Only loop through links on Page (not pasteboard)
Copy link to clipboard
Copied
Hi I'm looping through links with a script at the moment, but forgot about Pasteboard items, is there any simple adjustment to make it only look at parentPage=1 links for example?
var doc = app.activeDocument;
var links = doc.links ;
// start loop .......................
for(var i = 0; i < links.length; i++) {
link = links;
....
Copy link to clipboard
Copied
var objs = app.activeDocument.pageItems.everyItem().getElements();
while(obj=objs.pop()){
if(obj.parentPage == null) // Check the condition it will only find the links in the page
}
}
Copy link to clipboard
Copied
Try this,
var doc = app.activeDocument; |
var links = doc.links;
for(var i = 0; i < links.length; i++)
{
if(links.parent.parent.parentPage != null) | |
{ | |
alert(links.name) | |
} |
}
Regards,
Chinna
Copy link to clipboard
Copied
(obj.parentPage != null) /
Copy link to clipboard
Copied
Hi newtoindesign
Give this a try. You may have to refine it further.
main();
exit();
function main() {
var myDoc = app.activeDocument;
var myLinks = myDoc.links.everyItem().getElements();
for(var i = 0; i < myLinks.length; i++) {
// parent = e.g. imported Page
// parent.parent = rectagle
// parent.parent.parentPage is a page or null
if (myLinks.parent.parent.parentPage != null) alert("I am on a page");
else alert("I am not on a page");
}
}
kind regards
Daniel (from Switzerland)

