Nicolas
Nicolas

Reputation: 269

FPDF image not displaying

I tried to put an image in my pdf document, but when I use that method it only loading for a while, and do nothing (no errors, or such things) only a grey site...

$pdf = new FPDF();
$pdf->AddPage();
$pdf->Image('logo.png');
$pdf->Output();

So what I do wrong? If I only use text in the pdf, it's no problem, but with the Image. The Image is in the root-directory.

Edit: Added $pdf->AddPage(); as per the comment in Ewan Heming's answer.

Upvotes: 0

Views: 6369

Answers (2)

Nicolas
Nicolas

Reputation: 269

Sry guys i found out the problem , the resolution of the picture was too big

Upvotes: 3

Ewan Heming
Ewan Heming

Reputation: 4648

Your example doesn't include a method call to add a page to the PDF before placing the image on it:

$pdf = new FPDF();
$pdf->AddPage();
$pdf->Image('logo.png');
$pdf->Output();

Upvotes: 4

Related Questions