[python-win32] How to print a PDF file?

Cox Chen coxchen at nature.ee.ncku.edu.tw
Tue Aug 12 22:16:23 EDT 2003


I found a solution to my problem.
Though it's tedious and not so transparent, it is acceptable now. :-(


>>> from win32com.client import Dispatch
>>> ie = Dispatch('InternetExplorer.Application')
>>> ie.Visible = 1
>>> ie.Navigate2('c:\\dscV1.pdf')
>>> pdfViewer = ie.Document.embeds[0]
>>> pdfViewer.Print()

If the Acrobat Reader is installed correctly, when using IE navigating
to target PDF file, an embeded object, instance of Acrobat Control for
ActiveX, is instantiated to display that PDF file.

ie.Document.embeds returns a set of COMObjects embeded in a HTML Document.
Here, the first (only) embeding COMObject is the instance of Acrobat Control for ActiveX.
Check http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnie40/html/msdn_lassesen.asp
for further information about HTML Document.

I'm curious that is it possible to create a blank window and embed into an
COMObject, just as Acrobat Control for ActiveX is embedded in Internet Explorer ?

-Cox Chen




More information about the Python-win32 mailing list