0

I'm trying to implement the DOMPDF library on a worpdress page. The page has a custom template so I'm putting this code there:

<?php /**
/*
 * Template name: Prova
*/ 
get_header();

require_once (get_template_directory() . '/dompdf/dompdf_config.inc.php'); 
$dompdf = new DOMPDF();

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

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

get_footer();   

?>  

The page loads correctly and I can see the header and the footer of the template, but dompdf doesn't appear to work, as no pdf are generated. The path is correct. No error messages are shown. Am I missing something?

Thanks

Mick
  • 1
  • 1

1 Answers1

0
 $dompdf->stream("/try/your/directory/path/sample.pdf");

give it some path and check whether it got created in the corresponding folder or not..Ideally as per your syntax it should be there in the folder where your code file exists..

Danyal Sandeelo
  • 12,196
  • 10
  • 47
  • 78
  • Thanks Danyal,but no luck, the pdf is not created. If I use a die('test') before the require_once I see the die message. If I use it after the require_once, I get nothing. It seems like that when the dompdf library is required there is an error. – Mick Jan 30 '15 at 14:26
  • get_template_directory() . '/dompdf/dompdf_config.inc.php' are you sure this path is correct? – Danyal Sandeelo Jan 30 '15 at 18:08
  • Thanks Danyal. Of course, I even triend to include a random php script that I've put into the DOMPDF folder and it gets executed correctly. – Mick Feb 02 '15 at 08:40
  • Php would execute, I wanted to know whether the api is accessible or not due to given path in your php code.. – Danyal Sandeelo Feb 02 '15 at 08:49
  • Thanks Danyal for your help, I've found the problem. I had not created the "classes" directory in lib/php-font-lib and I had not copied in that directory the content of src/FontLib from this library: https://github.com/PhenX/php-font-lib. Found the solution here: http://stackoverflow.com/questions/15028250/dompdf-fails-to-load I had no clue about that since I wasn't getting any error message, just a blank page. Your help was really appreciated. Mick – Mick Feb 02 '15 at 10:10