I am bulding an application which take HTML format as input and generate PDF files as output. This library, I am using for reporting purpose. Now the problem is, I need to get data dynamically using PHP from database which ultimately will return HTML format after returning from PHP engine. Now how can I get this dynamically generated HTML file. So that I can make it as input to my library for report generation.
I hope clearly explained my requirement.
Thanks in advance.
Need HTML file format dynamically.
Moderator: General Moderators
the easiest way but not neccesarily the most effiecient is to assign all of the dynamic html document to a php variable then just echo out the variable.
As well then if you are generatin your pdf file at the same time you can just use the $html var.
Code: Select all
<?php
$html = "<html><head><title>$myPageTitle</title></head>";
$html .= "<body>$text_generated_eailer</bocy></html>";
echo $html;
?>-
kettle_drum
- DevNet Resident
- Posts: 1150
- Joined: Sun Jul 20, 2003 9:25 pm
- Location: West Yorkshire, England
Is it a php library to make the pdf?
Several things you can do, some more pratical than others - but they all revolve around running the page in some form or another. First simple way is to simply run the php page in a browser and save the output. This will get annoying if your makeing hundreds of pages. Simple way to speed it up would be to use a script to run curl to save the output:
etc.
Then if the pdf library is in php you can have it all done on a single page by buffering the output of the php and passing that to the library. Either buffer it yourself or use start_ob() and related functions.
Several things you can do, some more pratical than others - but they all revolve around running the page in some form or another. First simple way is to simply run the php page in a browser and save the output. This will get annoying if your makeing hundreds of pages. Simple way to speed it up would be to use a script to run curl to save the output:
Code: Select all
curl -O http://www.something.comThen if the pdf library is in php you can have it all done on a single page by buffering the output of the php and passing that to the library. Either buffer it yourself or use start_ob() and related functions.
- Maugrim_The_Reaper
- DevNet Master
- Posts: 2704
- Joined: Tue Nov 02, 2004 5:43 am
- Location: Ireland
You could also convert your html page into templates, then use a template engine to parse (but not output) the template using the dynamic data and pass the resulting string to your PDF library.
It's a variation on your first response, but each depends on how you generally generate your output at present...stick with what you know unless you have a good reason to change...
It's a variation on your first response, but each depends on how you generally generate your output at present...stick with what you know unless you have a good reason to change...