• 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

237.3K

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 ,
Nov 20, 2008 Nov 20, 2008

Copy link to clipboard

Copied

@KPanthen

Codeline:
fp.value = "Page: " + String(p+1)+ "/" + this.numPages;
replace with:
fp.value = "FINAL PRINT COPY " + String(p+1)+ "/" + this.numPages;

Codeline:
fp.textSize=6; fp.readonly = true;
replace with:
fp.textSize=6; fp.readonly = true;fp.textColor = color.green;

Maybe you set the fp.textSize=6 to 8 or 10, then you see the color better.

I didn't test if the box is width enough for that.
If not come back.

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 ,
Nov 20, 2008 Nov 20, 2008

Copy link to clipboard

Copied

Bernd,

We had some network problems in our office and I had to restart my computer; the scripts now appear correctly, though I am not sure why(the script to add a comment field however gives me an error that I am missing a ';' in line 18).

I applaud everybody's input and thank you once again.

I have a couple question

Is there a way to get a script that will add these items as a print watermark rather than to the file itself? Then if the file path changes the printed path would always be correct.

Is there a way to incorporate the 'Appearance Option' that specifies to 'Shrink document to avoid overwriting'?

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
LEGEND ,
Nov 20, 2008 Nov 20, 2008

Copy link to clipboard

Copied

You could use the doc "addWatermarkFromText()" method.

For example:

function PrtFooter() {
var sFirstLine = "Date: " + util.printd("yyyy/mmm/dd", new Date()) + " (" + this.path +")\r"; // first line
var sSecondLine; // second line
for(p = 0; p < this.numPages; p++) {

sSecondLine = "Page: " + String(p+1)+ "/" + this.numPages; // second line
this.addWatermarkFromText({
cText: sFirstLine + sSecondLine,
nFontSize: 8,
aColor: color.green,
nStart: p,
nEnd: p,
nTextAlign: app.constants.align.left,
nHorizAlign: app.constants.align.left,
nVertAlign: app.constants.align.bottom,
bOnScreen: false,
bOnPrint: true
});

} // end page loop
// this.print();
this.dirty = false; // cancel save prompt flag
} // end PrtFooter function

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 20, 2008 Nov 20, 2008

Copy link to clipboard

Copied

Geo,

How does this work? How do I invoke the script?

It doesn't appear to modify the menus or the print dialog box.

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
LEGEND ,
Nov 20, 2008 Nov 20, 2008

Copy link to clipboard

Copied

I just changed the code for the PrtFooter fucntion.

So an applicaiton JS File could look like:

app.addMenuItem({cName:"Print with Footer", cParent:"File", nPos:20, cExec:"PrtFooter();"}); // add Print with Footer to File menu option

function PrtFooter() {
var sFirstLine = "Date: " + util.printd("yyyy/mmm/dd", new Date()) + " (" + this.path +")\r"; // first line
var sSecondLine; // second line
for(p = 0; p < this.numPages; p++) {

sSecondLine = "Page: " + String(p+1)+ "/" + this.numPages; // second line
this.addWatermarkFromText({
cText: sFirstLine + sSecondLine,
nFontSize: 8,
aColor: color.green,
nStart: p,
nEnd: p,
nTextAlign: app.constants.align.left,
nHorizAlign: app.constants.align.left,
nVertAlign: app.constants.align.bottom,
bOnScreen: false,
bOnPrint: true
});

} // end page loop
// this.print();
this.dirty = false; // cancel save prompt flag
} // end PrtFooter function

You may need to fine tune it to get it placed exactly on the page. More information is contained in the Acrobat JavaScript API Reference.

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 22, 2008 Nov 22, 2008

Copy link to clipboard

Copied

Geo,

This works perfectly; I will have to decipher what determines the placement, but until then this will do fine.

Thanks again.

