Question:I can see there are a few options for doing this. My question is does any one know of a way that I can simply pass a PHP web page into a PDF creator and it outputs exactly the same as if it was viewed via a browser? Taking into consideration CSS, images and PHP functions etc. Is there any solution on VeryDOC?
Answer: According to your needs, maybe you can have a free trial of this software: VeryDOC HTMLPrint, which converts website to PDF by printing method. So by this software, you can output PDF totally same with the original webpage even if there is some image, css code and others. By this software, you can batch print html, mhtml files or Web URLs to Windows Printer, it is print the whole web page's content to Windows Printer without user interaction. As this is command line version software, so you can also call it via any programming or scripting languages, such as Visual Basic, C/C++, Delphi, ASP, PHP, C#, .NET, etc. Please check more detail information of this software on homepage, in the following part, let us check how to use this software.
Step 1. Free download HTMLPrint Command Line
- All the VeryDOC software are free downloading, so you can try it free without any fee produced.
- When downloading finishes, there will be a zip file. Please extract it to some folder then you can check related elements and help documents.
Step 2. Print webpage to PDF document using PHP
- Usage: htmlprint.exe [options] <HTML/MHTML file or URL>
- When print webpage to PDF, the following parameters will be helpful for you:
- When call this software from PHP code, please refer to the following code template:
-printer <string> : printer name to print
-prompt : prompt the user with the print dialog so they can change printer settings and/or select pages manually
-savedevmode <string> : prompt the user with print dialog and save the printer settings into a disk file.
-loaddevmode <string> : restore printer settings which saved by –savedevmode parameter.
-promptdevmode : prompt the user with print dialog and print the printer settings to screen.
-devmode <string> : restore printer settings which outputed by -promptdevmode parameter.
-hfflag <string> : set HTML header/footer to off or on.
-header <string> : set HTML header text.
-footer <string> : set HTML footer text.
-postdata <string> : set postdata when print HTML file.
$exeshell =new COM("exeshell.shell") or die("Can't start exeshell");
$exeshell->RunCommandLine("UserName", "Password", ' "htmlprint.exe" "C:\test.htm" "C:\out.pdf" ');
$exeshell = null;
During the using, if you have any question, please contact us as soon as possible.