I\'m storing signatures (using signaturepad in my database Coldfusion/MySQL 5.0.88
and would like to output the signature I\'m taking onto a pdf which I\'m gene
Originally, I was going to convert to PNG and the more I thought about it, it was more overhead then necessary. After all, Signature Pad give us everything we need to re-draw the signature in FPDF.
I did the following:
// decode the signature into an array
$sig = json_decode($signatureInJSON);
// for each line segment
foreach ($sig as $line) {
$lx = $line->lx;
$ly = $line->ly;
$mx = $line->mx;
$my = $line->my;
// draw the line
$pdf->Line($lx, $ly, $mx, $my);
}
Obviously, I also added some functions to scale the signature and offset it to where I wanted in the PDF.
Hope that helps someone else.
The issue is here
$pdf->imagepng($img);
^-------------- This should be an image path (String)
Solution
$file = 'signature.png' ;
imagepng($img, $file);
^----------- Save Image to File Instead
Then
if ($imgProceed == "true") {
$pdf->imagepng($file);
} else {
$pdf->Cell(50, 4, '', 0, 1);
}