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

Get the Linked Item Page number in the Link Panel

Explorer ,
Mar 30, 2023 Mar 30, 2023

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

}

 

 

TOPICS
Scripting

Views

348

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

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. 

 

▒► ID-Tasker - "Industrial Revolution" is finally here ◄▒

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

Copy link to clipboard

Copied

Hi @Barathi , As Robert suggests try

 

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

Copy link to clipboard

Copied

Hi @rob day 

 

As per @Robert Tkaczyk 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

 

 

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

Copy link to clipboard

Copied

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

 

▒► ID-Tasker - "Industrial Revolution" is finally here ◄▒

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

Copy link to clipboard

Copied

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

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

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

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

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?

 

▒► ID-Tasker - "Industrial Revolution" is finally here ◄▒

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

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)

 

 

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

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

Copy link to clipboard

Copied

LATEST

We can only guess 😉

 

▒► ID-Tasker - "Industrial Revolution" is finally here ◄▒

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