PDF version of this article is available.
Click here to download.
How to generate PDF in ASP: "Hello, PDF!" example
Step by Step
This page contains a step-by-step tutorial that will teach you how to create PDF files from ASP page using PDF Creator Pilot library.
Please note that to be able to use the full version of PDF Creator Pilot library on Web-server, you need to have an additional Web License for every Web-server that is used.
PDF Creator Pilot can generate in-memory PDF file so it does not need to be stored as a file and can be streamed right into the browser window.
The library has a special "GenerateInMemoryFile" flag for such purposes. You can set this flag to TRUE and the library will generate and keep your PDF file only in the memory. You can get PDF as a string or as a BinaryImage.
1) Install PDF Creator Pilot library on your computer and create an "HelloPDF.asp" file in the Notepad.
2) To create a PDF file from ASP, you have to implement a code that will do the following things:
- create and initialize PDF Creator Pilot object;
- set GenerateInMemoryFile to TRUE;
- draw "Hello, PDF!" message on the PDF document;
- copy PDF document as a BinaryImage using Response ASP object and its BinaryWrite command;
- disconnect from the library.
Content of "HelloPDF.asp" file:
<%
' create pdf library object
Set PDF = CreateObject("PDFCreatorPilot3.PDFDocument3")
' initialize PDF Engine
PDF.StartEngine "demo@demo", "demo"
' set GenerateInMemoryFile flag to TRUE so keep PDF only in the memory
PDF.GenerateInMemoryFile = TRUE
' 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
' get generated PDF as binary image
PdfImage = PDF.BinaryImage
' clear the output stream
response.Clear
' set the content type to PDF
response.ContentType = "application/pdf"
' add content type header
response.AddHeader "Content-Type", "application/pdf"
' set the content disposition
response.AddHeader "Content-Disposition", "inline;filename=form.pdf" |
Feel free to copy this code to the Notepad and save it as "HelloPDF.ASP":
3) Copy HelloPDF.ASP to the server root folder. If you use IIS, then it is located in the "c:\inetpub\wwwroot\" folder by default.
4) Now you can launch HelloPDF.asp page from your browser and your users will see the generated PDF in the browser as it shown on the screenshot below:

You can download the source code for the described example here (0.6 Kb)
PDF Creator Pilot can be used with different languages to generate PDF files. See "Hello, PDF" example for:
- Visual Basic Script (VBScript)
- Visual Basic (VB)
- Visual Basic.NET (VB.NET)
- C Sharp (C#)
- Active Server Pages (ASP)
- Active Server Pages for .NET (ASP.NET)
- Delphi
- Visual C++
See also:
- PDF documents and PDF files. Introduction and short description
- PDF Creator Pilot technology
- PDF Creator Pilot FAQ
If you have questions related to PDF Creator Pilot, contact us via our online support form.