[javascript] Limit on size of global object?  SOLVED

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: Daniel - PDF-XChange, PDF-XChange Support, Vasyl - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Paul - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

Mathew
User
Posts: 567
Joined: Thu Jun 19, 2014 7:30 pm

[javascript] Limit on size of global object?

Post by Mathew »

Looking at the js API for global object methods there's a vague note under setPersistent() "For Acrobat 6.0 or later, there is a 2-4 KB limit on the size of this file. Any data added to the string after this limit is dropped."

Is this enforced in PDF-XChange or is there some other limit?

On my computer GlobData is already over 2k, and I'm wondering if I can use it to store some data for javascript tools that would definitely put it over 4k (without clobbering data from other tools) - or is there another way to store data for javascript that can be accessed between documents? There's util.readFileInterStream() but I don't see any equivalent writeStreamIntoFile()...
Last edited by Mathew on Wed Jun 12, 2024 11:33 pm, edited 2 times in total.
User avatar
Roman - Tracker Supp
Site Admin
Posts: 332
Joined: Sun Nov 21, 2004 3:19 pm

Re: [javascript] Limit on size of global object?  SOLVED

Post by Roman - Tracker Supp »

Hi Mathew,
The Editor does not explicitly limit GlobData file size but limits the number of persistent properties by 65536.
As of an alternative to persistent global properties, you can consider Doc.createDataObject, Doc.exportDataObject, Doc.importDataObject and related API.
Mathew
User
Posts: 567
Joined: Thu Jun 19, 2014 7:30 pm

Re: [javascript] Limit on size of global object?

Post by Mathew »

Roman - Tracker Supp wrote: Wed Jun 12, 2024 10:48 pm As of an alternative to persistent global properties, you can consider Doc.createDataObject, Doc.exportDataObject, Doc.importDataObject and related API.
Thank you Roman. I'll do some noodling with those, but it's good to know that there's no arbitrary limit on the persistent global properties themselves.

The doc.exportDataObject() function looks like it's been made to not work for a script's storage. Seems I'm bumping up against a very intentional effort to not allow scripts to write to a user's hard drive:
Beginning with Acrobat 6.0, if the parameter cDIPath is non-null, a NotAllowedError (see Error object) exception is thrown and the method fails.
I'm thinking one could use use an empty pdf for storage as app.openDoc(), doc.saveAs() allows writing to a safe path; maybe that's my route.

Thanks again.
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 11009
Joined: Wed Jan 03, 2018 6:52 pm

Re: [javascript] Limit on size of global object?

Post by Daniel - PDF-XChange »

Hello, Mathew

I hope one of those options works out for your needs. If you have further questions, just let us know :)

Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com