问题描述
我有一个使用FPDF创建PDF的PHP文件.我的php文件在阅读了几美元的$ _ post值后做到这一点,这些值"确定"显示了什么. PDF是一个页面,仅包含通过单元格()和一些PNG图像包含简单的文本.
PDF显示不同的行为浏览器.我在文档中没有找到有关此信息的任何信息.我找到了以下测试结果:
- Chrome(Win)
- 显示:确定
- 下载:空文件
- Firefox(赢)
- 显示:继续加载
- 下载:空文件
- Firefox(Mac)
- 显示:继续加载
- 下载:确定
- Safari(Mac)
- 显示:确定
- 下载:确定
在上面的内容中,我的意思是下载:"将文件另存为"从显示视图中分开,以通过输出('foo.pdf',d)区分强制下载.后者也显示出不一致的结果.
什么会导致我的问题?我可以采取哪些步骤进行调试?
推荐答案
持续挖掘后,我发现了所有麻烦的原因:
$pdf->Cell(0,13,' ',0,1);
因此,似乎不允许编写包含一个空间的单元格.相反,您可以写
$pdf->Cell(0,13,'',0,1);
没有问题.
编辑:我在第一个setFont()之前犯了一个错误.如果首先具有SETFONT(),则允许在Cell()中的空间.我的坏:)
问题描述
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?
推荐答案
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 :)