Jump to content

Convert HTML page to PDF


pealo86

Recommended Posts

This is a bit of a long shot, but hopefully somebody can point me in the right direction.

 

I have a wordpress website that has a 'Wine List' page, in which it lists over 100 'custom posts' detailing each wine. I have tried out several plugins to convert the wine list into a PDF but none work in the way that I require.

 

So now I'm thinking to just do it outside of wordpress and find a PHP script that may help me.

 

I imagine it would be impossible to simply execute a script at the bottom of a page for it to convert whatever HTML has been generated into a PDF?

 

Or is there anything that would allow me to specify what records from the database to add to the PDF? E.g. for me to type a PHP script with a MySQL command and for that to be converted into a PDF?

 

Thanks if anybody has any ideas what action I should take!

Link to comment
https://forums.phpfreaks.com/topic/220360-convert-html-page-to-pdf/
Share on other sites

Hmmm I'm a little stuck now. I've uploaded the relevant files and have added this code to the very top of my template:

<?php if(is_page(235)) { require_once(TEMPLATEPATH . "/script/dompdf/dompdf_config.inc.php"); } ?>

 

And this to the very bottom (going by the example code in the usage section):

<?php
if(is_page(235)) {
	require_once(TEMPLATEPATH . "/script/dompdf/dompdf_config.inc.php");

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

 

However I cannot figure out how to actually view the PDF! If it's even being created that is. No error message is coming up (which I assume is a good thing?).

 

I can also confirm that the two 'if' statements are evaluating to true from simply adding echo statements in to make sure.

 

Does anyone know what I'm missing?

  • 1 month later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.