问题
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:
- Chrome (win)
- Display: ok
- Download: empty file
- Firefox (win)
- Display: keeps on loading
- Download: empty file
- Firefox (mac)
- Display: keeps on loading
- Download: ok
- 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?
回答1:
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 :)
来源:https://stackoverflow.com/questions/30699270/fpdf-not-working-properly-in-some-browsers