Components for Developers & PDF Software → HTML2PDF Add-on Examples

How to create PDF from HTML using HTML2PDF Add-on for Pdf Creator Pilot library


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:

  1. create and initialize PDF Creator Pilot object
  2. set filename for the PDF file
  3. initialize HTML2PDF add-on and connect to PDF Creator Pilot instance
  4. load HTML document into HTM2PDF add-on
  5. convert HTML document into PDF
  6. disconnect HTML2PDF add-on from PDF Creator Pilot instance

Content of "HelloHTML2PDF.vbs" file:

' create pdf object
Set PDF = CreateObject("PDFCreatorPilot.PDFDocument3")
PDF.StartEngine "demo", "demo"
PDF.AutoLaunch = true
PDF.FileName = "HelloHTML2PDF_VBS.pdf"

' create html2pdf object
Set HTML = CreateObject("HTML2PDFAddon.HTML2PDF2")
HTML.StartHTMLEngine "demo", "demo"
HTML.ConnectToPDFLibrary PDF

' load HTML file into HTML renderer
HTML.LoadHTMLString "<HTML><BODY><H1>Hello, PDF!</H1></BODY></HTML>", ""

' finalize PDF generation
Set HTML = nothing
Set PDF = nothing

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 of installation folder of HTML2PDF Add-on.

HTML2PDF Add-on menu

Send us your comments

We're really eager to hear from you. Please send us your suggestions in one of two ways: