We help IT Professionals succeed at work.

Adobe Acrobat Form- Create a Javascript "Save As" Button to save with a name in a shared drive.

d-smith asked
Last Modified: 2013-12-03
Hey experts,

I'm having trouble with my fillable PDF Form. Our enviroment is Windows XP, Office XP, Adobe Acrobate 5, and 2003 server. What i'm trying to do is have a form out on a shared drive (K:\Managed Care\Referral Request Form) so users can fill it out and then automatically save in (K:\Managed Care\Referral Request Form\Incoming Forms), with a name pulling from the "LNAME", "FNAME", and "NUMBER" fields, and then clear the form when they push the button. It would make the process go by faster for them because they do a lot a day. That way they can refer back to that form too if they need to print it again, email, etc.

So far, i've tried different code on my own, from EE, Google, etc and still can't get it correctly. I've tried app, functions, and doc objects but i keep getting this error.
                                             uncaught exception:Field SAVE:Mouse Up:1: Global.saveAs
                                             Security settings prevent access to this property or method.

If someone could help me out with the proper coding, I would appreciate it.
Watch Question


Do you have the AcroJS document from Adobe? If you lookup the Doc.saveAs method, you'll notice that there are security notes in the description: "This method can only be executed during batch, console or menu events. ... Beginning with Acrobat 7.0, execution of JavaScript through a menu event is no longer privileged, ..." and "The parameter cPath is required to have a Safe Path and an extension appropriate to the value of cConvID...."

From your short description, it's not obvious into which security violation your code runs, but the error message is very specifc.

How are you calling saveAs? What are the parameters? Are you using only Acrobat 5?


Yes I do have the AcroJS documentation. I wasn't sure how much that security note would limit my goal to do this, so I figured I would post my dilemna up here to find a way to make this work any way.

this.saveAs("K/Managed Care/Referral Request Form/" + LNAME + FNAME + NUMBER ".pdf");

And Yes majority of Acrobat 5, but I think there might be some with 6. No 7 though.


Is this supposed to save a file to drive K:? If so, you need to start the path with a slash: "/K/Managed Care/..."


Yes to the K drive. I added the slash and i'm still getting the same error

Is the save function a button on the form, or a menu item in Acrobat?


button on the top right of the form

That's the problem. If you look back to my first comment, you'll notice that the saveAs() function can only be executed during a menu, batch or console event. A button event is not permitted to perform a Save As.

You need to install a JavaScript program that gets executed at Acrobat startup time, and that installs either a menu item that your user's will use, or a JavaScript function that your document can call.


Ah ok i see the difference now. I thought as long as you were doing a menu action such as saving, you were within a menu event.  Is there anywhere you can point me to the right direction for that or how I can get that done?


I should also add, I've never done any menu additions like this.
This one is on us!
(Get your first solution completely free - no credit card required)


I loaded up the SaveAsProc.js into the Javascript folder. I didn't have to change the path or anything too, but I got this error when I opened up the form. Any ideas?

                                ReferenceError: ÿþ is not defined

I got this error when I opened up Acrobat with different pdf's.

Did you create the JS file as a text file? What tool did you use? It looks like there is some binary data in the file, which should not be the case. Try it again with NotePad.


Ah ok that worked better that was my fault, but now i'm getting this error.

TypeError: this.getField is not a function


My fault again. Variables weren't in the function. I also changed the cpath a little bit. Here is the script I put to use and tested it out. It works the way I want it too perfectly. Thanks khkremer. I appreciate the help.  

// get the values for LNAME, FNAME and NUMBER from the file

function SaveAsProc()

var LNAME = this.getField("LNAME").value;
var FNAME = this.getField("FNAME").value;
var NUMBER = this.getField("NUMBER").value;

    this.saveAs("/K/Managed Care/Referral Request Form/Incoming Forms/pati"+ LNAME + FNAME + NUMBER +".pdf");

// create a new menu item:

     cName: "Save to Server",
     cParent: "File",
     cExec: "SaveAsProc();",
     cEnable: "event.rc = (event.target != null);",
     nPos: 7

// end of script

Sorry about that. That was my fault.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.