Skip to main content
Inspiring
December 12, 2018
Answered

batch file page number sequence

  • December 12, 2018
  • 3 replies
  • 817 views

I have a batch script which combines all files in a folder.  I can add an Page processing action to add page numbers but it only pages each document separately. 

Is there a way I can do page numbers as a sequence of my entire documents.

Example:

1 Doc = 2 pages

2 Doc = 3 pages

Final doc should be stamped with pages 1-5

This topic has been closed for replies.
Correct answer Garfield1!

Found IT!!!!  the below code will set the page number as a footer and place in center.

************************************************************************************

    var Box2Width = 50;

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

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

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

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

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

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

        fp.value = "String(p+1);

        fp.textSize = 6;

        fp.readonly = true;

        fp.alignment="center";

    }

*********************************************************************************************

Full Example = Adobe Acrobat 9 Javascript to add footer to document - Stack Overflow

3 replies

Legend
December 13, 2018

setPageLabels sets page labels which you see in the "page number" display at the top of Acrobat. It allows you for instance to have page i, ii, iii, 1-1, 1-2 and so on. It doesn't add text to page contents.

I think the main way to add page numbers to each page is a unique for field on each page, but I have a feeling there is a better way. Anyone?

Garfield1!AuthorCorrect answer
Inspiring
December 13, 2018

Found IT!!!!  the below code will set the page number as a footer and place in center.

************************************************************************************

    var Box2Width = 50;

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

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

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

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

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

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

        fp.value = "String(p+1);

        fp.textSize = 6;

        fp.readonly = true;

        fp.alignment="center";

    }

*********************************************************************************************

Full Example = Adobe Acrobat 9 Javascript to add footer to document - Stack Overflow

Legend
December 13, 2018

Ok... that will combine the files. How do you add the page numbers at the moment?

Inspiring
December 13, 2018

I don't.  That is were I need help.  The below code doesn't work

this.setPageLabels(0, [ "D", "", 1]) or openDoc.setpageLabels().

Legend
December 12, 2018

Probably by changing the script. How do you combine?

Inspiring
December 13, 2018

var openDoc = app.openDoc({cPath: myPath}); < --Doc1 and the one I am adding Doc2 to.

// Get path of the file Acrobat has taken from the selected files

var path2file = this.path; <--Doc2

openDoc.insertPages ({ nPage: lastpage - 1, cPath: path2file });