Components for Developers © 2000-2008, Two Pilots

PDF Library Download Features Manual Tutorials FAQ Pricing HTML2PDF Add-on History In the Lab

 

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:

  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 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.

 

HTML2PDF Add-on for PDF Creator Pilot main page

PDF Library Download Features Manual Tutorials FAQ Pricing HTML2PDF Add-on History In the Lab

 

 

PDF Library | Virtual Printer | Converters to PDF

Support | Blog | Forum | Contacts | Site map

© 2000-2008, Two Pilots