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

JavaScript code disappearing

Guest
Jan 03, 2020 Jan 03, 2020

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!

TOPICS
Acrobat SDK and JavaScript
1.8K
Translate
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 , Jan 03, 2020 Jan 03, 2020

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

Translate
LEGEND ,
Jan 03, 2020 Jan 03, 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...?

Translate
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
Guest
Jan 06, 2020 Jan 06, 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?

Translate
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 ,
Jan 03, 2020 Jan 03, 2020

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

Translate
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
Guest
Jan 06, 2020 Jan 06, 2020

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

Translate
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 Beginner ,
Jan 03, 2020 Jan 03, 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.

Translate
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 ,
Jan 04, 2020 Jan 04, 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.

Translate
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
LEGEND ,
Jan 06, 2020 Jan 06, 2020
LATEST

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