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

AcroExch crash after populating too many fields

New Here ,
Jul 01, 2021 Jul 01, 2021

Copy link to clipboard

Copied

I'm trying to populate a few thousands of PDF forms with around 100 fields per file. In Python it looks like this:

 
def createPDF(data) :

    import winerror
    from win32com.client.dynamic import DispatchERRORS_BAD_CONTEXT
    ERRORS_BAD_CONTEXT.append(winerror.E_NOTIMPL)

    template  = 'C:\\template.pdf'
 
    for row in data:
        app = Dispatch('AcroExch.App')
        pdfDoc = Dispatch('AcroExch.PDDoc')
        pdfDoc.Open(template)

        jso = pdfDoc.GetJSObject()
        jso.getField('field1').Value = row[0]
        #...
        jso.getField('field100').Value = row[99]
 
        pdfDoc.Save (33,  row[0] +  '.pdf')

        pdfDoc.close()
        app.CloseAllDocs
        app.exit
 
This is some very simplified version of the code. I know it can be faster with opening and closing 'AcroExch.App' outside the loop, safer with using try... but for this example it really does not matter.
 
It works quite good for small batches as it populates around 200 files per minute. Unfortunately with every additional file it starts to slowing down until crash with error like this:
AttributeError: Property '<unknown>.Value' can not be set
so in some moment it cannot populate anymore fields.
 
When it is running I see in task manager that Acrobat is using more and more memory, but those are some small values: it starts from 50MB, goes to arund 900MB and crashes when there is still a few GB of free memory. It really looks like Acrobat is leaving some trash that is slowing and crashing it down. 
 
In "Interapplication Communication withthe Acrobat SDK" I see that AcroExch.AVDoc.close function after closing file is allowing to reuse it ("To reuse an AVDoc object, close it with AVDoc.Close, then use the AVDoc object’s LPDISPATCH for AVDoc.OpenInWindow"), but in the descrition of other functions that I am using: AcroExch.PDDoc.close and AcroExch.App.CloseAllDocs there is noting about leaving something to reuse. 
 
 
I have this problem in Windows 10 Enerprise with using current Acrobat DC Pro (32-bit) version. I was testing also some other acrobat versions and even running AcroExch.App from VBA, but results were the same.
 
At the moment I have one workaround for this. On error and after some N created files(based on number of fields in a form) it is:
  • closing Acrobat with AcroExch.App.exit
  • wait around 15 or 20 seconds before opening it once again

This additional time allows system to close Acrobat app and clear all garbages from memory, but waiting 20 second every few minutes is not too efficient.

Do you maybe know some other way how it can be resolved? Something like forcing Actobat to clear cache without closing it or maybe just using some different functions to populate forms?

TOPICS
Acrobat SDK and JavaScript , Windows

Views

673

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
LEGEND ,
Jul 01, 2021 Jul 01, 2021

Copy link to clipboard

Copied

Acrobat is an interactive tool with tools for very low volume automation. Never mind 200 per minute, 200 is too many. Restart Acrobat at least every 100 files and check results carefully. 

Votes

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
Community Expert ,
Jul 06, 2021 Jul 06, 2021

Copy link to clipboard

Copied

HI ,

 

Everything said above, and you probably want to put something in place to make sure that Acrobat has actually exited fully before you start again.

Votes

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
New Here ,
Jul 06, 2021 Jul 06, 2021

Copy link to clipboard

Copied

Hi,

 

Sorry, but for me it is just a set of bugs in SDK and not something to deal with it.

 

First of all: any software should not leave trash in a memory after closing files. If from some reasons you have to leave references to closed files, then you should give user at least option to force some garbage collector or clear cache.

 

Second: if user is asking to close application it should be closed without keeping it hidden in a background to "open" it once again with all garbages from previous run.

 

SDK does not have any problems with populating files to fast, it is just crashing after populating too many fields. To be clear this "too many" fields is something that average laptp is able to populate literally in a less thatn 5 minutes. It really looks like software bug and not something that user shoud be worry about. We are talking here about paid comercial software that should not be crashing by defaulf after 5 minutes of using it.

Votes

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
LEGEND ,
Jul 06, 2021 Jul 06, 2021

Copy link to clipboard

Copied

Of course it's a set of bugs. Some of them have been there for 20 years, others are newer. We have spent years working around them. It's no use telling us it should be better. You could try reporting it to Adobe, but my suggestion is to look for a tool more suitable. Or complain to Adobe, not your fellow sufferers. 

Votes

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
New Here ,
Jul 06, 2021 Jul 06, 2021

Copy link to clipboard

Copied

LATEST

Ok, I will try to report it as bugs(leaving trash in a memory and not closing app), but from this what I already see probably it will be much easier just to find some other software. Fortunately I was only checking benefits from moving users from nitro pro to acrobat pro. Idea was to add them not only edit PDF options, but also a few extra tools based on SDK (simple python scripts to run on their computers), but if it is crashing by default I will look for something more stable and not server based. 

Votes

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
Community Expert ,
Jul 06, 2021 Jul 06, 2021

Copy link to clipboard

Copied

You are using Acrobat as an automation server. Not only is this against the license agreement, it's not suitable for the task (as you've already discovered).  You should be using a PDF Library or form filling tool. Both Appligent and Active PDF make tools specifically for this purpose. And there are many others.

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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
New Here ,
Jul 06, 2021 Jul 06, 2021

Copy link to clipboard

Copied

Right... if I'm using one thread in a laptop to convert small excel file to PDFs during cofee break(less than 10 minutes) this is "automation server". xD Just please don't go with such idea to the microsoft as then they can move "mail merge" option from word to windows server. Are you really thinking that using some SDK for more than 5 minutes requires moving it to the server? Or maybe not leaving trash in a memory should require additional license? 

Votes

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