• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
1

Print File Name with pdf Document

New Here ,
Aug 30, 2006 Aug 30, 2006

Copy link to clipboard

Copied

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?
TOPICS
Print and prepress

Views

233.6K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
replies 161 Replies 161
Engaged ,
Dec 01, 2011 Dec 01, 2011

Copy link to clipboard

Copied

@Arne

simple delete or comment out (like as follow) these lines:

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

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

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

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

The statement cName:"..xxx.." is only the menu item display name. So you change it for rest to whatever you want-

Good luck, Reinhard 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 01, 2011 Dec 01, 2011

Copy link to clipboard

Copied

@Reinhard

Thank you very much for your useful script and your helpful replies to users questions here.  This will streamline my workflow 100x

I've taken the script in AA X and modified page position to fit specific documents.

As a quick guide to help others, initially I didn't have a good grasp on the placement syntax and would like to share with others here what I "figured out".

[10,30,545,40]

10 = Places the start of the text box 10 pixels from the left most edge (x1 coordinate) of the document

30 = Places the bottom of the text box 30 pixels from the bottom (y1 in your post) edge of the document

545 = Places the end of the text box 545 pixels from the left most edge (x2 coordinate) of the document (ie. 535 pixel wide text box, starting 10 pixels from left most edge)

40= Places the top of the text box 40 pixels from the bottom edge (y2 in your post) of the document (ie. 10 pixel high text box)

Is this logic correct?

Also, I plan to share this with other collegues in my office, I would like to put the following header in the script, with your permission.  If you would like me to add any other credit text, please post it or send via PM

//Original script written by ReinhardF, Nov 13, 2006

//For specific questions, visit http://forums.adobe.com/thread/302996?tstart=0

Thanks again!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 02, 2011 Dec 02, 2011

Copy link to clipboard

Copied

Is there a way to rotate the text 90 degrees?

I have documents that have text at the top most and bottom most part of the page, but an inch of whitespace on the right hand side.

What I'm hoping to do is have text run along the right-hand side and when the page is in a 3-ring binder, the text is running LR reading order starting in the lower right corner, running up to the top right side of the page.

Thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 02, 2011 Dec 02, 2011

Copy link to clipboard

Copied

Hi,

"Is this logic correct?" -> Yes it is.

"Also, I plan to share" -> No problem.

"Is there a way to rotate the text 90 degrees?" No problem : fd.rotation=90

     found at; AcroJs.pdf Field object -> Field property =>rotation

"have text run along the right-hand side " Not realy a porblem, you need: var TotHeight = aRect[1] - aRect[3];

      found at; AcroJs.pdf Doc object ->  Doc methods  = > getPageBox

With that you have all information to set it als header, in the middle or wherever you want.

Good luck, Reinhard

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 07, 2011 Dec 07, 2011

Copy link to clipboard

Copied

Hi ReinhardF!

I have tried to modify the script to meet my needs, that is ONLY the filepath to be shown on the first page only, no need for page number or date.

My script looks like this:

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

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

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

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

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

function SetFooter(ARG)

{

var re = /.*\ / | \ .pdf$/ig;

var Path = this.path;

var Box2Width = 50

for (var p = 0; p < 1; p++)

  {

    var aRect = this.getPageBox("Crop", p);

    var TotWidth = aRect[2] - aRect[0]

    if (ARG<=3 | | 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.alignement="left"  };

           if (ARG==2){ fd.alignement="center"  };

           if (ARG==3){ fd.alignement="right"  };

     }

   if  (ARG==4 | |  Arg==5  | | ARG==9)

    {  var bStart=(TotWidth/2)-(Box2Width/2)

         var bEnd=((TotWidth/2+8Box2Width/2))

         if (ARG==5){var bStart=8TotWidth-Box2Width-30); var bEnd=(TotWidth-30);}

         var fp = this.addField(String("xftPage"+p+1),  "text" , p, [bStart, 30, bEnd, 15]);

    }

  }

}

Function RemoveFooter(ARG)

{

if  (ARG<=3 | | ARG===9)  {var x = this.removeField("xftDate");}

}

Is ther anything more I can remove from this script, and still make it to work for the file path only?

Just to reduse the script to a minimum.

Thanks from Arne!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 07, 2011 Dec 07, 2011

Copy link to clipboard

Copied

"Is ther anything more I can remove from this script"

Sure, take this:

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

app.addMenuItem({cName: "Left", cParent: "Footer", cExec: "SetFooter(1)"});
app.addMenuItem({cName: "Center", cParent: "Footer", cExec: "SetFooter(2)"});
app.addMenuItem({cName: "Right", cParent: "Footer" , cExec: "SetFooter(3)"});
app.addMenuItem({cName: "Remove", cParent: "Footer", cExec: "this.removeField('xftDate');"});

