[python-win32] How to launch acrobat with data

Roger Upole rwupole at msn.com
Thu Sep 21 02:49:37 CEST 2006


Andrew Diederich wrote:
> Hello python-win32,
> 
> I'm storing some Adobe forms (application/vnd.fdf) in a database.
> Using ADODBAPI I've been able to pull the data out.  Does anyone know
> how I can launch Adobe Acrobat with the data?
> 
> Here's how I get the data:
>>>> import adodbapi
> 
>>>> conn = adodbapi.connect('Driver={SQL Server};Data
> Source=dbServer,1433;Initial Catalog=theDatabase;User
> ID=theUser;Password=thePassword;')
> 
>>>> curs=conn.corsor()
> 
>>>> curs.execute('''select documentID, BLOBcol from mytable where documentID=5;''')
> 
>>>> answer=curs.fetchall()
> 
> And answer is:
>>>> answer
> ((u'5', <read-write buffer ptr 0x00AF51C8, size 5132 at 0x00AF51A8>),)
> 
> I can get just the FDF data, of course.
> 
>>>> print answer[0][1]
> %+++-1.2
> /FDF << /Fields [ << /T (All_Activity_ActivityID)/V /Off >> << /T (All_
> <snip more FDF data>
> 
> Does anyone know how to launch Acrobat with data?  I'm very behind the
> power curve on windows programming, so I'm not really even sure how to
> search through windows to discover how to Dispatch correctly.  I
> searched the registry for applicatoin/vnd.fdf, and found HKCR\.fdf,
> which had AcroExch.FDFDoc, and PDFs look to be AcroExch.Document, but
> how I would use, say, win32com.client.Dispatch to launch Acrobat with
> some data (or even launch Acrobat)?
> 
> Thanks for the help.
> 
> -- 
> Best regards,
> Andrew Diederich

You could write the data out to a file and use os.startfile
to launch acrobat.  If you need to actually control Acrobat
as a COM object, it has to be embedded in a container.
Using IE as a container is fairly easy, you just Navigate to
a PDF document:
import win32com.client
ie=win32com.client.Dispatch('internetexplorer.application')
ie.Visible=1
ie.Navigate('somedocument.pdf')

        Roger



More information about the Python-win32 mailing list