tags:

views:

146

answers:

1

hi,

dompdf is not able to generate a pdf from a page of my website. However, I've saved the page and uploaded it as simple static html file, and it worked!

So, I dunno if the issue is with the url, or something else.. this is the error I get:

Warning: require_once(/home/o110334/public_html/dompdf/include/firephp.cls.php) [function.require-once]: failed to open stream: No such file or directory in /home/o110334/public_html/dompdf/dompdf_config.inc.php on line 194

Fatal error: require_once() [function.require]: Failed opening required '/home/o110334/public_html/dompdf/include/firephp.cls.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/o110334/public_html/dompdf/dompdf_config.inc.php on line 194

This is the code:

$file = "admin/store/orders/45/invoice/print"; // doesn't work
//$file = "invoice_sample2.html"; //it works (same web page, but stored in a html file)

$dompdf = new DOMPDF();
$dompdf->load_html_file($file);
$dompdf->render();
$dompdf->stream("sample.pdf");
A: 

DOMPDF is trying all kinds of stuff/eval's when running local, you're better of trying:

1) the (granted, long way trip) of requesting the HTML by http:

$dompdf->load_html_file('http://yourdomain.ext/'.$file);

2) Don't let DOMPDF eval but use output buffering itself, and let DOMPDF load the resulting string of HTML.

<?php
    ob_start();
    //be sure this file exists, and works outside of web context etc.)
    require("admin/store/orders/45/invoice/print");
    $dompdf = new DOMPDF();
    $dompdf->load_html(ob_get_clean());
    $dompdf->render();
?>
Wrikken
I've updated my question. The same page is correctly rendered if loaded from a static html file (even locally).
Patrick
That's what I said. i said do NOT let DOMPDF run your php.
Wrikken
Method #1 coded to be more portable $file = "/admin/store/orders/45/invoice/print"; $dompdf->load_html_file('http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).$file);
BrianS