php - Add base64 image from canvas to pdf button -


i have html form uses canvas allow users sign name. there quite lot of code involved in project, difficult copy/paste working code.

when form submitted, fields , base64 string (e.g. "data:image/png;base64,blahblahetc") sent processing -- field values saved database, , signature images saved server.

the parts uncertain are:

1 - can add signature image icon on designated button on final pdf? there better way signature image onto pdf? i've seen can't manage use following syntax:

<< /t (button1)/apref << /n << /f (http://www.yoursite.com/pfds/icons.pdf)/name (icon3)>> >> >>  

2 - achieve preparing .png or .pdf file set button? have been successful in generating .png on server, haven't tried .pdf because don't know if need it.

3 - using php , pdftk fill final pdf dynamic fdf. need perform special preparations on signature button on pdf template? think read setting layout "icon only."

i ears if has advice, experience, or snippets. happy give more details if i've left out.

tia

p.s. quite have follow questions, if help, please stay tuned.

since not find way apply signature pdf button, had fiddle , hack form data , signatures server onto new pdf.

first fopen/fwrite form values new fdf, use pdftk generate unsigned pdf:

echo exec("cd $submissions_path/; $pdftk \"$template\" fill_form \"$fdf\" output \"$unsigned_pdf\"; chmod 777 \"$unsigned_pdf\";"); 

then fopen/fwrite base64 signatures signature images:

$fp=fopen("$submissions_path/$simg","wb"); fwrite($fp,base64_decode($scode)); fclose($fp); 

then generate .html watermark converted watermark .pdf using mpdf (please excuse use of tables, mpdf didn't <div>'s):

$watermark_pdf="installorder_{$submissionid}_watermark.pdf"; $watermark_html="<table style=\"width:792px;height:1123px;\"><tr>"; $watermark_html.="<td colspan=\"2\" style=\"padding-top:900px;padding-left:70px;width:240px;height:20px;\">{$watermark[customersignature]}</td>"; $watermark_html.="</tr><tr>"; $watermark_html.="<td style=\"padding-top:16px;padding-left:69px;width:240px;height:20px;\">{$watermark[ownersignature]}</td>"; $watermark_html.="<td style=\"padding-top:16px;padding-left:169px;width:240px;height:20px;\">{$watermark[managersignature]}</td>"; $watermark_html.="</tr></table>"; include("../mpdf/mpdf.php"); //include mpdf class $mpdf=new mpdf('','',0,'',0,0,0,0,0,0,'p'); // create new mpdf document $mpdf->writehtml($watermark_html); $mpdf->output("$watermark_pdf","f");    //save file server - may include path 

finally, stamp watermark.pdf onto unsigned.pdf using pdftk again:

echo exec("cd $submissions_path/; $pdftk \"$unsigned_pdf\" stamp \"$watermark_pdf\" output \"$pdf\""); 

the tedious part correctly setting size , position of signature images on watermark html.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -