You are right. I made a mistake, it forces early binding.
However neither late nor early can discover the AcroExch.AVdoc method I need and VB does it with no problem.

By the way I can force early or late binding on the Excel.Application, but for some reason not on Acrobat classes.

----- Original Message ----
From: Simon Dahlbacka <[EMAIL PROTECTED]>
To: Michael S <[EMAIL PROTECTED]>
Cc: Justin Ezequiel <[EMAIL PROTECTED]>; python-win32@python.org
Sent: Monday, September 25, 2006 10:56:13 AM
Subject: Re: [python-win32] AVDoc and PDDoc/How to force late binding

EnsureModule forces *early* binding

 
On 9/25/06, Michael S <[EMAIL PROTECTED]> wrote:
I am trying to force late binding, since obviously early binding does not discover the methods that I am trying to call.
I ran the makepy -i from within PythonWin, to get those two lines I need to paste in into my script.
from win32com.client import gencache
gencache.EnsureModule .......

However when I run the script, I get an com_error saying that dynamic.py couldn't find a certain method?
I thought that EnsureModule should force late binding.



----- Original Message ----
From: Michael S <[EMAIL PROTECTED] >
To: Justin Ezequiel <[EMAIL PROTECTED]>; python-win32@python.org
Sent: Sunday, September 24, 2006 10:44:57 PM
Subject: Re: [python-win32] AVDoc and PDDoc

Thanks a lot Justin. I tried running your code, for some reason it just hangs. I wonder why.

----- Original Message ----
From: Justin Ezequiel < [EMAIL PROTECTED]>
To: python-win32@python.org
Sent: Sunday, September 24, 2006 9:52:18 PM
Subject: Re: [python-win32] AVDoc and PDDoc


> From: Michael S < [EMAIL PROTECTED]>
>
> I am trying to write a short Python script to create
> some PDFs.
> I create instances of App, AVDoc and PDDoc using the
> following syntax:
> app = Dispatch("AcroExch.App")
> doc = Dispatch("AcroExch.AVDoc")
> pd = Dispatch("AcroExch.PDDoc")
>
> However when I call pd = doc.GetPDDoc(), the Python
> interpreter
> complains about the member function not being found. I
> know for sure
> that it is there, since I can execute the code in VB
> no problem.
>

was experimenting with Acrobat months ago

import win32com.client.dynamic

NOSAVE = -1
PDSAVEFULL = 1

class Acrobat2pdfError(RuntimeError): pass

def Acrobat2pdf(src, dst):
   avdoc = win32com.client.dynamic.Dispatch("AcroExch.AVDoc ")

   if not avdoc.Open(src, "doc2pdf"):
       raise Acrobat2pdfError("unable to open %s" % src)

   pddoc = avdoc.GetPDDoc()

   if not pddoc.Save(PDSAVEFULL, dst):
       raise Acrobat2pdfError("unable to save %s" % dst)

   if not pddoc.Close():
       raise Acrobat2pdfError("unable to close %s" % dst)

   del pddoc

   if not avdoc.Close(NOSAVE):
       raise Acrobat2pdfError("unable to close %s" % src)

   del avdoc

if __name__ == '__main__':
   import os
   src = "">   dst = r"C:\test\file2.pdf"
   Acrobat2pdf(src, dst)
   assert os.path.isfile(dst)
_______________________________________________
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32
_______________________________________________
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32



_______________________________________________
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


_______________________________________________
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to