@ Jeffrey Kuhn, if you control click the acrobat program in OSX and select show package contents, you can navigate to the javascript folder (it's a subfolder within mac os i think). i've confirmed that the menus are modified by the scripts but haven't actually tried them.

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 ,
Mar 27, 2009 Mar 27, 2009

Copy link to clipboard

Copied

This is probably due to the document having security settings. Try a PDF w/o security. Download a program that strips the document of the Restrictions. This works most of the time for this error.

REPLY TO: Eli R Kaplan, "Print File Name with pdf Document" #27, 16 Apr 2007 1:16 pm

>QUOTE=====

>Eli R Kaplan - 1:16pm Apr 16, 07 PST (#27 of 79)

>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

----------------------------------------------------
>Reinhard Franke - 3:49am Apr 17, 07 PST (#28 of 79)

>"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

>END QUOTE =================

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 ,
Jul 16, 2009 Jul 16, 2009

Copy link to clipboard

Copied

I'm trying to get a simple FilePath/Document Name footer via the JS window in Acrobat Pro 7.1.0 and don't see the menu option under File->Print after a restarting of Acrobat.  No error messages, just no menu item.

I've copied the following text to this location: C:\Program Files\Adobe\Acrobat 7.0\Acrobat\Javascripts\PrintWithFooter.js


// 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)); }

} }

I do however have the following code working in the JS Editor inside of Acrobat:

this.addWatermarkFromText({cText: (this.path), nRotation:0, nVertValue:-124});

When I try to reduce the font size using:

this.addWatermarkFromText({cText: (this.path), nRotation:0, nVertValue:-124, fontSize: 8});

It's the same size as without the fontSize code, is there proper syntaxt that will get the font smaller?

Also, is there a way to not get the absolute path, but the drive letters?

This: this.addWatermarkFromText({cText: (this.path), nRotation:0, nVertValue:-124});

results in this:
/domain/drive/unit/remote/UserName/Creating Custom Labels.pdf

but I would like:


Y:UserName/Creating Custom Labels.pdf

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
LEGEND ,
Jul 16, 2009 Jul 16, 2009

Copy link to clipboard

Copied

If you check the Acrobat JavaScripting documentation, folder level scripts are only processed upon opening the application, so you will need to exit and shutdown Acrobat and any web browser using the PDF plug in and restart Acrobat to get the menu item established.

When specifying the parameter name, one needs to use the parameter name in the documentation. The parameter name for the font size is "nFontSize" to specify the number in points for the font size.

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 ,
Jul 16, 2009 Jul 16, 2009

Copy link to clipboard

Copied

GKaiseril wrote:

If you check the Acrobat JavaScripting documentation, folder level scripts are only processed upon opening the application, so you will need to exit and shutdown Acrobat and any web browser using the PDF plug in and restart Acrobat to get the menu item established.

No luck.  I even rebooted the PC and when I open Acrobat, it's still not there.

GKaiseril wrote:

When specifying the parameter name, one needs to use the parameter name in the documentation. The parameter name for the font size is "nFontSize" to specify the number in points for the font size.

That did it!  Oversight on my part.  Any ideas for the file path question (the way the syntax is a full path vs a drive letter?)

Thanks for getting me this far.

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 ,
Jul 22, 2009 Jul 22, 2009

Copy link to clipboard

Copied

I'm sorry to echo a question that's been asked several times before, but would someone tell me how specifically to edit the provided javascript so that it creates a Header with the document name when printing, instead of a footer? Thank you very much for your help!

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
LEGEND ,
Jul 22, 2009 Jul 22, 2009

Copy link to clipboard

Copied

This is a very advanced script. To edit this script you will need to know about the coordinates system used in PDFs, how to obtain the page size, and how to compute the location at the top of the page.

See 'Automating Placement of Annotations' by Thom Parker for information on how to compute the quad locations for annotations or form fields.

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 ,
Jul 22, 2009 Jul 22, 2009

Copy link to clipboard

Copied

Thanks so much GKaiseril! The document you linked me to was very useful and I was able to play around with coordinates to create a good header.

For anyone looking to get a header script, here's what I have:

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

app.addMenuItem({ cName: "Set Date Time (Filename)", cParent: "Header", cExec: "SetHeader(1)"});
app.addMenuItem({ cName: " ->  Set Date .... centered", cParent: "Header", cExec: "SetHeader(2)"});
app.addMenuItem({ cName: " ->  Set Date .... right", cParent: "Header", cExec: "SetHeader(3)"});
app.addMenuItem({ cName: "Set Page centered", cParent: "Header", cExec: "SetHeader(4)"});
app.addMenuItem({ cName: " -> Set Page right", cParent: "Header", cExec: "SetHeader(5)"});
app.addMenuItem({ cName: "Set Both", cParent: "Header", cExec: "SetHeader(9)"});

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

app.addMenuItem({ cName: "Remove Both", cParent: "Header", cExec: "RemoveHeader(9)"});
app.addMenuItem({ cName: "Remove Date Time (Filename)", cParent: "Header", cExec: "RemoveHeader(1)"});
app.addMenuItem({ cName: "Remove Page", cParent: "Header", cExec: "RemoveHeader(4)"});


//Set/remove Header
function SetHeader(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==9)
   { var fd = this.addField("xftDate", "text", p, [30,1450, TotWidth-30-30,30]);
      fd.value =  util.printd(AcDateFormat, AcDate) + "   (" + FileNM +")";
       fd.textSize=12; 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 ||ARG==9)
   {  var hStart=(TotWidth/2)-(Box2Width/2)
       var hEnd=((TotWidth/2)+(Box2Width/2))
       if (ARG==5){var hStart=(TotWidth-Box2Width-30); var hEnd=(TotWidth-30);}
       var fp = this.addField(String("xftPage"+p+1), "text", p, [hStart,30,hEnd,1450]);
       fp.value = "Page: " + String(p+1)+ "/" + this.numPages;
       fp.textSize=12;  fp.readonly = true;
       fp.alignment="center";
   }
}
}

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

