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

Global script on document save?

phorest
Registered: Feb 26 2008
Posts: 13
Answered

Hello, This is a javascript/workflow question.

Is it possible to create a global script that will fill the metadata properties automagically?
We are a paperless office and work with tens of thousands of documents. I successfully wrote and deployed a batch program to set all the metadata properties for all of our legacy documents on our file server.

Now that the legacy documents are taken care of, how can we continue the metadata properties with all new documents in an easy fashion?

We follow strict naming conventions for all of our files. (e.g. [Lastname, Firstname 00-BBB DescriptionOfDocument 022608])
We really want to be able to either... 1.) Fill in the document metatdata and have a global script to automagically name the file on save -or- ... 2.) Fill the metadata properties from the filename on save.
Option #2 seems to be the best and easiest in a workflow sense because the userbase already intuitively name the documents.

ANY help or ideas would be appreciated.

Thanks!

My Product Information:
Acrobat Standard 7.0.9, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You can execute the same code you wrote for the batch process from a folder level automation script.

Take a look at : http://www.windjack.com/products/acrobuttons.php

and these articles:

General Folder level Scripts:
http://www.acrobatusers.com/tech_corners/javascript_corner/tips/2006/folder_level_scripts/

For creating a toolbar button:
http://www.acrobatusers.com/tutorials/2007/10/apply_security_with_js/

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

phorest
Registered: Feb 26 2008
Posts: 13
Hello,

Yes I am following auto_insert_metadata tutorial but nothing happens.
The button is created but on pressing it the metadata does not change.
phorest
Registered: Feb 26 2008
Posts: 13
I get this error. I am using the tutorial script below the error codes.

ReferenceError: his is not defined
8:Folder-Level:User:AutoMetadata.js
ReferenceError: his is not defined
8:Folder-Level:User:AutoMetadata.js

V-V-V-V-V-V-V-V-V-

var SetMetaData = app.trustedFunction(function()
{
app.beginPriv();
this.info.author = identity.name;
this.info.copyright = "Copyright \xA9"
+ this.modDate.getFullYear()
+ " by "+ identity.corporation;
his.info.subject = "JavaScript";
this.saveAs(this.path);
app.endPriv();
});

app.addToolButton({
cName: "applyMetaData",
cLabel: "MetaData",
cEnable: "event.rc = (app.doc != null);",
cExec: "SetMetaData();"});
phorest
Registered: Feb 26 2008
Posts: 13
I suppose/now know that means line8 is missing a 't'...
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Your line 8 reads:

his.info.subject = "JavaScript";

and it should read:

this.info.subject = "JavaScript";


The magic decoder ring is not always accurate with the line count but it is usually close.

For those interested the error message also discloses that the error is in the file "AutoMetadata.js"
in the user's JavaScript folder, not the application's ("app") JavaScript folder.

George Kaiser

phorest
Registered: Feb 26 2008
Posts: 13
Thanks