These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Save As based on Field Data

koenigma
Registered: Jan 23 2008
Posts: 45
Answered

I have red through all the post concerning this and to be honest I am not much smarter than when I started.

I have tried to use the example posted by radzmar which I modifed as shown below but nothing happens:

I've placed the following in the directory:
C:\Adobe\Acrobat\8.0\JavaScripts

1. The folder level JS SaveAs.js

// Defining a trusted function
var mySaveDoc = app.trustedFunction(function(doc)
{
// Check current doc name
var aDocumentFileName = this.documentFileName;

// If-Statement for ensuring, that the save fuction is only done if PDF has exactly this name
if (aDocumentFileName == "Registration Form.pdf")
{
app.beginPriv();

// Save under Users documents
var myPath = app.getPath("user", "documents") + "/" + "Registration Form" + " - " + Part1 + " - " Part2 + " - " + Part3 + " - " + ".pdf";

doc.saveAs(myPath);
app.endPriv();
}
});

2. Added JS to the click event of a button:

//Defining variable(s) used for new filename
var Part1 = resolveNode("ReportForms.#pageSet[0].Att1.#area[0].txtCompanyname").rawValue;
var Part2 = resolveNode("ReportForms.#pageSet[0].Att1.#area[0].txtCompanyID").rawValue;
var Part3 = resolveNode("ReportForms.#pageSet[0].qrr_P1.#area[0].ReportDate").rawValue;
event.target.mySaveDoc(event.target);

Can anyone tell me what I am doing wrong?

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You've got a couple of issues. First, "mySaveDoc()", because it is in a Folder Level Script, is a globally defined function. Call it directly like this:

mySaveDoc(event.target);

Next, the Part1, Part2, and Part3 variables are defined locally in the button script. They are not availible to the function. You'll need to pass these parameters as function arguments.

When the code was run it should have reported an error in the Console window. See the material on the console window in the links below.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script