Thanks again for your help!

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 ,
Oct 05, 2009 Oct 05, 2009

Copy link to clipboard

Copied

Hi,

SetRemoveFooter.js works great but I actually only need the file path in the footer, so no date no page number.  And how can I get more than one line for the path since the paths for my files sometimes go beyound one line.

Also anyone know how to change the \192.168.1.1\Projets\test.pdf to M:\Projects\test.pdf??

Thanks for your help.

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 06, 2010 Sep 06, 2010

Copy link to clipboard

Copied

How can this be done?

Contact support

http://www.xemtruyenhinh.info/

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
LEGEND ,
Sep 06, 2010 Sep 06, 2010

Copy link to clipboard

Copied

You can add the  water mark to show on print when you create the PDF assuming the  file will not be renamed. But you will need to add a 'Will Print" action to add the watermark or fill in a previously added field. If any users are using Reader you will not be able to add a watermark with JS.

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 ,
Mar 24, 2011 Mar 24, 2011

Copy link to clipboard

Copied

Hi, I am a novice at this, but I have the same requirement to print

filename and path on documents, particularly using the archive function.

Is there an easy way to do this in version Acrobat X pro?

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 ,
Aug 04, 2011 Aug 04, 2011

Copy link to clipboard

Copied

Hi folks,

I used Reinhard's JavaScript file (http://www.refob.de/downloads/Acrobat/SetRemoveFooter.js) in Adobe Pro 9.0, and it worked like a charm.


But now, I want to do a batch of files, and I can't get it to work.  I saw on another post that I should just use the SetFooter code (bottom of this post).  So, I did the following:

1) Clicked Advanced > Document Processing > Batch Processing

2) Clicked Select Commands

3) Added "Execute JavaScript"

4) Added the SetFooter code

5) I kept the default settings and clicked OK.

When I selected the sequence, clicked Run Sequence, and selected a PDF, I got nothing. The sequence executed without any error messages, but when I opened the file, the footer was not at the bottom. I've tried several different PDFs and I get the same thing. None of them are secured. I even removed the the SetRemoveFooter.js file from the JavaScript folder, and it still didn't work.

