1

I have a PDF file which sets the values of several fields on loading based on a form the user fills out on a webpage. I need to set these fields with different data values each time the PDF is opened. I'd prefer to do this with something like localStorage but I'm not sure how to access localStorage from the PDF JavaScript (or if that's even possible). The fields may be quite long—I'm avoiding sending the data in the URL as a query string (e.g. ...doc.pdf?title=Doc), which may exceed browser URL character limits.

Is there a way to access localStorage or another local browser data storage system using PDF JavaScript? If not, is there a better way I can go about this?

I'm using Acrobat 15 to add JavaScript to my PDF. I will only need to open the resulting PDF in a browser. However, cross-browser solutions are preferred.

Community
  • 1
  • 1
intcreator
  • 4,206
  • 4
  • 21
  • 39
  • look here http://stackoverflow.com/questions/26124025/open-pdf-from-html5-storage – MastaBot Jul 05 '16 at 17:35
  • @MastaBot that question has to do with storing and loading entire PDFs. I have one PDF with JavaScript inside it. I need the JavaScript to read data (just text) from some form of the user's local storage and fill out its own PDF fields with that text data. – intcreator Jul 05 '16 at 17:39

1 Answers1

0

If these users are internal to your organization and you can direct them to make some settings changes to their copy of Acrobat or Reader, you can use the Acrobat JavaScript global object to store data that will be persistent across Acrobat sessions. You'll need to disable the global object security policy.

enter image description here

After restarting Acrobat, all documents will have access to the global object. You can set key value pairs using some simple JavaScript...

global.firstName = "Joel";  // Declare firstName to be global
global.setPersistent("firstName", true);

Then later, you can set a field value to the stored global value like this...

this.getField("First Name").value = global.firstName;
joelgeraci
  • 4,606
  • 1
  • 12
  • 19