PDF won't open

823 views
Skip to first unread message

Wasim

unread,
Feb 7, 2012, 1:29:42 PM2/7/12
to dompdf
Hi,

I'm using the most basic example you have (see below) and the PDF
downloads, but it doesn't open. I've tried opening it in Google Chrome
but it says "Failed to load PDF document" and i've tried opening it in
Preview for mac and I get this error "It may be damaged or use a file
format that Preview doesn’t recognize.".

I've copied the example exactly, what could be the problem?


require_once("dompdf_config.inc.php");

$html =
'<html><body>'.
'<p>Put your html here, or generate it with your favourite '.
'templating system.</p>'.
'</body></html>';

$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("sample.pdf");

BrianS

unread,
Feb 7, 2012, 11:10:55 PM2/7/12
to dom...@googlegroups.com
It will be easier to see why these applications are reporting the PDF corrupted if you post the resulting PDF.

More than likely some non-PDF content is being inserted into the PDF stream due to output buffering. The easiest way to tell this is to open your PDF in a plain text editor (e.g. Notepad, TextEdit, vi).

Wasim

unread,
Feb 12, 2012, 8:27:21 AM2/12/12
to dompdf
Thanks very much got it working now, I was using print_r() on an array
just before, I didn't realise that it considered the PHP page's output
as well as the $html loaded variable, why does it do this?
Reply all
Reply to author
Forward
0 new messages