Step 1: Check us out

You don't have to be a member to look at any content on the site. Increase your expertise with our helpful tutorials, videos, forums, and sample PDFs.

Step 2: Sign up for a free account

Like what you see? Take the next step and become a member. Register now to get discounts, attend eSeminars, ask questions and more.

Step 3: Start participating

Get the most out of your membership. Post in the forums, create your profile, submit to the gallery, attend a user group meeting. Log In now.

Acrobat User Community Forums

You are not logged in.     Log in to your AUC account.     Don't have an account? Sign up today

#1 2010-02-09 11:42:58

koenigma
Member
Registered: 2008-01-23
Posts: 21

Save As based on Field Data

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?


Offline

 

#2 2010-02-09 12:54:58

thomp
Expert

Registered: 2006-02-16
Posts: 2746

Re: Save As based on Field Data

ACCEPTED ANSWER

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
pdfscripting.com

The Acrobat JavaScript Reference,  Use it Early and Often
http://www.adobe.com/devnet/acrobat/javascript.html

Then most important JavaScript Development tool in Acrobat
The Console Window (Video tutorial)
The Console Window(article)

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson