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

2.8k Views Asked by At

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

1

There are 1 best solutions below

0
On

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