Skip to main content
Known Participant
March 30, 2023
Question

Get the Linked Item Page number in the Link Panel

  • March 30, 2023
  • 2 replies
  • 743 views

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) ;

}

 

 

This topic has been closed for replies.

2 replies

rob day
Community Expert
Community Expert
March 30, 2023

Hi @Barathi , As Robert suggests try

 

var page = link.parent.parentPage.name
BarathiAuthor
Known Participant
March 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.

 

 

Robert at ID-Tasker
Legend
March 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)
    }
}

But this still doesn't change anything? 

 

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

 

Robert at ID-Tasker
Legend
March 30, 2023

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

 

Link can't exist without its parent container.