In this article, I will show you a method of converting HTML to PDF and keeping background color and images in output PDF file. Meanwhile this method also can be used to convert HTML to PDF and disable background color and images. The software I use is named as VeryDOC Doc Converter COM, which is COM object for developers. By it you can develop software for file format conversion like converting files of Microsoft Word, PowerPoint, Excel, JPG, PNG, GIF, HTML and others to PDF based on this software. Here I will take converting HTML to PDF and keeping background color and images for example to show you how to use this software.
Step 1. Free trial Doc Converter COM
- As this is COM software, we have compressed it to zip file. When downloading finishes, please extract it to some folder then you can find executable file, dll and other code templates.
- When install this software, please refer to the following steps.
1.1. Please download and install PDFcamp Printer v2.3 or PDFcamp Printer Pro v2.3 from our website,
http://www.verypdf.com/pdfcamp/pdfcamp_setup.exe
1.2. Please download DocConverter COM from our website,
http://www.verypdf.com/pdfcamp/doc2pdf_com_trial.zip
1.3. Please unzip "doc2pdf_com_trial.zip" package to a folder, and run "install_as_exe.bat" file to install the DocConverter COM into your system,
1.4. Then you can run HTML2PDF.exe from command line to try, HTML2PDF.exe is a Windows Command Line Tool, you can run it from command line window.
Step 2. Convert HTML to PDF and keeping background color and images.
- When converting HTML to PDF together with other applications like Visual Basic, C/C++, Delphi, ASP, PHP, C#, .NET, etc, please refer to following code template:
<%
set PdfCreator = server.createobject("PdfOut.PdfCreator")
PdfCreator.html2PDF= "http://www.google.com/"
PdfCreator.fileName = "C:/google.pdf"
result = PdfCreator.Doc2PDFViaSocket()
set PdfCreator = nothing
%>
And when converting HTML to PDF and keeping background color and image, please add the following command line templates:
"html2pdf.exe" "http://www.verypdf.com/pdfcamp/pdfcamp.htm" "C:/output.pdf" "PrintHTMLBackground=yes"
If you do not need to keep background color and image, please refer to the following one:
"html2pdf.exe" "http://www.verypdf.com/pdfcamp/pdfcamp.htm" "C:/output.pdf" "PrintHTMLBackground=no"
When you use this software for HTML to PDF conversion, please make sure that you have PDFcamp and Windows Internet Explorer 5.0 or newer installed, or else the conversion can not be done successfully.
By this software, you can do lots of jobs for file formats conversion. You can print any kind of file which could be opened normally to PDF by this application. Please check more information of this software on homepage, during the using, if you have any question, please contact us as soon as possible.