Components for Developers © 2000-2008, Two Pilots

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

PDF version of this article is available.
Click here to download.

How to create PDF file in VBScript: "Hello, PDF!" example

Step by Step

 

PDF Creator Pilot can be used in VBScript (Visual Basic scripted language). This page contains a step-by-step tutorial that will teach you how to create PDF files from VBScript using PDF Creator Pilot library.

Windows 98/2000/ME/XP has a built-in VBScript interpreter so all you have to do is to create text file which contains script and save it using ".vbs" extension.

1) Install PDF Creator Pilot library 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 the file name for your PDF file;
  3. draw "Hello, PDF!" message on the PDF document;
  4. disconnect from the library.

Content of "HelloPDF.vbs" file:


 ' create pdf library object

 Set PDF = CreateObject("PDFCreatorPilot3.PDFDocument3")

 ' initialize PDF Engine

 PDF.StartEngine "demo@demo", "demo"

 ' set AutoLaunch flag to TRUE to open document automatically

 PDF.AutoLaunch = true

 PDF.FileName = "HelloPDF_VBS.pdf"

 ' start document generation

 PDF.BeginDoc

 ' draw "HELLO, PDF" message on the current PDF page

 PDF.PDFPAGE_SetActiveFont "Verdana", True, False, False, False, 14, 0

 PDF.PDFPAGE_TextOut 10, 20, 0, "HELLO, PDF!"

 ' finalize document generation

 PDF.EndDoc

 ' disconnect from library

 Set PDF = Nothing
 

Feel free to copy this code to Notepad and save it as "HelloPDF.VBS":

4) Double-click "HelloPDF.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 HelloPDF_VBS.PDF file as shown on the screenshot below:

You can download the script code for the described example here (23 KB)

 

PDF Creator Pilot can be used with different languages to generate PDF files. See "Hello, PDF" example for:

See also:

 

If you have questions related to PDF Creator Pilot, contact us via our online support form.

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