On Oct 13, 5:22 am, Dennis Meyer <
snooop...@googlemail.com> wrote:
> I just want to add a image into my header, i read the faq and tried
> the example, i was a little bit confused about the missing } at the
> end, whatev.
> This is my HTML template:
>
> <html>
> <body>
> <p>Hello World</p>
> <script type="text/php">
> if ( isset($pdf) ) {
>
> $header = $pdf->open_object();
> $pdf->image("pix/bb_iqment02.JPG", "jpg", 1, 10, 570, 130);
> $pdf->close_object();
> $pdf->add_object($header, "all");
> }
> </script>
> </body>
> </html>
Your HTML looks fine, but you'll probably need to use a full local
filesystem path in the $pdf->image() function. I believe, though I
would need to double-check, that this image looks relative to the
executing PHP file. However, this is not the source of your error.
> And this is the call:
>
> require_once("dompdf/dompdf_config.inc.php");
> $html = file_get_contents('modules/offer/pdftemplate.html');
>
> $dompdf = new DOMPDF();
> $dompdf->load_html($html);
> $dompdf->set_paper('a4', 'portrait'); // letter, landscape
> $dompdf->render();
> $dompdf->stream("sample.pdf");
Looks fine.
> And this is my error ;-)
>
> Fatal error: Uncaught exception 'PDFlibException' with message
> 'Function must not be called in 'template' scope' in /is/htdocs/
> wp1046861_Z1H6V86WEE/pm/modules/offer/dompdf/include/
> pdflib_adapter.cls.php:658 Stack trace: #0 /is/htdocs/
> wp1046861_Z1H6V86WEE/pm/modules/offer/dompdf/include/
> pdflib_adapter.cls.php(658): PDFlib->load_image('jpeg', 'pix/
> bb_iqment02...', '') #1 /is/htdocs/wp1046861_Z1H6V86WEE/pm/modules/
> offer/dompdf/include/php_evaluator.cls.php(66) : eval()'d code(6):
> PDFLib_Adapter->image('pix/bb_iqment02...', 'jpg', 1, 10, 570, 130)
> #2 /is/htdocs/wp1046861_Z1H6V86WEE/pm/modules/offer/dompdf/include/
> php_evaluator.cls.php(66): eval() #3 /is/htdocs/wp1046861_Z1H6V86WEE/
> pm/modules/offer/dompdf/include/php_evaluator.cls.php(70):
> PHP_Evaluator->evaluate('???if ( isset($...') #4 /is/htdocs/
> wp1046861_Z1H6V86WEE/pm/modules/offer/dompdf/include/renderer.cls.php
> (180): PHP_Evaluator->render(Object(Null_Frame_Decorator)) #5 /is/
> htdocs/wp1046861_Z1H6V86WEE/pm/modules/offer/dompdf/include/
> renderer.cls.php(120): Renderer->_ren in /is/htdocs/
> wp1046861_Z1H6V86WEE/pm/modules/offer/dompdf/include/
> pdflib_adapter.cls.php on line 658
What version of PHP, DOMPDF, and PDFLib are you using? I have not been
able to reproduce this error as yet. I'll try and help you figure out
the source of the error, but in the meantime you can work around the
problem by using the built-in CPDF adapter. Set DOMPDF_PDF_BACKEND to
"CPDF" to do so.
-b