I am using smarty template to generate a page on-the-fly that consists of user-submitted form data and uploaded images. I can get to display all the contents as expected. I want the same to be output as PDF. The template is named index.tpl, and is located inside the template folder. I can't figure out how to put these two together. Any help would be appreciated, thanks. I tried the following, but doesn't work. There is no output.
require_once("dompdf/dompdf_config.inc.php");
$html = $smarty->fetch('index.tpl');
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("pdf_file.pdf");
When I checked the error_log, I noticed "PHP Fatal error: Class 'DOMPDF' not found" line. HOWEVER, when I created a simple file as shown below, I get it working perfectly (PDF is generated).
require_once("dompdf/dompdf_config.inc.php");
$html =
'<html><body>'.
'<p>Hello World!</p>'.
'</body></html>';
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("pdf_file.pdf");
What is happening here? Why the difference?