[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
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
Medium Priority
?
4,089 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ability to edit PDF documents can be useful, however it may not be a straight forward process. Many non-technical people don't realise that a PDF document is basically an image rather than a text file, even if it contains nothing but text. If…
Inserting page numbers in Portable Document Files not only enhances manageability but also makes them look professional. With numbered pages, the file appears more organized and it becomes easier to search for a particular page. The size and the vol…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
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 …
Suggested Courses

650 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