[python-win32] COM, Acrobat and JavaScript

Mark Hammond mhammond@skippinet.com.au
Wed, 6 Mar 2002 09:51:14 +1100


The other alternative is to modify win32com\client\dynamic.py.  Near the top
of the file, find the list ERRORS_BAD_CONTEXT.  Try adding
winerror.E_NOTIMPL to this list and see if it solves the problem.

Mark.

> -----Original Message-----
> From: Joshua Reynolds [mailto:joshuar@isogen.com]
> Sent: Wednesday, 6 March 2002 2:43 AM
> To: Mark Hammond
> Cc: python-win32@python.org
> Subject: Re: [python-win32] COM, Acrobat and JavaScript
>
>
> I've already tried that and it doesn't seem to get me anything.  I run
> makepy and it generates the file, but when I print out the objects I get
> they are still <COMObject AcroExch.App> or <COMObject <unknown>>.
>
> In the Acrobat documentation they say they don't define any interface
> for the JSObject, just use IDispatch.  I don't know if this helps, but
> the only difference I can tell between the JSObject and any of their
> other interfaces etc. is that the JSOBject return type from the
> getJSOBject call is defined as LDispatch* (is this a typo and supposed
> to say LPDispatch*) whereas all of the other com objects are returned as
> types LPDispatch (no *).  I am kind of blissfully ignorant of the magic
> that is going on in the python com mapping.
>
> Oh yeah, I am running Python 2.2 with the build 146.
>
> Any other suggestions?
>
> Thanks a million,
>
> Joshua
>
> Mark Hammond wrote:
> > Try running makepy over the Acrobat type library.  Look for
> documentation on
> > makepy in the COM readme.
> >
> > Mark,
> >
> >
> >>-----Original Message-----
> >>From: python-win32-admin@python.org
> >>[mailto:python-win32-admin@python.org]On Behalf Of Joshua Reynolds
> >>Sent: Tuesday, 5 March 2002 8:01 AM
> >>To: python-win32
> >>Subject: [python-win32] COM, Acrobat and JavaScript
> >>
> >>
> >>
> >>
> >>Problem:
> >>
> >>The functionality that I need to use from Acrobat is on a javascript
> >>object (returned type defined in the Automation interface as an
> >>LDispatch*).  I haven't had any problems using any of their other OLE
> >>components through python, but when I try to use the root javascript
> >>object -- or any other javascript objects accessed through it.
> >>
> >>I can get at all of the attributes on the javascript objects, but if I
> >>try to call a method on it, it fails.
> >>
> >>Here is the full calling sequence that brings me to failure
> >>
> >> >>> from win32com.client import Dispatch
> >> >>> app = Dispatch("AcroExch.App")
> >> >>> app
> >><COMObject AcroExch.App>
> >> >>> pddoc = Dispatch("AcroExch.PDdoc")
> >> >>> pddoc.Open("d:\\tmp\\cn_final.pdf")
> >>1
> >> >>> jso = pddoc.getJsobject
> >> >>> jso
> >><COMObject <unknown>>
> >> >>> jso.app.formsVersion
> >>5.0
> >> >>> jso.console.Show
> >>Traceback (most recent call last):
> >>   File "<interactive input>", line 1, in ?
> >>   File
> >>"D:\programs\Python2.2\lib\site-packages\win32com\client\dynamic.py",
> >>line 432, in __getattr__
> >>     raise pythoncom.com_error, details
> >>com_error: (-2147467263, 'Not implemented', None, None)
> >>
> >>in the above, app.formsVersion is an attribute, and console.Show  is a
> >>parameterless method.
> >>
> >>Here are some potentially useful snippets from the Acrobat docs on using
> >>the JSObject in Visual Basic.
> >>
> >>
> >>
> >>6. JSObject always returns values as Variants. This includes property
> >>gets as well as
> >>return values from method calls. An empty Variant is used when a null
> >>return value
> >>is expected. When JSObject returns an array, each element in the array
> >>is a
> >>Variant. To determine the actual data type of a Variant, use the utility
> >>functions
> >>IsArray, IsNumeric, IsEmpty, IsObject, and VarType from the Information
> >>module of the VBA library.
> >>7. JSObject can process most elemental Visual Basic types for property
> >>puts and
> >>input parameters to method calls, including Variant, Array, Boolean,
> >>String, Date,
> >>Double, Long, Integer, and Byte. JSObject can accept Object parameters,
> >>but only
> >>when the Object was the result of a property get or method call to a
> >>JSObject.
> >>JSObject fails to accept values of type Error and Currency.
> >>
> >>I have verified that I can access the methods on JSObject as well as
> >>subObjects, but I would really really like to be able to use this stuff
> >>through python.
> >>
> >>Any ideas on how i can get access to any of those methods?
> >>
> >>
> >>
> >>Thanks,
> >>Joshua
> >>
> >>
> >>
> >>--
> >>Joshua Reynolds | Consultant
> >>
> >>Isogen International
> >>Office: 512-302-9879
> >>Main:   512-380-0347
> >>Cell:   512-743-3865
> >>1016 La Posada Suite 240
> >>Austin, TX 78752
> >>
> >>
> >>_______________________________________________
> >>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
> >
> >
> >
>
>
> --
> Joshua Reynolds | Consultant
>
> Isogen International
> Office: 512-302-9879
> Main:   512-380-0347
> Cell:   512-743-3865
> 1016 La Posada Suite 240
> Austin, TX 78752
>