Skip to main content
Participating Frequently
Mar 20, 2023 4:06 PM UTC
Answered

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

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 is closed to new replies. Start a new post to keep the conversation going.
LaubenderCorrect answer
Community Expert
Mar 21, 2023 4:27 PM UTC

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 )

 

 

10 replies

rob day
Community Expert
Community Expert
Mar 25, 2023 11:50 AM UTC

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

 

Translate
LaubenderCommunity ExpertCorrect answer
Community Expert
Mar 21, 2023 4:27 PM UTC

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 )

 

 

Translate
VenkatMPAuthor
Participating Frequently
Mar 25, 2023 9:41 AM UTC

Thank you Laubender,

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

Translate
brian_p_dts
Community Expert
Community Expert
Mar 20, 2023 4:58 PM UTC

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

Translate
VenkatMPAuthor
Participating Frequently
Mar 21, 2023 3:09 PM UTC

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.

Translate
brian_p_dts
Community Expert
Community Expert
Mar 21, 2023 3:49 PM UTC

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

Translate
James Gifford—NitroPress
Legend
Mar 20, 2023 4:17 PM UTC

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

 

Translate
VenkatMPAuthor
Participating Frequently
Mar 20, 2023 4:34 PM UTC

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. 

Translate
James Gifford—NitroPress
Legend
Mar 20, 2023 4:41 PM UTC

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. 🙂

 

Translate