Controlling Acrobat Reader with COM

andres at corrada.com andres at corrada.com
Wed Jun 28 11:06:19 EDT 2000


On Tue, Jun 27, 2000 at 12:07:08PM -0400,  wrote:
> On Mon, 26 Jun 2000 21:59:51 -0400, "Andres Corrada-Emmanuel"
> <andres at mail.mamey.com> wrote:
> 
> >Hi,
> >
> >I'm trying to develop an application that will print (as in a paper copy) a PDF file automatically on Win32. I've used Mark Hammond's genpy utility to create a wrapper around "Acrobat Control for ActiveX". I'm able to get a handle on Acrobat but cannot execute any of its registered methods:
> >
> >>>> from win32com.client import Dispatch
> >>>> acro = Dispatch('PDF.PdfCtrl.1')
> >>>> acro.LoadFile(fileName='C:\Temp\ReadMe.pdf')
> >Traceback (innermost last):
> >  File "<interactive input>", line 1, in ?
> >  File "C:\Program Files\Python\win32com\gen_py\CA8A9783-280D-11CF-A24D-444553540000x0x1x3.py", line 30, in LoadFile
> >    return self._oleobj_.InvokeTypes(0x2, LCID, 1, (11, 0), ((8, 0),),fileName)
> >com_error: (-2147418113, 'Unexpected failure', None, None)
> >
> >I'm very much a COM newbie, so this traceback means very little to me. Could someone enlighten me on what is going wrong in this case? I have no problem controlling Word with my setup so I'm stumped on this one.
> >
> >Andres Corrada
> Try typing these strings directly into the interpreter.
> 
> >>> print 'c:\test\readme.pdf'
> c:	est
> eadme.pdf
> >>> print "c:\test\readme.pdf"
> c:	est
> eadme.pdf
> >>> print 'c:\\test\\readme.pdf'
> c:\test\readme.pdf
> >>> print 'c:/test/readme.pdf'
> c:/test/readme.pdf
> -- 

Thanks for pointing out that I was not escaping the backslashes. The error,
however will not go away when I use

acro.LoadFile(fileName='C:\\Temp\\ReadMe.pdf')

I've noticed that (I'm using PythonWin) when I get to the first parenthesis
on LoadFile, the editor offers the hint:

fileName=<PyOLEMissing object at 108c1010>

Does that have anything to do with the subsequent error?

------------------------------------------------------
Andres Corrada-Emmanuel   Email: andres at corrada.com
------------------------------------------------------




More information about the Python-list mailing list