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

Script for Batch Process of Document Labels

mjmontario
Registered: Dec 16 2010
Posts: 1

Ok, so I have a problem with a java script for an adobe acrobat batch process.
 
The script takes the file name (example file name: D01MA001401_01.01_0500_p.pdf) and puts it in a text box in the bottom right corner of the document. However, it doesn't always use the same font, font size or font color, it depends on the version of adobe you're using. Acrobat 7 is the only one that uses this script correctly as it was written for that version. Acrobat 9 must require a significantly different script as it puts in red, 12 point text.
 
Also, I think the end result also depends on what version of adobe last opened the document. I just processed a batch with version 7 that were last opened with version 9, the script used Arial in the text box. It's very annoying.
 
The code is below, any ideas on how I can fix it? According to our QC it has to use Times New Roman, black, font size 9.
 
I would like the code to work with all versions of Acrobat but I'm not sure if that's possible. I am using version 7.1.0 pro.
  
/* Add code and filename */
var fnprep = this.documentFileName;
var fnlen = fnprep.length - 4;
var fnchpos = fnprep.length - 5;
var fnchar = fnprep.substring(fnchpos, fnlen);
console.println(fnchar);
var filename =" ";
filename += "200-1";
if (fnchar == "a") { filename += "e"} else{filename += "f"};
filename += "\n";
filename += fnprep.substring(0,fnlen);
 
var aRect = this.getPageBox( {nPage: 0} );
aRect[0] = aRect[2]-144;
aRect[1] = aRect[3]+36;
aRect[2] -= 18;
aRect[3] += 10;
var f = this.addAnnot ({
page: 0,
type: "FreeText",
rect: aRect,
textFont: "TimesNewRoman",
strokeColor: color.black,
fillColor: color.white,
textSize: 9,
contents: filename,
width: 0
});

My Product Information:
Acrobat Pro 7.0, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2398
I would suggest using font.Times instead of "TimesNewRoman" for textFont.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

DaveyB
Registered: Dec 10 2010
Posts: 70
Have you considered embedding the font into the PDF file? This would prevent font substitution based on user preferences or Acrobat versions on the client machine.

LiveCycle Designer 8.0
"Genius is one percent inspiration, ninety-nine percent perspiration." ~~ Thomas Edison
"If at first you don't succeed, get a bigger hammer." ~~ Alan Lewis
"If the conventional doesn't work, try the unconventional" ~~ DaveyB