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()?
With Acrobat DC, you can use JSON.stringify() and JSON.parse() instead of toSource() and eval().
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.
Copy link to clipboard
Copied
With Acrobat DC, you can use JSON.stringify() and JSON.parse() instead of toSource() and eval().
Copy link to clipboard
Copied
I'm old-school...
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.
Copy link to clipboard
Copied
Thanks!! Where does the persistent data get saved (shitdows)?
Copy link to clipboard
Copied
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.