Can someone tell me what I'm doing wrong?

Here is the code I used in the batch sequence:

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==9)
   { 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 ||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-30);}
       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";
   }
}
}

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 ,
Aug 05, 2011 Aug 05, 2011

Copy link to clipboard

Copied

Hi,

first point: A function has to be called, like:

SetFooter(2);

second point: If you use may script you should avoid problems with redeclareing a function, so rename the function like:

SetFooterBatch(2);


function SetFooterBatch(ARG)

{

........

}

HTH, 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 ,
Aug 05, 2011 Aug 05, 2011

Copy link to clipboard

Copied

Hi Reinhard,

I forgot to mention that I'm almost completely ignorant when it comes to programming. I took a few variations of your instructions, and I'm still not getting this to work. Here they are:

1) Changed "function SetFooter(ARG)" to "function SetFooterBatch(ARG)"

2) Changed "function SetFooterBatch(ARG)" to "function SetFooterBatch(August)" and replaced all "ARG" in the code with "August". It didn't work, so I changed everything back to "ARG".

3) Added "SetFooterBatch(2);" to the top of my code.

4) Changed "SetFooterBatch(2);" to "SetFooterBatch(ARG);"

I'm sure the problem is obvious, but I'm very new to this. Any help will be appreciated. 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 ,
Aug 07, 2011 Aug 07, 2011

Copy link to clipboard

Copied

"I'm sure the problem is obvious, but I'm very new to this."

So then start simple and keep it simple.

Your startup I stated already to you, so take that for testing until you get it to work:

SetFooterBatch(2);


function SetFooterBatch(ARG)

{

........

-------

}

ARG is a variable, means arguments.

As arugments you can only only take 1-5 or 9.

Have a look at the menuitems in the full script to understand for what it stands.

But once again, start simple, get above to run and then you can go on.

HTH, 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 ,
Aug 08, 2011 Aug 08, 2011

Copy link to clipboard

Copied

I should have said, "I'm sure the problem is obvious to you, but it is not to me because I don't know much about programming. I'm just a government stiff trying to make sure that the taxpayer is getting his/her money's worth by spending more time doing my job rather than manually putting the filename into the footer of every file. So, if you could provide the straight code to do a batch process instead of making me guess, that would be great!"

But, just for the record, I did give it a shot. I want to make argument 1 rather than 2, so I made the replacement, and it still didn't work. Then, I just deleted all the other arguments and - you guessed it - it didn't work. Here's the shortened code I used:

{

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

var FileNM = this.path.replace(re,"")+".pdf";

var AcDate = new Date();

var AcDateFormat = "yyyy/mmm/dd HH:MM";

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

{

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

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

var fd = this.addField("xftDate", "text", p, );

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

fd.textSize=6;

fd.readonly = true;

fd.alignment="left";

}

}

I even threw in "function SetFooterBatch(ARG)" at the top, and then "SetFooterBatch(1)" above that. Still didn't work...

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 ,
Aug 08, 2011 Aug 08, 2011

Copy link to clipboard

Copied

Mmmh,

at least you are nearby. If you replace in your shortened code:

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

with the correct one (which includes []):

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

then the code works and you will get on every file and page left alined something like: 2011/Aug/08 14:55 (file01.pdf)

If that not works, perhabs someone with an english acrobat version can lead you through the steps how to set up a batch job. I'm afraid my translation from german to english would be to bad.

HTH, 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 ,
Aug 08, 2011 Aug 08, 2011

Copy link to clipboard

Copied

Actually, for some reason, the forum's text editor recognized the brackets as a link. So, I did have the brackets in there, and yes, it still doesn't work. Anyway, I'll try elsewhere. Thanks for your help.

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 ,
Aug 09, 2011 Aug 09, 2011

Copy link to clipboard

Copied

