Skip to main content
Jan 3, 2020 9:25 PM UTC
Answered

JavaScript code disappearing

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 is closed to new replies. Start a new post to keep the conversation going.
try67
try67Correct answer
Community Expert
Jan 3, 2020 10:48 PM UTC

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

7 replies

Legend
Jan 6, 2020 3:52 PM UTC

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.

Translate
danielc99152335
Inspiring
Jan 3, 2020 11:54 PM UTC

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.

Translate
try67
Community Expert
Community Expert
Jan 4, 2020 9:29 AM UTC

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.

Translate
try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
Jan 3, 2020 10:48 PM UTC

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

Translate
Jan 6, 2020 1:34 PM UTC

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

Translate
Legend
Jan 3, 2020 10:02 PM UTC

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

Translate
Jan 6, 2020 1:33 PM UTC

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?

Translate