How to Create or Edit PDF with Python


PDF Creator Pilot:       Home       Download       Features       Tutorials       FAQ       Pricing       News

 

Once 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 to create and edit PDF documents.

You need to import the win32com.client library to be able to work with COM.

 

Example: Creating and Editing PDF with Python

import sys
import win32com.client
 
PDF = win32com.client.Dispatch("PDFCreatorPilot.PDFDocument4")
PDF.SetLicenseData("demo", "demo")
PDF.Compression = 1
 
## you may open an existing PDF, provide password if needed
PDF.Open("first.pdf", "")
 
## you may change document properties
oldTitle = PDF.UnicodeTitle
print "Old title is '" + oldTitle + "'"
PDF.UnicodeTitle = u"-=[ my new title ]=-"
 
## you may add a new page
PDF.NewPage()
fnt = PDF.AddBuiltInFont(1, 0, 0)
PDF.UseFont(fnt, 14)
PDF.ShowTextAt(30, 30, "This page came from Python.")
 
## you may append an existing PDF, provide password if needed
PDF.Append("second.pdf", "")
 
## save and open it in default PDF viewer
PDF.SaveToFile("test.pdf", 1)

 


PDF Creator Pilot:       Home       Download       Features       Tutorials       FAQ       Pricing       News