使用基本 HTML 标签时,DOMPDF PDF 文件无法在 Adobe 中打开
我正在尝试根据一些简单的 HTML 输出生成一些非常简单的 PDF。我的预期输出的基本结构是:
Category Name 1
[Product Image 1] Product Name 1
[Product Image 2] Product Name 2
Category Name 2
[Product Image 3] Product Name 3
我可以从 HTML 生成一些非常基本的 PDF(我正在使用 DOMPDF 0.5)。例如,内容为“test”的 PDF 可以正常导出。
但是,一旦我尝试插入哪怕是最轻微的 HTML 标记,PDF 就会导出,但不再在 Adobe Acrobat 中打开,而是给出错误:
'Adobe Reader 无法打开 filename.pdf 因为它不是 支持的文件类型或因为 文件已损坏(例如, 作为电子邮件附件发送并且 未正确解码)。
有人遇到过类似的问题吗?似乎有时我可以使用 pargaraph
等标签打开文件,但使用 test
生成文件会失败的。是否有任何解决方案或有任何更好的替代方案来使用 DOMPDF(前提是该解决方案可以在共享托管环境上使用)。
干杯
I am trying to generate some VERY simple PDFs based on some simple HTML output. My basic structure of expected output is:
Category Name 1
[Product Image 1] Product Name 1
[Product Image 2] Product Name 2
Category Name 2
[Product Image 3] Product Name 3
I can generate some very basic PDFs fine (I'm using DOMPDF 0.5) from my HTML. For example, a PDF with the content 'test' exports fine.
However, as soon as I try to insert even the slightest HTML markup, the PDF exports but no longer opens in Adobe Acrobat, instead giving the error:
'Adobe Reader could not open
filename.pdf because it is either not
a supported file type or because the
file has been damaged (for example, it
was sent as an email attachment and
wasn't correctly decoded).
Has anyone had a similar problem? It seems sometimes I can get the file to open with tags like <h1>test</h1>
but generating a file with <p>pargaraph</p>
would fail. Is there any solution or are there any better alternatives to using DOMPDF (provided the solution can be used on a shared hosting environment).
Cheers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题出在你的 PHP 版本上。它不支持“set_magic_quotes_runtime”,并且您的 PDF 基本上被 php 错误覆盖。
您可以抑制 PHP 错误或将“@”放在 lib/class.pdf.php 中对 set_magic_quotes_runtime 的调用前面
Problem is with your PHP version. It doesn't support "set_magic_quotes_runtime", and your PDFs are basically being overwritten with php error.
You can either suppress PHP error or put "@" in front of calls to set_magic_quotes_runtime in lib/class.pdf.php