Copy link to clipboard
Copied
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) ;
}
Copy link to clipboard
Copied
Link doesn't have "page" property - its Parent object will have "parentPage" property.
Link can't exist without its parent container.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Only objects that have been overriden on a regular page will have that page number / name.
Copy link to clipboard
Copied
Yes. "A" is a page's name located in the MasterSpread.
Copy link to clipboard
Copied
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)
}
}
Copy link to clipboard
Copied
But this still doesn't change anything?
@Barathi can you clarify why are you expecting to get normal page name instead of Master?
Copy link to clipboard
Copied
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)
Copy link to clipboard
Copied
We can only guess 😉