Wrong sequence page list

Community Beginner ,
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

201

Likes

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

Adobe Community Professional , 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); } }

Likes

Translate

Translate
Adobe Community Professional ,
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);
    }
}

 

Likes

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
Community Beginner ,
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

Likes

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