简体   繁体   English

使用基本HTML标记时,DOMPDF PDF文件无法在Adobe中打开

[英]DOMPDF PDF file fails to open in Adobe when using basic HTML tags

I am trying to generate some VERY simple PDFs based on some simple HTML output. 我试图基于一些简单的HTML输出生成一些非常简单的PDF。 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. 我可以从HTML生成一些非常基本的PDF(我正在使用DOMPDF 0.5)。 For example, a PDF with the content 'test' exports fine. 例如,内容为“ test”的PDF可以很好地导出。

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: 但是,一旦尝试插入最小的HTML标记,PDF就会导出,但不再在Adobe Acrobat中打开,而是出现错误:

'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). “ Adob​​e Reader无法打开filename.pdf,因为它不是受支持的文件类型,或者因为文件已损坏(例如,它作为电子邮件附件发送且未正确解码)。

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. 有时候我可以使用<h1>test</h1>类的标签打开文件,但是使用<p>pargaraph</p>生成文件会失败。 Is there any solution or are there any better alternatives to using DOMPDF (provided the solution can be used on a shared hosting environment). 有没有使用DOMPDF的解决方案或有更好的替代方法(只要该解决方案可以在共享主机环境中使用)。

Cheers 干杯

Problem is with your PHP version. 问题出在您的PHP版本上。 It doesn't support "set_magic_quotes_runtime", and your PDFs are basically being overwritten with php error. 它不支持“ set_magic_quotes_runtime”,并且您的PDF基本上被php错误覆盖。

You can either suppress PHP error or put "@" in front of calls to set_magic_quotes_runtime in lib/class.pdf.php 您可以抑制PHP错误,也可以在lib / class.pdf.php中对set_magic_quotes_runtime的调用前面加上“ @”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM