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
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?

Link to comment
Share on other sites

  • 1 month later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.