Thanks a lot Justin. I tried running your code, for some
reason it just hangs. I wonder why.
----- Original Message ----
From: Justin Ezequiel <justin.mailinglists gmail.com>
To: python-win32 python.org
Sent: Sunday, September 24, 2006 9:52:18 PM
Subject: Re: [python-win32] AVDoc and PDDoc
> From: Michael S <msherman77 yahoo.com>
>
> 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 = r"C:\test\file1.doc"
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
|