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

Get the Linked Item Page number in the Link Panel

Explorer ,
Mar 30, 2023 Mar 30, 2023

Hi,

I need to get the Page number of the Linked item in the Link Panel. I have used the following script. But it shows an error. Please guide on me to get the Page number of the linked item.

 

 

 

// get the active document
var doc = app.activeDocument;

// loop through all the links in the document
for (var i = 0; i < doc.links.length; i++) {

  // get the current link object
  var link = doc.links[i];

  // get the link properties
  var name = link.name; // name of the link
  var path = link.filePath; // path of the linked file
  var status = link.status; // status of the link (e.g. missing, modified, OK)
  var size = link.size; // size of the linked file in bytes
    var page = link.page;
  alert("Link name: " + name + "\nLink path: " + path + "\nLink status: " + status + "\nLink size: " + size + "\npage: " + page) ;

}

 

 

TOPICS
Scripting
507
Translate
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 Expert ,
Mar 30, 2023 Mar 30, 2023

Link doesn't have "page" property - its Parent object will have "parentPage" property.

 

Link can't exist without its parent container. 

 

Translate
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 Expert ,
Mar 30, 2023 Mar 30, 2023

Hi @Barathi , As Robert suggests try

 

var page = link.parent.parentPage.name
Translate
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 ,
Mar 30, 2023 Mar 30, 2023

Hi @rob day 

 

As per @Robert at ID-Tasker Suggesstion. I used to get the Master pagenumber 'A' as a output.But I need to get the exact page number(like 1,2, and so on) of the link.

Barathi_0-1680176922204.png

 

 

Translate
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 Expert ,
Mar 30, 2023 Mar 30, 2023

Only objects that have been overriden on a regular page will have that page number / name. 

 

Translate
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 ,
Mar 30, 2023 Mar 30, 2023

Yes. "A" is a page's name located in the MasterSpread.

Translate
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 Expert ,
Mar 30, 2023 Mar 30, 2023

The documentOffset of a master page would be less than 0, so maybe this?

 

var dl = app.activeDocument.links;
for (var i = 0; i < dl.length; i++) {
    if (dl[i].parent.parentPage.documentOffset>0){
        $.writeln(dl[i].parent.parentPage.name)
    }
}
Translate
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 Expert ,
Mar 30, 2023 Mar 30, 2023

But this still doesn't change anything? 

 

@Barathi can you clarify why are you expecting to get normal page name instead of Master?

 

Translate
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 Expert ,
Mar 30, 2023 Mar 30, 2023

I was thinking @Barathi wanted to skip the links on master pages:

 

var dl = app.activeDocument.links;
var s ="Links on Pages: \r"
for (var i = 0; i < dl.length; i++) {
    if (dl[i].parent.parentPage.documentOffset>0){
        s += dl[i].parent.parentPage.name + "\r"
    }
}

alert(s)

 

 

Screen Shot 2023-03-30 at 5.07.03 PM.png

Translate
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 Expert ,
Mar 30, 2023 Mar 30, 2023
LATEST

We can only guess 😉

 

Translate
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