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

Wrong sequence page list

Explorer ,
May 11, 2021 May 11, 2021

Copy link to clipboard

Copied

Hi community,

I want to push page number in a list wherever a linked image appears but don't understand why list is a wrong sequence.

Could you help me? thanx in advance.

Mario

 

var allMyGraphics = app.activeDocument.allGraphics;
var myList = new Array();

for (g = 0; g < allMyGraphics.length; g++) {

var myPage = allMyGraphics[g].parentPage.name;
myList.push(myPage);
}
alert(myList);

 

TOPICS
Scripting

Views

308

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Expert , May 11, 2021 May 11, 2021

Probably because of spreads and how the graphics on the page are read. You could do this instead, especially if you just want one page number in the array. 

var pages = app.activeDocument.pages.everyItem().getElements();
var pagesWithGraphics = [];
for (var i = 0; i < pages.length; i++) {
    if (pages[i].allGraphics.length > 0) { 
        pagesWithGraphics.push(pages[i].name);
    }
}

 

Votes

Translate

Translate
Community Expert ,
May 11, 2021 May 11, 2021

Copy link to clipboard

Copied

Probably because of spreads and how the graphics on the page are read. You could do this instead, especially if you just want one page number in the array. 

var pages = app.activeDocument.pages.everyItem().getElements();
var pagesWithGraphics = [];
for (var i = 0; i < pages.length; i++) {
    if (pages[i].allGraphics.length > 0) { 
        pagesWithGraphics.push(pages[i].name);
    }
}

 

Votes

Translate

Translate

Report

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
Explorer ,
May 11, 2021 May 11, 2021

Copy link to clipboard

Copied

LATEST

Hi Brian,

this helped me and one page number is a better solution too.

thanx a lot

Mario

Votes

Translate

Translate

Report

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