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

Automate Headers for Multiple Documents Based on Document Name - Batch Processing Execute Javascript

New Here ,
Nov 11, 2019 Nov 11, 2019

Hi there

I'm hoping to automate the insertion of headers on documents through the Batch Processing/Actions > Execute Javascript function of Adobe Acrobat Pro. 

 

The headers should have information on the left hand side and right hand side in Size 7 Arial font and pull the file name into the header. 

 

So far I've worked out how to insert a footer with the file name through Execute JavaScript with the following script but would love some assistance to modify this so that the final result is a header that looks like the attached picture (note - right hand header should automatically pull the file name -".pdf"). 

 

Header 1.PNGexpand image

 

The code I've got so far that give me a footer (that pulls the filename minus ".pdf") is shown below: 

 

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

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

var Path = this.path;

var Box2Width = 50

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

{

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

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

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

    hp.value = FileNM ;

    hp.textSize=9;

    hp.readonly = true;

    hp.alignment="right" ;

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

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

    var bStart=(TotWidth-Box2Width-30); var bEnd=(TotWidth-30);

}

 

flattenPages();

 

Thank you in advance for your assistance brainstrust!

 

TOPICS
How to
2.0K
Translate
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 ,
Nov 12, 2019 Nov 12, 2019

Maybe I don't understand your question, but why are you not using the same approach that you are using for the footer, and place the fields for the header? You show two differen groups of header information, one on the left edge, and one on the right. I would use one field per group, so you would need to add two fields, and because you are using two lines, you would have to make sure that the Field.multiLine property is set to true (see here for more information: https://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/index.html#t=Acro12_MasterBook%2FJ... )

 

You have to of course adjust the coordinates for where these fields go. 

 

Once the fields are placed, you flatten again, just like what you are doing for the footer. 

Translate
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, 2019 Nov 13, 2019
LATEST

Thank you Karl, that is very helpful. 

Many thanks

KH

Translate
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