PDF Creator Pilot documentation |
Download CHM version of this manual. |
|
![]() ![]() Collapse AllOnce you have installed PDF Creator Pilot on your system it is available for use from Python. This sample demonstrates how to use PDF Creator Pilot with Python running under an IIS Web server. You may use any Web server and any library to handle writing to an output stream. Different libraries may provide different ways for writing out data. You need to import the win32com.client library to be able to work with COM. Then create a new COM object: import sys
import win32com.client
PDF = win32com.client.Dispatch("PDFCreatorPilot.PDFDocument3")
Set the license data and adjust other properties: PDF.StartEngine("demo", "demo")
PDF.Compression = 1 # coFlate = 1
PDF.GenerateInMemoryFile = 1
Fill your document with some data: PDF.BeginDoc()
# draw a message on the current PDF page
PDF.PDFPAGE_SetActiveFont("Verdana", 0, 0, 0, 0, 14, 0)
PDF.PDFPAGE_TextOut(10, 20, 0, "HELLO, from Python!")
PDF.EndDoc()
Then save it to disk, PDF.SaveToFile("test.pdf", 0)
or send it directly to an output stream: size = PDF.GetBufferSize()
data = PDF.GetBuffer()
Response.Clear()
Response.ContentType = "application/pdf"
Response.AddHeader("Content-Type", "application/pdf")
Response.AddHeader("Content-Disposition", "attachment;filename=test.pdf")
Response.AddHeader("Content-Length", size)
Response.BinaryWrite(data)
Response.End()
|



Example