How to create PDF from HTML using HTML2PDF Add-on for Pdf Creator Pilot library
"Hello, HTML2PDF!" example
Step by Step:
HTML2PDF Add-on for PDF Creator Pilot can be used in Visual Basic, Visual Basic.NET, ASP, ASP.NET, VBScript (Visual Basic scripted language) as well as in Visual C, Visual C# and Delphi.
This page contains step by step tutorial that will teach you how to convert HTML document into PDF file from VBScript using PDF Creator Pilot library and HTML2PDF add-on.
Windows 98/2000/ME/XP has a built-in VBScript interpreter so all you have to do is to create a text file which contains script and save it using .vbs extension.
1) Install PDF Creator Pilot library and HTML2PDF add-on on your computer
2) Run Notepad and create a new text file.
3) To create a PDF file from VBScript, you have to write a very simple script that will do the following steps:
- create and initialize PDF Creator Pilot object
- set filename for the PDF file
- initialize HTML2PDF add-on and connect to PDF Creator Pilot instance
- load HTML document into HTM2PDF add-on
- convert HTML document into PDF
- disconnect HTML2PDF add-on from PDF Creator Pilot instance
Content of "HelloHTML2PDF.vbs" file:
' create pdf library object
Set PDF = CreateObject("PDFCreatorPilot2.piPDFDocument")
' initialize PDF Engine
PDF.StartEngine "demo@demo", "demo"
' set AutoLaunch flag to TRUE to automatically open the generated pdf generation
PDF.AutoLaunch = TRUE
PDF.FileName = "HelloHTML2PDF_VBS.pdf"
' start document generation
PDF.BeginDoc
Set HTML = CreateObject("HTML2PDFAddon.HTML2PDF")
' initialize HTML engine
HTML.StartHTMLEngine "",""
' connect to PDF Creator Pilot instance
HTML.ConnectToPDFLibrary PDF
' load HTML file into HTML renderer
HTML.LoadFromString "<HTML><BODY><H1>Hello,PDF2HTML!</H1></BODY></HTML>", ""
' convert whole HTML document into PDF
HTML.ConvertAll
' disconnect from PDF Creator Pilot instance
HTML.DisconnectFromPDFLibrary
Set HTML = nothing
' finalize PDF generation
PDF.EndDoc
Feel free to copy this code to Notepad and save it as a "HelloPDF.VBS"
4) Double-click "HelloHTML2PDF.VBS" file from Explorer or from another file manager and it will run the script.
If you have PDF viewer installed (for example, Adobe Reader, then the script will open HelloHTML2PDF_VBS.PDF file as shown on the screenshot below:

You can find the source code of this example in the "\Examples\" sub-folder.