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

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

720

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

Community Expert , Aug 15, 2019 Aug 15, 2019

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

Votes

Translate

Translate
Community Expert ,
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.

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 ,
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().

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

Copy link to clipboard

Copied

I'm old-school...

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 ,
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.

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

Copy link to clipboard

Copied

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

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 ,
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.

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