Persistent data

New Here ,
Aug 15, 2019 Aug 15, 2019

Copy link to clipboard

Copied

I have an array of objects that need to be persistent.  I have read that saving complex data can't be done as is but can be saved if in a string format.  Any help in this area will be greatly appreciated.  Also is there a special location to make this data persistent ie: global.setPersistent()?

TOPICS
Acrobat SDK and JavaScript

Views

128

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

correct answers 1 Correct Answer

Adobe Community Professional , Aug 15, 2019 Aug 15, 2019
With Acrobat DC, you can use JSON.stringify() and JSON.parse() instead of toSource() and eval().

Likes

Translate

Translate
Adobe Community Professional ,
Aug 15, 2019 Aug 15, 2019

Copy link to clipboard

Copied

Yes, global.setPersistent(cVariable, bPersist). For example:

global.myText = "abc";

global.setPersistent("myText", true);

As for the array, that's true. You can only set string objects as persistent. You can use the toSource method to convert any object to a string, though, and then eval to convert it back to an object.

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 Community Professional ,
Aug 15, 2019 Aug 15, 2019

Copy link to clipboard

Copied

With Acrobat DC, you can use JSON.stringify() and JSON.parse() instead of toSource() and eval().

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 Community Professional ,
Aug 15, 2019 Aug 15, 2019

Copy link to clipboard

Copied

I'm old-school...

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 Community Professional ,
Aug 15, 2019 Aug 15, 2019

Copy link to clipboard

Copied

I store my complex data as strings... of JSON... which allows me to use a single string to store all kinds of stuff.

Also, there is a global object but with the default security settings, only the document that set the value can retrieve the value.

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
New Here ,
Aug 16, 2019 Aug 16, 2019

Copy link to clipboard

Copied

Thanks!!  Where does the persistent data get saved (shitdows)?

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 Community Professional ,
Aug 16, 2019 Aug 16, 2019

Copy link to clipboard

Copied

LATEST

I use a folder level JavaScript and a PDF to save my persistent data into a form field in that PDF. It's stored as a JSON string that I parse into an object. The PDF gets opened as a hidden file and is disclosed so all other PDFs can get access to the object. It's stored in the same folder as the JavaScript.

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