Solved

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

Posted on 2006-06-15
15
3,407 Views
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.
0
Comment
Question by:d-smith
  • 8
  • 7
15 Comments
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 16914895
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?
0
 
LVL 1

Author Comment

by:d-smith
ID: 16915710
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.

0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 16916451
Is this supposed to save a file to drive K:? If so, you need to start the path with a slash: "/K/Managed Care/..."
0
 
LVL 1

Author Comment

by:d-smith
ID: 16919652
Yes to the K drive. I added the slash and i'm still getting the same error
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 16920755
Is the save function a button on the form, or a menu item in Acrobat?
0
 
LVL 1

Author Comment

by:d-smith
ID: 16921136
button on the top right of the form
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 16921661
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.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 1

Author Comment

by:d-smith
ID: 16921803
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?
0
 
LVL 1

Author Comment

by:d-smith
ID: 16921837
I should also add, I've never done any menu additions like this.
0
 
LVL 44

Accepted Solution

by:
Karl Heinz Kremer earned 400 total points
ID: 16922540
OK, here is a script that will work. Save this program in Acrobat's JavaScript directory (for Acrobat 7 this is C:\Program Files\Adobe\Acrobat 7.0\Acrobat\Javascripts) as a file with the extension .js (e.g. SaveAsProc.js):


// get the values for LNAME, FNAME and NUMBER from the file
var LNAME = this.getField("LNAME").value;
var FNAME = this.getField("FNAME").value;
var NUMBER = this.getField("NUMBER").value;

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


// create a new menu item:

app.addMenuItem({
     cName: "Save Document to Server",
     cParent: "Document",
     cExec: "SaveAsProc();",
     cEnable: "event.rc = (event.target != null);",
     nPos: 0
});

// end of script

You may have to change the path, and you may have to come up with a way to extract the values for your variables from the active document.
This script will add a new menu item to the "Document" menu.

0
 
LVL 1

Author Comment

by:d-smith
ID: 16922913
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.
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 16922929
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.
0
 
LVL 1

Author Comment

by:d-smith
ID: 16923030
Ah ok that worked better that was my fault, but now i'm getting this error.

TypeError: this.getField is not a function
0
 
LVL 1

Author Comment

by:d-smith
ID: 16923646
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:

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

// end of script
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 16924817
Sorry about that. That was my fault.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In a previous article published here at Experts Exchange, Signature Image with Transparent Background (http://www.experts-exchange.com/Web_Development/Document_Imaging/A_12380-Signature-Image-with-Transparent-Background.html), I explained how to cre…
This article focuses on how to remove password security from multiple PDF files by Adobe Acrobat program. Sometimes it is essential to access the stored data items and to print, edit as well as copy content from Portable Document Format files in abs…
In this video, we show how to perform Bates Numbering/Stamping of PDF documents using Power PDF Advanced, the newest product from the Document Imaging division of Nuance Communications. There are two editions of Power PDF — Standard and Advanced. Th…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now