Skip to main content
Inspiring
Dec 12, 2018 5:41 PM UTC
Answered

batch file page number sequence

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 is closed to new replies. Start a new post to keep the conversation going.
Garfield1!Correct answer
Inspiring
Dec 13, 2018 6:47 PM UTC

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

6 replies

Legend
Dec 13, 2018 6:42 PM UTC

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?

Translate
Garfield1!AuthorCorrect answer
Inspiring
Dec 13, 2018 6:47 PM UTC

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

Translate
Legend
Dec 13, 2018 6:05 PM UTC

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

Translate
Inspiring
Dec 13, 2018 6:09 PM UTC

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

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

Translate
Legend
Dec 12, 2018 6:00 PM UTC

Probably by changing the script. How do you combine?

Translate
Inspiring
Dec 13, 2018 5:31 PM UTC

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

Translate