Skip to main content
Raw_Lychee
Participant
January 19, 2019
Question

App.Exit() returns false when using AcroExch. The memories that Acrobat takes continues to raise and then it will stop running because the Acrobat cannot afford.

  • January 19, 2019
  • 1 reply
  • 1695 views

It's really an important problem for me, I've been bothered for two days, and I've read the API reference of Acrobat as well as all the relating discussions in this forum.

I'll be very grateful if someone could help me.

Here is the problem:

I am trying to deal with almost 3000 PDFs, using AcroExch to automatically save them as txt in Python 3.6.

The code works, but the memories that Acrobat takes continues to raise while running, and then it will stop when the Acrobat cannot afford such big memories.

The Acrobat will tell me that something wrong when opening this document, because too much documents are opened, I need to close some.

I've already used PDDoc.close(), AVDoc.close(1), APP.CloseAllDocs(), app.Hide() and app.Exit()

But it doesn't works, the first four methods returns "True" while the app.Exit() returns "False" all the time.

Here is my code:

import os

import win32com

import winerror

from win32com.client.dynamic import Dispatch, ERRORS_BAD_CONTEXT

def txt(path):

    ERRORS_BAD_CONTEXT.append(winerror.E_NOTIMPL)

    (my_dir, my_pdf) = os.path.split(path)

    (filename, extension) = os.path.splitext(my_pdf)

    os.chdir(my_dir)

    src = os.path.abspath(my_pdf)

    try:

        app = win32com.client.Dispatch("AcroExch.App")

        #app.show()

        AvDoc = win32com.client.Dispatch("AcroExch.AVDoc")

        if AvDoc.Open(src, ""):

            pdDoc = AvDoc.GetPDDoc()

            jsObject = pdDoc.GetJSObject()

            jsObject.saveAs(os.path.join(my_dir, filename+".txt"), "com.adobe.acrobat.plain-text")

    except Exception as e:

        print(str(e))

    finally:

        print(pdDoc.Close())

        print(AvDoc.Close(1))

        print(app.CloseAllDocs())

        print(app.Hide())

        print(app.Exit())

        app = None

        pdDoc = None

        AvDoc = None

        jsObject = None

This topic has been closed for replies.

1 reply

lrosenth
Adobe Employee
Adobe Employee
January 20, 2019

Two things…

1 – you don’t mention what version of Acrobat is being used. Are you sure you are on the current version of DC?

2 – Are you trying to do this on a server? Acrobat is not licensed for server usage.