Copy link to clipboard
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:
from win32com.client.dynamic import Dispatch, ERRORS_BAD_CONTEXT
(my_dir, my_pdf) = os.path.split(path)
(filename, extension) = os.path.splitext(my_pdf)
src = os.path.abspath(my_pdf)
app = win32com.client.Dispatch("AcroExch.App")
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:
app = None
pdDoc = None
AvDoc = None
jsObject = None
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.