Skip to main content
Participating Frequently
March 20, 2023
Answered

How to Move Auto Page Numbering from left to different corner of the page using Indesign script?

  • March 20, 2023
  • 4 replies
  • 908 views

I am trying to move Master Spread auto page numbering to right corner of the page using Indesign Extendscript. Unable to achieve it yet. 

Is there a way we can select the text frame of content type "SpecialCharacters.AUTO_PAGE_NUMBER"? 

Here is what i have tried so far -

 

 

for (var i = 0; i < app.activeDocument.masterSpreads.length; i++) {
    var page = app.activeDocument.masterSpreads[i].pages[0];
    for (var j = 0; j < page.textFrames.length; j++) {
        var textFrame = page.textFrames[j];

        alert(page.name + "*****" + textFrame.parentPage.name);
        
        if (textFrame.parentPage.name === page.name) {
            textFrame.paragraphs.everyItem().justification = Justification.RIGHT_ALIGN;
        }
    }
}

 

 

The above code is aligning all the textframes to right. I am interested in finding only the Auto page number text frame. Appreciate any insight and help on this! Thanks

 

<Title renamed by moderator>

This topic has been closed for replies.
Correct answer Laubender

Hi @VenkatMP ,

just a hint: you could find the paragraph of the auto page number if you are using a GREP Find action. Also per script.

The found text's paragraphs[0] is that paragraph.

The found text's parentTextFrames[0] is the text frame the special character is positioned.

 

Regards,
Uwe Laubender
( Adobe Community Expert )

 

 

4 replies

rob day
Community Expert
Community Expert
March 25, 2023

Hi @VenkatMP , In case someone else is looking for the grep example, this would get the document’s current page number characters as an array:

 

 

//the document‘s current page number characters
var pn = getPageNumbers()
$.writeln(pn)

/**
* gets the active document’s auto page numbers as an array 
* @ return the array 
*/
function getPageNumbers(){
    app.findTextPreferences = app.changeTextPreferences = app.findChangeTextOptions = null;
    app.findChangeTextOptions.properties = { 
        includeHiddenLayers:true, 
        includeLockedLayersForFind:true, 
        includeLockedStoriesForFind:true, 
        includeMasterPages:true} 
    app.findTextPreferences.findWhat = "^#";
    return app.activeDocument.findText()
}

 

LaubenderCommunity ExpertCorrect answer
Community Expert
March 21, 2023

Hi @VenkatMP ,

just a hint: you could find the paragraph of the auto page number if you are using a GREP Find action. Also per script.

The found text's paragraphs[0] is that paragraph.

The found text's parentTextFrames[0] is the text frame the special character is positioned.

 

Regards,
Uwe Laubender
( Adobe Community Expert )

 

 

VenkatMPAuthor
Participating Frequently
March 25, 2023

Thank you Laubender,

I've used the GREP action method, it worked!

brian_p_dts
Community Expert
Community Expert
March 20, 2023

Name your auto page number text frame as "autonum" in the layers panel, then for each page, get page.textFrames.itemByName("autonum");

VenkatMPAuthor
Participating Frequently
March 21, 2023

As am working on a large set of documents, I do not have the bandwidth to do the change for each document!  Is there a possiblity to name the auto page number text frame as "autonum" in the script itself? Ex: once I select the text frame with auto page numbering, I can use the inbuilt "AlignToPage" to move it to desired place on the page. Any help here would be much appreciated.

brian_p_dts
Community Expert
Community Expert
March 21, 2023

Is the auto page num not configured on the master pages for these documents? 

James Gifford—NitroPress
Legend
March 20, 2023

I'm unclear why a script is needed. Move the numbering text block on the Parent page(s), done... right?

 

VenkatMPAuthor
Participating Frequently
March 20, 2023

I have a large set of documents which has to be converted from Print Layout to Web, so i have  script for it. Removing the facing page makes the page number stay on the left, which I need on the right side. 

James Gifford—NitroPress
Legend
March 20, 2023

Okay. I just have a bias against "automation for automation's sake," seeing too many massive efforts to script/automate processes that can be completed manually in minutes, if not seconds. 🙂