" ... trying to make sure that the taxpayer is getting his/her money's worth by spending more time doing my job rather then ..."

Ok, I think that's a good reason for a last try.

Because we don't get it to work direct in Acrobat I wrote a VBScript for that. I think the smartphone-generation would call it an "App" 🙂

Copy the following vbs into an editor (like Notepad) and save it as AcFooterBatch.vbs on your desktop.

Drag and drop from explorer some files on it and you will get it back with footer.

HTH, Reinhard

AcFooterBatch.vbs

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


'//////  User settings /////////////////////////////////////////////////////////
fileSaveDir = "c:\Temp"    '/->state an existing folder for saving changed files
mode = 1         '/->  0=work hidden; 1= show acrobat
test = 1             '/-> 0= don't show messages; 1=show messages
'///////////////////////////////////////////////////////////////////////////////

'    // set WSH objects
set oWsh = CreateObject ("Wscript.Shell")
Set oArgs = WScript.Arguments
Set fso = CreateObject("Scripting.FileSystemObject")
'    // test basic files/folders
if not fso.FolderExists(fileSaveDir) then : msgBox("Folder """ &fileSaveDir &""" don't exist") : wscript.quit : end if
if oArgs.Count = 0 then :    MsgBox("Drag & Drop files on this") : Wscript.quit : end if
'    // set acrobat basic objects
Set App = CreateObject("Acroexch.app")
if mode > 0 then app.show
Set AVDoc = CreateObject("AcroExch.AVDoc")
Set AForm = CreateObject("AFormAut.App") 'from AFormAPI

'    // write  acro-js to a variable for later executing
Ex = "  // set Date and filename as footer  "&vbLF _
  & "  var re = /.*\/|\.pdf$/ig;  "&vbLF _
  & "  var FileNM = this.path.replace(re,"""")+"".pdf"";  "&vbLF _
  & "  var AcDate = new Date();  "&vbLF _
  & "  var AcDateFormat = ""yyyy/mmm/dd  HH:MM"";  "&vbLF _
  & "  for (var p = 0; p < this.numPages; p++)   "&vbLF _
  & "  {   "&vbLF _
  & "    var aRect = this.getPageBox(""Crop"",p);  "&vbLF _
  & "    var TotWidth = aRect[2] - aRect[0];  "&vbLF _
  & "    var fd = this.addField(""xftDate"", ""text"", p, [30,15, TotWidth-30-30,30]);   "&vbLF _
  & "    fd.value =  util.printd(AcDateFormat, AcDate) + ""   ("" + FileNM +"")"";   "&vbLF _
  & "    fd.textSize=6;   "&vbLF _
  & "    fd.readonly = true;  "&vbLF _
  & "    fd.alignment=""left"";  "&vbLF _
  & "  }  "

'    // kernel: batch processing of js-code
for each xFile in oArgs
    if test = 1 then : OK = msgbox("Change file: " & xFile,1) : if OK = 2 then WScript.quit : end if
    If not fso.FileExists(xFile) Then : msgbox("File doesn't exist") : wscript.quit : end if
    If AVDoc.Open(xFile,"") Then
        set PDDoc = AVDoc.GetPDDoc
        AForm.Fields.ExecuteThisJavaScript Ex
        outFile = fileSaveDir &"\" &mid(xFile,InstrRev(xFile,"\")+1)
        if test = 1 then : OK = msgbox("Script executed"&vbCr&"SaveAs: "&outfile,1) : if OK = 2 then WScript.quit : end if
        If fso.FileExists(outFile) Then fso.DeleteFile(outfile)
        PDDoc.save 1, outFile
        App.CloseAllDocs
    else
        msgbox("Coudn't open file!") : wscript.quit
    end if
next

OK = msgbox("Batchjob finished!" &vbCr &"Close Acrobat?",1) : if OK = 1 then app.exit
Set AVDoc = Nothing : Set PDDoc = Nothing
Set APP = Nothing : Set AForm = Nothing

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