# How to print html to PDF?

Question: What possible HTML Converter can I use to print a specific html page to PDF? Do you have any suggestions or know plug ins that can be easily customize and modify? By the way, if it has to be done via a programming language PHP, Java or ASP.NET. Please specifics! Can you help me out further in the matter.

Answer: A long time ago I used Apache FOP which implements XSL-FO and allows conversion of XML (e.g. XHTML) to PDF (and other formats). This is flexible, but not very easy. Nowadays, there are webkit-based solutions (wkhtmltopdf, webkit2pdf, wkpdf, in a day) which can render to PDF from any HTML soup parable by webkit.  VeryPDF HTML Converter supports the conversion from HTML to PDF by advanced WebKit technology which is a layout engine designed to allow web browsers to render web pages. And this technology now is used by Safari, Chrome and Opera.

And when you need to print HTML to PDF together with a programming language PHP, Java or ASP.NET, VeryPDF HTML Converter can not help you do this as there is no COM or SDK version of this software. But you can try another software VeryPDF Doc Converter COM, which can help you convert files of Microsoft Word, PowerPoint, Excel, JPG, PNG, GIF, HTML and others to PDF by script together with other application like VB, VC, C# etc.

Now let us check one example of PHP code of Doc Converter COM:

A: Some examples for call DocConverter COM Service from PHP code:
Example 1:
<?php
$url = "http://www.verypdf.com";$path = "C:\\test.pdf";
$com = new COM("PdfOut.PdfCreator");$com->html2PDF = $url;$com->fileName = $path;$com->Doc2PDFViaSocket();
?>
Example 2:
<?php
$PdfCreator =new COM("PdfOut.PdfCreator") or die("Cannot start PdfCreator");$PdfCreator->Doc2PDFCommandLine(' "c:\input.doc" "c:\output.pdf" ');
$PdfCreator = null; ?> Example 3: <?php$url = "http://www.verypdf.com";
$path = "C:\\test.pdf";$com = new COM("PdfOut.PdfCreator");
$com->Doc2PDFCommandLine("\"$url\" \"\$path\" \"paperType=0,PrintHTMLBackground=yes,overwrite=yes\"");
?>

If you do not need to call this software together with other applications, HTML Converter Command Line developer version is enough for you. And by the latest version of this software, WebKit technology enables the Webkit engine to convert HTML and web pages to PDF files fast and accurately. So the conversion will be much more accurate and fast. Now let us check some parameters and examples of this software:
-webkit : use the Webkit engine to convert HTML and web pages to PDF files.
-nosplitimg :don't break images in HTML file. When convert long HTML file and specify output file size, sometimes images in source file will be split for catering size setting. Add this parameter; the images will not be split.
-postdata <string>: set the data to be posted to the URL. Use this function for some URLs protected by forms.
-fitpage : scale page content to fit the PDF paper format automatically. Page margins will NOT be cut when long HTML file is converted to PDF and the output PDF page size is specified
htmltools.exe -webkit "http://www.verypdf.com" D:\out.pdf
htmltools.exe -fitpage -width 612 -height 792 -emfheight 792 C:\in.htm C:\out.pdf
htmltools.exe -fitpage -width 612 -height 792 -pageheight 792 C:\in.htm C:\out.pdf

If you need to more information and parameters, please visit homepage of this software. During the using, if you have any question, please contact us as soon as possible.

VN:F [1.9.20_1166]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.20_1166]
Rating: 0 (from 0 votes)

## Related Posts

This entry was posted in HTML Converter (htmltools) and tagged . Bookmark the permalink.