Skip to main content
Participant
August 30, 2006
Question

Print File Name with pdf Document

  • August 30, 2006
  • 93 replies
  • 245470 views
In order to have an audit trail / track a document, I want to print the file name as a header or footer when printing the documents. How can this be done?
This topic has been closed for replies.

93 replies

Participant
July 24, 2007
This is great!

Works with Acrobat 8.0

those having trouble, make sure to save the .js file to the appropriate \program files\adobe\acrobat "X"\javascript folder.

Questions:

A. I am a novice at javascripting. what changes to the script need to be made to move this from footer to header?

B. How to I make it so that this script is available to the Batch Processing in Acrobat?

thanks in advance
ReinhardF
Participating Frequently
April 18, 2007
I work with WinXP and furtheron with Acrobat v5. From the answer from @P.Allan I can see that it should work also with higher Acrobat versions.

Perhaps someone else can confirm that ist works / works not with vista and with which Acrobat Version.

Good luck, Reinhard
Participant
April 17, 2007
tried taking out app.addMeuitem and i'm still getting the same thing

i'm using adobe 7.0

thanks a lot for your help though
ReinhardF
Participating Frequently
April 17, 2007
"Is this because I have Vista? any advice?"

I don't know. Which Acrobat version?
You may test the pure script (without app.addMeuitem) in the JS-Console.

best regards, Reinhard
Participant
April 16, 2007
Participant
April 16, 2007
I got the "Set/Remove Footer" thing to show up above print setup under the file drop-down, but when I click on any of the options it says, "an internal error occurred"

Is this because I have Vista? any advice?

thanks for your help
ReinhardF
Participating Frequently
March 16, 2007
Add:
fr.value = "My Text";

to:
fr.textSize=6; fr.alignment="right";

e.g
fr.textSize=6; fr.alignment="right"; fr.value = "My Text";

HTH, Reinhard
Participant
March 15, 2007
Reinhard,

Thank you so much for your help. I just have one question. You have the code written above so that you may type the footnote or message on the bottom of the page in acrobat. I would like to put the text or message in the JavaScript. That way when you SETBOTH, it adds everything to the bottom and that's it. So my question is, how do I put that information in the code? and secondly where? Thanks again for your help.
ReinhardF
Participating Frequently
March 14, 2007
@bjames

A quick solution.
Under: "if (ARG==3){ fd.alignment="right" };"
Insert:
var fr = this.addField("xftRem", "text", p, [30+TotWidth/2,15, TotWidth-30,30]);

fr.textSize=6;fr.alignment="right";


If you choose "Set Both" an extra field will be added to the right side of every page. This you can edit on one page for every page.

If you want to remove it via Menuitem, then
Under: "if (ARG<=3 || ARG==9) {var x = this.removeField("xftDate");}"
Insert:
if (ARG<=3 || ARG==9) {var x = this.removeField("xftRem");}

HTH, Reinhard
Participant
April 21, 2010

This solution works for me too, filename and text on the right.

I'd like to shorten the text box from 1/2 page width to only 10-20 characters so the display is not cluttered. Can someone tell me how to reduce the size of the text box?

Here is the code that has been taken from these posts and modified for my personal use (filename and text ONLY for those of you that want to bypass modifying it on your own):

app.addSubMenu({ cName: "Footer",cUser: "Custom Footer", cParent: "File", nPos: 20 });

app.addMenuItem({ cName: "Set", cParent: "Footer", cExec: "SetFooter(9)"});

app.addMenuItem({ cName: "-------------------------------", cParent: "Footer",cExec: "{}"});

app.addMenuItem({ cName: "Remove", cParent: "Footer", cExec: "RemoveFooter(9)"});

//Set/remove Footer
function SetFooter(ARG)
{
var re = /.*\/|\.pdf$/ig;
var FileNM = this.path.replace(re,"")+".pdf";
var Path = this.path;
var AcDate = new Date();
var AcDateFormat = "dd-mmm-yyyy"
var Box2Width = 15
for (var p = 0; p < this.numPages; p++)
{
var aRect = this.getPageBox("Crop",p);
var TotWidth = aRect[2] - aRect[0]
if (ARG==9)
{ var fd = this.addField("xftDate", "text", p, [30,15, TotWidth-30-30,30]);
fd.value = " " + Path +" ";
fd.textSize=6; fd.readonly = true;
if (ARG==1){ fd.alignment="left" };
if (ARG==2){ fd.alignment="center" };
if (ARG==3){ fd.alignment="right" };
var fr = this.addField("xftRem", "text", p, [30+TotWidth/2,15, TotWidth-30,30]);

fr.textSize=6; fr.alignment="right"; fr.value = "Confidential"; 
}
if (ARG==9)
{ var bStart=(TotWidth/2)-(Box2Width/2)
var bEnd=((TotWidth/2)+(Box2Width/2))
if (ARG==5){var bStart=(TotWidth-Box2Width-30); var bEnd=(TotWidth-10);}
var fp = this.addField(String("xftPage"+p+1), "text", p, [bStart,30,bEnd,15]);
fp.value = "";
fp.textSize=6; fp.readonly = true;
fp.alignment="center";
}
}
}

function RemoveFooter(ARG)
{
if (ARG==9) {var x = this.removeField("xftDate");}
if (ARG==9)
{ for (var p = 0; p < this.numPages; p++)
{var x = this.removeField(String("xftPage"+p+1)); }
if (ARG<=3 || ARG==9) {var x = this.removeField("xftRem");}
}
}

August 30, 2010

Great Topic

Using Adobe Pro9.0

I batch process the footer area of my PFD's but then after production I require a scrip that would:

Header Right

Produce the original print/ creation date and then update it with the print date others of whom may access the file (format 18AUG2010 or 18-AUG-2010)

AND

Also, I was hoping to capture the whom "the ID (author) of the person of whom had printed the record"

Sample Output

Tom Brady 18AUG2010

AND

Header Left

"Reference Only Copy"

Some of the code above appears to be applicable but I am not in a position to decipher a solution without guidance

Assistance is greatly appreciated

Lastly, does PDF security prevent the java?

Well Wishes

D

ReinhardF
Participating Frequently
March 14, 2007
@esma
You should open your own topic. It's a total different technic (watermarks or ..)

@allan
"Am I missing something?"
No. I use AAv5. "documentFilename" was introduced in later versions. Also the regular expression I used I took only because I just worked with that and was to lazy to look for "stringMid, stringInStr ..." in a JS-handbook.

Best regards, Reinhard