Skip to main content
selvam214
Inspiring
August 17, 2017
Question

Sorted links to match with object links

  • August 17, 2017
  • 0 replies
  • 372 views

Hi All,

Here is my process:

Collect the images from page by page and sort with geometric order, I sorted and I can’t match with link and link’s name, because once sorted the links converted to an array and not an object. My aim to pass links to the below loop based on the sorted list. Can you please help to achieve my goal.

var doc = app.activeDocument;

var docLinks = doc.links;

linkSort(docLinks);

//can't pass the links to the below loop, the sorted link not in object link

for(i=0; i<myReturn.length; i++){

    //need to pass the link one by one asper shortlisted and go the next process

     var link = myReturn;

     //get base name

    }

function linkSort(docLinks){

    sortlist = [];

    myReturn = [];

    for(var k=0; k<docLinks.length; k++){

        var myGeo = docLinks.parent.parent.geometricBounds;

        var myTotalOut = docLinks.parent.parentPage.name+":"+Math.round(myGeo[0])+":"+Math.round(myGeo[1])+":"+docLinks;

        sortlist.push(myTotalOut.split(":"));

        }   

    sortlist.sort(doSort());

    sortlist.sort(doSort(false));

    for(s=0; s<sortlist.length; s++){

        var myshort = (sortlist[3]);

        myReturn.push(myshort)

        }

    }

function doSort(ascending) {

    ascending = typeof ascending == 'undefined' || ascending == true;

    return function(a, b) {

       var ret = b[0]-a[0] || b[1] - a[1] || b[2] - a[2];

       return ascending ? ret : -ret;

    };

}

Thanks,

Selva

This topic has been closed for replies.