How create PDF files with the PDF library
in questions and answers
- Do you have step-by-step tutorials for Visual Basic, ASP, Delphi or Visual C ?
- What are the system and software requirements for the PDF library?
- Does the library need Adobe Reader or any other software to produce PDF documents?
- What are the limitations of the demo version?
- What is the proper way to install PDFCreatorPilot.DLL on the user computer?
- How can I incorporate images into the PDF document?
- How do I create a new page in the document?
- How can I change the paper size of the generated PDF document?
- How can I generate PDF document "on-the-fly" directly in user's browser window?
- Can I use the PDF library with ASP.NET?
- Can I draw or print to a PDF?
- Is there support for windows metafiles (EMF)?
- How can I decrease the size of the produced PDF document?
- Why did I get an error message when I tried to add an image to a PDF from ASP?
- How can I create an editable text field in the PDF document?
- How can I draw "wrapped" text?
- How can I draw a rectangle measured in millimeters (mm)?
- I entered some text using .PDFPage_TextOut. How can I change the text alignment?
- If there is a way to create bookmarks in the PDF?
- Do you have documentation for javascript in PDF forms?
- Can I use PDF Creator Pilot from C++ Builder?
-
Do you have step-by-step tutorials for Visual Basic, ASP, Delphi or Visual C ?
Yes, we do. Please check "Hello, PDF!" step-by-step samples for Visual Basic, Delphi, Visual C++, Visual Basic Script (VBScript), and Active Server Pages (ASP)
-
What are the system and software requirements for the PDF library?
Windows 2000/XP/2003/Vista. No 3rd-party software is required.
-
Does the library need Adobe Reader or any other software to produce PDF documents?
No additional software is required.
-
What are the limitations of the demo version?
The demo version places notification messages inside the generated pdf documents.
-
What is the proper way to install PDFCreatorPilot.DLL on a user's computer?
Place PDFCreatorPilot.DLL in the {%system%} directory and use the regsvr32.exe system utility to register PDFCreatorPilot.DLL. You can also use PDFCreatorPilot3.msi installer package from Redistributable folder.
-
How can I incorporate images into the PDF document?
Set PDF = CreateObject("PDFCreatorPilot.PDFDocument3")
PDF.StartEngine "demo@demo","demo"
PDF.AutoLaunch = false
PDF.DocumentInfo_CreationDate = NowPDF.FileName = "TestImage.pdf"
PDF.DocumentInfo_Title = "PDF Creator Pilot Demo"PDF.BeginDoc
J = PDF.AddImageFromFile("image.bmp")
PDF.PDFPAGE_Width = 310
PDF.PDFPAGE_Height = 310PDF.PDFPAGE_ShowImage J,5,5,224,183,0
PDF.EndDoc
-
How do I create a new page in the document?
Use the .NewPage function.
-
How can I change the paper size of the generated PDF document?
Use the .PaperSize property
-
How can I generate a PDF document "on-the-fly" directly in user's browser window?
The technique is quite simple:
1. Create a PDF Creator Pilot object and initialize it:
Set PDF = CreateObject("PDFCreatorPilot.PDFDocument3")
PDF.StartEngine "demo@demo","demo"2. Set the .GenerateInMemoryFile flag to TRUE. The library will keep
the generated pdf document in memory.3. Activate the .BeginDoc command to start document generation.
4. To generate a PDF document using provided drawing API, use JPG, BMP, EMF, etc., images.
5. Activate the .EndDoc command to finalize document generation.
6. Use the "response" ASP object to stream the document to the
browser directly, or write the data into the output "response" object. A byte
array is required. Use the .BinaryImage property of PDF Creator Pilot to get the generated
PDF document as a byte array.7. Use the following code:
PdfImage = PDF.BinaryImage
response.Clear
response.ContentType = "application/pdf"
response.AddHeader "Content-Type", "application/pdf"
response.AddHeader "Content-Disposition", "inline;filename=form.pdf"
response.BinaryWrite PdfImage
response.EndAs a result, the user will see your PDF document in the browser window.
You can find an example for ASP that will generate a simple PDF document and output it via browser: http://www.colorpilot.com/pdfsample_asp.html
-
Can I use the PDF library with ASP.NET?
Yes, you can use PDF Creator Pilot in ASP.NET as a normal ActiveX library.
Click here to view an example for ASP.NET.
If you have worked with ASP before, then keep in mind that there are some differences in ASP and ASP.NET language syntax.
Take a look at the following resources about migrating from ASP to ASP.NET:
http://www.aspalliance.com/anjum/ASPMigration.aspx
http://samples.gotdotnet.com/quickstart/aspplus/doc/migrationoverview.aspx -
Can I draw or print to a PDF?
Use the .hDC property of the library and draw on this HDC as with the printer or screen HDC.
-
Is there support for windows metafiles (EMF)?
Yes, use the .PDFPAGE_PlayMetaFileFromFileName method. Your metafile will be imported retaining its vector nature.
-
How can I decrease the size of the generated PDF document?
Check the .Compression to change PDF compression ratio.
-
Why did I get an error message when I tried to add an image to a PDF from ASP?
Try to use the Server.MapPath function, for example:
K = PDF.AddImageFromFileName (Server.MapPath("logo.jpg"), 1)
-
How can I create an editable text field in the PDF document?
Use the .PDFANNOTATION_ methods and properties to create interactive fields, comboboxes, and listboxes:
' create PDF Creator Pilot object
Set PDF = CreateObject("PDFCreatorPilot.PDFDocument3")
' start pdf engine
PDF.StartEngine "demo@demo","demo"
' set document creation date
PDF.DocumentInfo_CreationDate = Now
' set output filename
PDF.Filename = "sampleform.pdf"
' set document title
PDF.DocumentInfo_Title = "Form Demo"
' set option to automatically open pdf document in Adobe Reader if available
PDF.AutoLaunch = true
' set document compression to flate to reduce pdf file size
PDF.COmpression = 1 ' 1 = ctFlate' start document generation
PDF.BeginDoc' create edit control
PDF.PDFPAGE_CreateControl_Edit "samplefield1", 20, 30, 200, 45
' set default text
PDF.PDFANNOTATION_Text = "simple edit with centered text"
' set font color
PDF.PDFANNOTATION_Font_Color = 0
' set font style to bold
PDF.PDFANNOTATION_Font_Style_fsBold = true
' set font size to 12
PDF.PDFANNOTATION_Font_Size = 12
' set justification to center
PDF.PDFANNOTATION_Justification = 1 ' center alignment' create text field
PDF.PDFPAGE_CreateControl_Edit "samplefield2", 20, 50, 120, 70
' set default text
PDF.PDFANNOTATION_Text = "pass"
' limit max characters number that can be inputed to 4
PDF.PDFANNOTATION_MaxLength = 4
' set "password" show mode to hide characters
PDF.PDFANNOTATION_IsPassword = true
' set font size to 10
PDF.PDFANNOTATION_Font_Size = 10
' set text justification to left
PDF.PDFANNOTATION_Justification = 0 ' left alignment
PDF.PDFANNOTATION_Hint_Caption = "This is the hint for edit"' create text field
PDF.PDFPAGE_CreateControl_Edit "samplefield3", 20, 75, 150, 110
' set default text
PDF.PDFANNOTATION_Text = "multiline edit"
' set multiline mode for text field
PDF.PDFANNOTATION_Multiline = 113
' set font color
PDF.PDFANNOTATION_Font_Color = 113
' set font style to italic and bold
PDF.PDFANNOTATION_Font_Style_fsItalic = true
PDF.PDFANNOTATION_Font_Style_fsBold = true
' set font size to 10
PDF.PDFANNOTATION_Font_Size = 10
' set text justification to right alignment
PDF.PDFANNOTATION_Justification = 2' create text field
PDF.PDFPAGE_CreateControl_Edit "samplefield4", 20, 115, 200, 150
' set default text
PDF.PDFANNOTATION_Text = "simple edit with white border"
' set font size
PDF.PDFANNOTATION_Font_Size = 12
' set border color to white
PDF.PDFANNOTATION_BorderColor = 16777215
' set justification to left
PDF.PDFANNOTATION_Justification = 0 ' left alignment' end document
PDF.EndDoc -
How can I draw "wrapped" text?
Use the .PDFPAGE_TextOutBox command to draw wrapped text.
-
How can I draw a rectangle measured in millimeters (mm)?
You can change the .Resolution property of PDF Creator Pilot. The default resolution is 72 DPI (72 dots per inch). This is how you can calculate the size of your objects using resolution.
-
I entered some text using .PDFPage_TextOut. How can I change the text alignment?
Use the .PDFPAGE_TextBox instead of the .PDFPage_TextOut method.
-
If there is a way to create bookmarks in the PDF?
Take a look at the .PDFOUTLINES_ commands. Look at the "demo.vbs" example in the /examples/other/ folder of PDF Creator Pilot.
-
Do you have documentation for JavaScript in PDF forms?
Adobe Technical Note #5186, "Acrobat Forms JavaScript Object
Specification", gives details on the contents and effects of JavaScript
scripts. -
Can I use PDF Creator Pilot from C++ Builder?
Yes, you can use the PDF library in C++ Builder mostly the same way as in Delphi.Click here to view an example for Delphi.