function SetFooter(ARG)
{
var Path = this.path;
var Box2Width = 50;
var page = 0;
var aRect = this.getPageBox("Crop", page);
var TotWidth = aRect[2] - aRect[0];

var fd = this.addField("xftDate",  "text" , page, [30, 15,  TotWidth-30-30, 30]);
fd.value = Path;
fd.textSize = 6;
fd.readonly = true;
if (ARG==1){fd.alignement="left"};
if (ARG==2){fd.alignement="center"};
if (ARG==3){fd.alignement="right"};
}

best regards, Reinhard

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 08, 2011 Dec 08, 2011

Copy link to clipboard

Copied

Thanks ReinhardF!!!

This is more than perfect!

By the way, do you know why this does not work with Reader?

Best regards from Arne.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 08, 2011 Dec 08, 2011

Copy link to clipboard

Copied

Reader don't can add fields - only fill existing.

Only with Reader you can use a freeware tool like BeCyPdfAsm (http://www.becyhome.de/news_eng.htm) to set a footer.

best regards, Reinhard

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 08, 2011 Dec 08, 2011

Copy link to clipboard

Copied

Reader can add fields, if the right to do so has been applied to the file

in Acrobat.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 08, 2011 Dec 08, 2011

Copy link to clipboard

Copied

Hi try67!

How do you do this?

Regards

Arne

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 08, 2011 Dec 08, 2011

Copy link to clipboard

Copied

In Acrobat? Depends on your version. In Acrobat X it's under File - Save As

- Reader Extended PDF - Enable Additional Features...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 08, 2011 Dec 08, 2011

Copy link to clipboard

Copied

Hi,

I have tested this procedure, and it works with AA X.

But you need to have AA X, it can't be done in Reader. That means you have to save it in AA X and then open the file in Reader and then run the function.

Most people have only Reader and then it can't be done.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 12, 2012 Mar 12, 2012

Copy link to clipboard

Copied

Mr. Reinhardf Im using your script and I will like to change the code a little bit in order to get just some parts of the path,

Ex. my actual path is something like /1/2/3/4/5/abc.pdf and will like to change the footer to something like 4/5/abc.

1/2/3 will be always the same part of the path; all documents are in the same drive.

I know I need to change this part of you code

var re =/.*\/|\.pdf$/ig;
var FileNM = this.path.replace(re,"")+".pdf";
var Path = this.path;

But I can’t get what I want.

Any help will be appreciated

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 14, 2013 Nov 14, 2013

Copy link to clipboard

Copied

Hi ReinhardF!

In Acrobat 9 Pro Batch, execute JavaScript, please provide a script to add the footer and displays the date and file name,
Thank you very much!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 08, 2011 Dec 08, 2011

Copy link to clipboard

Copied

Hi Reinhard!

Can you please test the shortened script from answer 140? It allways place the file path to the left even if I press menu item "Center" or "Right".

Regards Arne

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 09, 2011 Dec 09, 2011

Copy link to clipboard

Copied

You may use

   if (ARG==2){fd.alignment="center"};

not

   if (ARG==2){fd.alignement="center"};

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 09, 2011 Dec 09, 2011

Copy link to clipboard

Copied

Thanks, Bernd!!

A mis-spelling can cause unexpected errors.

Best regards from Arne

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 08, 2012 Sep 08, 2012

Copy link to clipboard

Copied

Is it possible to print the the specific bookmark title/page title of each page in the footer of the pdf? 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 25, 2013 Apr 25, 2013

Copy link to clipboard

Copied

Another method, but not using Java Script, and this method may applied to each single file only.

http://www.uwec.edu/help/Acrobat9/for-date.htm

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 13, 2006 Nov 13, 2006

Copy link to clipboard

Copied

Thank you Reinhard! You were kind to do this; but if I may ask a favor, can I get a version that just prints the date and the file name? I don't need the file path, since it's very long anyway.

Also, this script crashes when one chooses the "yes" option on the remove dialog.

Many thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 15, 2006 Nov 15, 2006

Copy link to clipboard

Copied

Attached an updated Script. It gives you a menu for Set/Remove Footer. Then you can Set - Print - Remove.

HTH, Reinhard

PrintWithFooter.js
-------------------------------

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

app.addMenuItem({ cName: "Set Date Time (Filename)", cParent: "Footer", cExec: "SetFooter(1)"});
app.addMenuItem({ cName: "Set Page ", cParent: "Footer", cExec: "SetFooter(2)"});
app.addMenuItem({ cName: "Set Both", cParent: "Footer", cExec: "SetFooter(3)"});

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

app.addMenuItem({ cName: "Remove Date Time (Filename)", cParent: "Footer", cExec: "RemoveFooter(1)"});
app.addMenuItem({ cName: "Remove Page", cParent: "Footer", cExec: "RemoveFooter(2)"});
app.addMenuItem({ cName: "Remove Both", cParent: "Footer", cExec: "RemoveFooter(3)"});

function SetFooter(ARG)
{
var re = /.*\/|\.pdf$/ig;
var FileNM = this.path.replace(re,"")+".pdf";
var Path = this.path;
var AcDate = new Date();
for (var p = 0; p < this.numPages; p++)

{

if (ARG==1 || ARG==3) {var fd = this.addField("xftDate", "text", p, [30,15, 290,30]);

fd.textSize=6; fd.value = util.printd("yyyy/mmm/dd, HH:MM", AcDate) + " (" + FileNM +")"; }

if (ARG==2 || ARG==3){var fp = this.addField(String("xftPage"+p+1), "text", p, [350,15,300,30]);

fp.textSize=6; fp.value = "Page: " + String(p+1)+ "/" + this.numPages; }

} }

function RemoveFooter(ARG)
{

if (ARG==1 || ARG==3) {var x = this.removeField("xftDate");}

if (ARG==2 || ARG==3) {for (var p = 0; p < this.numPages; p++)

{

var x = this.removeField(String("xftPage"+p+1)); }

} }

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 16, 2006 Nov 16, 2006

Copy link to clipboard

Copied

OK! Did a little bit more so it is usable for myself.

Now you can choose if you want to have the "Date Time (Filename" footer want to have left, center, or right aligned.

The code has been updated:
- now it really cnter the boxes page for page.
- the first box (Date ...) uses the total width of the page. So it also useable if you want to have a selfmade footer note, something like "First Draft from ....". You have only to edit one box on one page, then it will be displayed on all pages.

- if you want to remove you can use allways "Remove both". It's only work a little bit longer in bigg files.

br, Reinhard

PS to other scripters: If someone has time he may improve the script.
The general settings could be done on a extra page (like general Dateformat, general Texthigh, ..... Then this can saved in global.js. So all the user defined settings are stored and retrieveable. That would Adobe save work. Adobe should set up a "Acrobat Scripts & Scraps" forum, where (freetime-)scripter can publish and discuss scripts.

Edit: ... and where it is also possible to publish scripts without to have to format by yourselft, so that it is readable!

SetRemoveFooter.js (<-Save in folder ...\javascript)

-----------------------------------------------


// SetRemoveFooter

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


app.addMenuItem({ cName: "Set Date Time (Filename)", cParent: "Footer", cExec: "SetFooter(1)"});

app.addMenuItem({ cName: " -> Set Date .... centered", cParent: "Footer", cExec: "SetFooter(2)"});

app.addMenuItem({ cName: " -> Set Date .... right", cParent: "Footer", cExec: "SetFooter(3)"});

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

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


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


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

app.addMenuItem({ cName: "Remove Date Time (Filename)", cParent: "Footer", cExec: "RemoveFooter(1)"});

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


//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 = "yyyy/mmm/dd HH:MM"

var Box2Width = 50

for (var p = 0; p < this.numPages; p++)

{

var aRect = this.getPageBox("Crop",p);

var TotWidth = aRect[2] - aRect[0]

if (ARG<=3 || ARG==5)

{var fd = this.addField("xftDate", "text", p, [30,15, TotWidth-30-30,30]);

fd.value = util.printd(AcDateFormat, AcDate) + " (" + FileNM +")";

fd.textSize=6; fd.readonly = true;

if (ARG==1){ fd.alignment="left" };

if (ARG==2){ fd.alignment="center" };

if (ARG==3){ fd.alignment="right" };

}

if (ARG==4 || ARG==5)

{var bStart=(TotWidth/2)-(Box2Width/2)

var bEnd=((TotWidth/2)+(Box2Width/2))

var fp = this.addField(String("xftPage"+p+1), "text", p, [bStart,30,bEnd,15]);

fp.value = "Page: " + String(p+1)+ "/" + this.numPages;

fp.textSize=6; fp.readonly = true;

fp.alignment="center";

}

} }


function RemoveFooter(ARG)

{

if (ARG<=3 || ARG==5) {var x = this.removeField("xftDate");}

if (ARG==2 || ARG==5) {for (var p = 0; p < this.numPages; p++)

{

var x = this.removeField(String("xftPage"+p+1)); }

} }

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 16, 2006 Nov 16, 2006

Copy link to clipboard

Copied

Hi Reinhard,

Thanks for working on this. However, this script does not work, because the "Set/Remove Footer" submenu does not appear in my File menu (the previous version worked fine). I have carefully copied and pasted your script into a new .js file in the \javascripts folder. What could I be doing wrong?

Jeff

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 16, 2006 Nov 16, 2006

Copy link to clipboard

Copied

I've edited above script and now it should work.

br, Reinhard

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 16, 2006 Nov 16, 2006

Copy link to clipboard

Copied

Thanks. Can you post it?

Regards

Jeff

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines