FPDF not working properly in some browsers

六月ゝ 毕业季﹏ 提交于 2019-12-11 12:16:36

问题


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?


回答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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!