PDF Creator Pilot documentation |
Download CHM version of this manual. |
|
![]() ![]() Collapse AllOnce you have installed PDF Creator Pilot to you system it is available for use from Python. This sample demonstrates how to use PDF Creator Pilot with Python running under IIS web server. You may use any web server and any library to handle writing in output stream. Different libraries may provide different ways for writing data to response. You need to import 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")
Then you need to set 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 you may save it to disk: PDF.SaveToFile("test.pdf", 0)
or send it directly to user 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