Hello All,
I wrote this nifty java code using Acrobat Pro 6 awhile back, which if executed using 'Batch Processing' prompts the user for the files to process, then 1) adds a tag and 2) a scrap of Java code to each selected document which in turn updates the tag on document open, inserting a string equal to filename up to the first space as the tag contents.
So once the documents have been processed initially, the filename can be changed and any Acrobat version (even Reader) which calls up the document updates the tag with the current filename string.
It works pretty slick, except now we've updated office-wide to Acrobat 8 Standard (my Acrobat 6 Pro officially 'went away' -- don't worry, I still have a copy cached away), but going forward I'd really like ANY user to be able to ADD THE TAGS in the first place, using Acrobat 8 Standard.
The code below, as-is, if placed in an Acrobat 8 Standard document and linked to the 'Document Did Save' event, adds the desired tag to the current document. Wundervoll! We're on to something...
Could this code be enclosed in a loop, with perhaps a dialog box confirmation, so that when triggered by the 'Document Did Save' event it processed all the pdf files in the host document's current directory? Not as nice as prompting for the files, but for our purposes this would answer adequately.
Our IT Dept. is not going to spring for 100 copies of Acrobat Pro, and while two or three copies for key people to do the initial processing is a potential answer, it would be MUCH better if the code could be embedded in template file and executed by anyone using Acrobat 8 Standard.
Or perhaps an external JavaSript console could be configured for the purpose? Hmm, sounds like a possibility, but Java isn't really what I do for a living...I could probably fumble through it, if someone could give me an outline of what needs to be done.
In summary, how can this code best be run cheaply?
Thanks in Advance,
Brandon Nichols
/* Add Tag */
function AddTag()
{
//Remove any existing field named TAG if exist
if (this.getField("TAG") != null)
{
this.removeField("TAG");
}
// //Remove all fields (could be damaging -- saved here for ref)
// for(var i = this.numFields - 1; i > -1; i--)
// {
// //Get the field name for field i
// var fieldName = this.getNthFieldName(i);
//
// //Now delete this field from doc
// this.removeField(fieldName);
// }
var pp = this.path.replace(/.*\/|\.pdf$/ig, "");
pp = pp.match(/^([A-Za-z0-9\-\,\_\[\]])+(([A-Za-z0-9\-\,\_\[\]])+)*/, "");
for (var p=0; p
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script