Converting Dynamic HTML TO PDF using html2pdf

Viewed 19517

The pages I want to convert are generated dynamically via PHP from a MySQL database. In other words the information on a page depends on the Id of the chosen object. So I would normally have a URL like this

renal_prescRequest_review.php?id=4

I am using html2pdf and so far I am unable to perform the conversion. When I pass id=2 directly like this

// get the HTML
ob_start();
include("renal_clinicalTrial_review.php?id=2");
$content = ob_get_clean();`

I get these errors:

Warning: include(renal_prescRequest_review.php?id=2) [function.include ]: failed to open stream: No such file or directory in/home/renalmed/public_html/testing/test/renal_prescRequest_pdf.php on line5

Warning: include(renal_prescRequest_review.php?id=2) [function.include]: failed to open stream: No such file or directory in /home/renalmed/public_html/testing/test/renal_prescRequest_pdf.php on line5

Warning: include() [function.include]: Failed opening 'renal_prescRequest_review.php?id=2' for inclusion(include_path='.:/usr/lib/php:/usr/local/lib/php') in/home/renalme/public_html/testing/test/renal_prescRequest_pdf.php on line5.

The fascinating thing is that these errors are thrown on the PDF document where the actual HTML is supposed to be displayed. I have been on this for quite a while now. Please help.

5 Answers

You can not include the file like this :

include("renal_clinicalTrial_review.php?id=2");

You should do it like this :

include("renal_clinicalTrial_review.php");

The parameter is then passed to the calling page.

For example, if your code is saved as test.php, then call it like this:

test.php?id=2
Related