0

HTML Doc PHP Implementation

I want to use PDF in my project to print the report. Currently my report is in HTML format since it is easy to generate using PHP. Before this, I have try to use DOMPDF and TCPDF, but unfortunately, there is a lot of customization need to be done to get a good PDF report.
Finally, I found HTMLDoc. It's open source but to get the compiled-ready binary you need to buy.
Fortunately. I found the free compiled binary here :

http://htmldoc-binaries.org/

Download and install HTMLDoc.
 public function topdf($filename, $options = "") {

$path = "library_includes/general/htmldoc/htmldoc.exe";
$path=realpath($path);
# Tell HTMLDOC not to run in CGI mode...
putenv("HTMLDOC_NOCGI=1");

$scmd = "$path -t pdf --quiet --landscape --jpeg --webpage --header ... $options $filename";
# Write the content type to the client...
header("Content-Type: application/pdf");
flush();
system($scmd);
}
Just submit your URL / file name and the HTMdoc will will create the PDF on the fly.
For more details about the command line, you can refer be to the document :

http://www.easysw.com/htmldoc/docfiles/8-cmdref.html

But, if your url is password protected using login and session, you need to handle to bypass the session checking since HTMLDoc read the url and PHP will treat HTMLDoc as new session rather than your current.
 
Copyright © peyotest