Phragma
Phragma

Reputation: 21

FPDF not working properly in some browsers

I have a php file which creates a PDF using FPDF. My php file does that after reading a few $_POST values, which "determine" what to display. The PDF is a single page, only containing simple text via Cell() and a few PNG images.

The PDF shows different behaviour accross browsers. I didn't find any information regarding this in the documentation. I found the following test-results:

  1. Chrome (win)
    • Display: ok
    • Download: empty file
  2. Firefox (win)
    • Display: keeps on loading
    • Download: empty file
  3. Firefox (mac)
    • Display: keeps on loading
    • Download: ok
  4. Safari (mac)
    • Display: ok
    • Download: ok

In the above, I mean with download: "Save file as" from the display-view, to distinguish from forced download via Output('foo.pdf', D). The latter is showing inconsistent results too.

What can cause my problems? Which steps can I take to debug any further?

Upvotes: 1

Views: 2158

Answers (1)

Phragma
Phragma

Reputation: 21

After persistent digging, I found the cause for all trouble:

$pdf->Cell(0,13,' ',0,1);

So writing cells containing a space only seems to be not allowed. Instead, you can write

$pdf->Cell(0,13,'',0,1);

without problems.

Edit: I made the mistake to call Cell() before the first SetFont(). If you have set SetFont() first, a space in Cell() IS allowed. My bad :)

Upvotes: 1

Related Questions