Well, I spent half a day testing on this issue. I have to say that this is a solution for printing images from a database row directly, without saving them in temporary files.
I am going to write a few points to consider:
- I use the type of blobs in the database to store the human signature for printing in a PDF document.
- I send a signature to be saved to the database using the post method from the canvas node.
- When I print a line from the db blob, it does not contain the "+" character, which does not allow me to print the signature correctly. To solve this problem, I am doing str_replace to remove spaces and insert a plus symbol.
Then the only thing you need to do is:
$pdf->Image(str_replace(' ','+',$dbRow['blobImage']),160,150,20,10,'png');
If you, like me, need to print several images from the database, you should see if they came or not, because if the image is empty, you will have an error.
I just add this to the last code:
if( $dbRow['blobImage'] ){ $pdf->Image(str_replace(' ','+',$dbRow['blobImage']),160,150,20,10,'png'); }
NOTE:
- 160 β X image position
- 150 β Y image position
- 20 β X Image Scale
- 10 β Y Image Scale
- 'png' β The base format of my Base64 image type.
source share