Hi I'm trying to use php to covert html to pdf. The code is able to run and I able to run it and download a pdf file but when I open the pdf file it gives me this error
This is the code I have to run the php
'<p>Put your html here, or generate it with your favourite '.
$dompdf = new DOMPDF();
<? ^^^---- these spaces will corrupt the PDF require_once("dompdf/dompdf_config.inc.php");
If you really do have those 3 spaces before your PHP opening tag, they will become part of the PDF file and corrupt it. Load up your "bad" pdf, do a file->save, and opening the file in a text/hex editor (NOT a pdf reader) and see what you're getting. Any PHP errors/warnings or other output before the actual PDF data will cause the PDF readers to see it as corrupted.