0

I'm trying to paste an image onto a pdf. $img is a php generated PNG file. The image appears when echoed.

echo "<img src='".$img."'>";
sleep(5);

// initiate FPDI  
$pdf = new FPDI();  
$pdf->setPrintHeader(false);
// add a page


// set the sourcefile  
$pdf->setSourceFile('reports/Report'.$r.'.pdf');
$tplIdx = $pdf->importPage(1);
$pdf->AddPage();    
$pdf->useTemplate($tplIdx, 10, 10, 200); 
$pdf->Image($img, 26, 57, 170, 134, 'PNG', '', '', true, 150, '', false, false, 1, false, false, false);

$filename = $_SERVER['DOCUMENT_ROOT']."pdf/test.pdf";
$pdf->Output($filename,'F');

There is no error log, and test.pdf is blank at the place where $img should be.

Do you know the reason for this error ?

thank you in advance :)

cj123456
  • 1
  • 1
  • 2
    What _is_ `$img`? You have not shown us where that variable gets is value to begin with. – misorude Jan 14 '19 at 13:27
  • Where do you define $img? You can also check with file_exists() function, if the path and filename is correct. – Bernhard Jan 14 '19 at 14:18
  • $img is a php generated PNG file. The image appears when echoed. Edited the above code. – cj123456 Jan 14 '19 at 16:40
  • The code works when the php generated PNG file is replaced with an identical file on the hard drive. Even with a 5 seconds delay, the php generated PNG file could not be pasted on the pdf. – cj123456 Jan 14 '19 at 16:51

0 Answers0