• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

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.

New Here ,
Jan 19, 2019 Jan 19, 2019

Copy link to clipboard

Copied

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

TOPICS
Acrobat SDK and JavaScript

Views

856

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Jan 20, 2019 Jan 20, 2019

Copy link to clipboard

Copied

LATEST

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines