Page 1 of 1
Need HTML file format dynamically.
Posted: Mon Nov 29, 2004 8:21 am
by inpreet
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.
Posted: Mon Nov 29, 2004 9:15 am
by phpScott
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.
Code: Select all
<?php
$html = "<html><head><title>$myPageTitle</title></head>";
$html .= "<body>$text_generated_eailer</bocy></html>";
echo $html;
?>
As well then if you are generatin your pdf file at the same time you can just use the $html var.
Posted: Mon Nov 29, 2004 9:19 am
by kettle_drum
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.
Posted: Mon Nov 29, 2004 10:58 am
by Maugrim_The_Reaper
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...