Skip to main content
January 3, 2020
Answered

JavaScript code disappearing

  • January 3, 2020
  • 4 replies
  • 1992 views

This seems like it must be a super basic issue, but I wrote some JavaScript code for a pdf using the "Edit All JavaScripts" butoon, but whenever I click "OK" to save/close out the code/script editor, it all clears out and all I am left with is the

 

//------

//----Do not edit the XML tags

//---------

 

code.

 

So basically nothing I do is getting saved, whether or not my code is any good.

 

Any idea what I am doing wrong? Thanks!

This topic has been closed for replies.
Correct answer try67

Despite its name, do NOT use this command to edit the code in your file. It can seriously damage it.

4 replies

Legend
January 6, 2020

Code in PDF forms and Acrobat likely goes to five different places, each edited separately (and I probably forgot some).

 

1. Event related code (like, when I click this button run this code). This must be edited with the form editor for the form element.

2. Document level scripts. Use the document level script editor.

3. Batch actions. Edit in the batch action editor.

4. Acrobat startup scripts not connected to any document. Add to startup folder.

5. Immediate scripts, to run right now. Use the JavaScript console. This isn't an editor, so edit externally, and paste to run.

danielc99152335
Inspiring
January 3, 2020

I would recomend saving any js script you wish to use as a folder level script by saving its .js file in: \AppData\Roaming\Adobe\Acrobat\Privileged\2017\JavaScripts.

 

You can then test and run it by using the acrobat JS console or better yet, using an action wizard to call your JS code.

try67
Community Expert
Community Expert
January 4, 2020

For testing purposes it's easier to do it all from the Console, not from a folder-level script as you will need to restart the application after each update to the script if you do the latter, which can get pretty annoying.

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
January 3, 2020

Despite its name, do NOT use this command to edit the code in your file. It can seriously damage it.

January 6, 2020

Gotcha, so where is the best place to edit the code?

Legend
January 3, 2020

What else did you put there? Basically this is a handy way of viewing all your existing scripts. Not a place to type it all in - how would it know where to put it...?

January 6, 2020

I have all of my code on a notepad file and have been trying to copy and paste it into "edit all JavaScripts". That has worked for me previously but I guess not this time.

So where is the best place to type in the script?