🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #1374

Re: Extracting info from Links panel

#1374
From: Kasyan_Servetsky
Date: Thu, 12 Feb 2009 08:44
40 lines
1754 bytes
Here is my function that finds the page name the link is on:


 
#target indesign
myDoc = app.activeDocument;
myLink = myDoc.links[0];
myMessage = whereIsTheLink(myLink);
if (!isNaN(parseInt(myMessage))){
   myMessage = 'page ' + myMessage;
}
alert("My link is on " + myMessage);

function whereIsTheLink(theLink){
   while (theLink.constructor.name != 'Application') {
      if (theLink instanceof Page) {
         var myPageName = theLink.name;
         return myPageName;
      }
      if (theLink instanceof Character) {
         var thePage = whereIsTheLink(theLink.parentTextFrames[0]);
         if (thePage != undefined) return  thePage;
      }
   theLink = theLink.parent;
   myHierarchy += theLink.constructor.name + '|';
   }
  
   if (myHierarchy.lastIndexOf('|Page|MasterSpread|Document|Application|') != -1)
      {
      return 'master page';
      }
   else if (myHierarchy.lastIndexOf('|MasterSpread|Document|Application|') != -1)
      {
      return 'pasteboard of master page';
      }
   else if (myHierarchy.lastIndexOf('|Spread|Document|Application|') != -1)
      {
      return 'pasteboard';
      }
}
Technical Details
Message-ID: <59b7d3ce.10@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!newshub.sdsu.edu!webcrossing
References: <59b7d3ce.-1@webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,bd0091c62c2e8cba
X-Google-Attributes: gidf939a,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: Kasyan_Servetsky@adobeforums.com
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!newshub.sdsu.edu!webcrossing
Newsgroups: adobe.scripting.indesign
Subject: Re: Extracting info from Links panel
Message-ID: <59b7d3ce.10@webcrossing.la2eafNXanI>
Date: Thu, 12 Feb 2009 00:44:46 -0800
References: <59b7d3ce.-1@webcrossing.la2eafNXanI>
Lines: 29
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit