2 Replies Latest reply on Aug 16, 2012 9:19 PM by HJS2

    Is there any way to determine if a link is a book mark or hyperlink in java script

    HJS2

      Is there any way to determine if a link is a book mark or hyperlink in java script

      Sub Problem:

      I am making an array of quads of all the hyperlinks in a document. I would like to automatically skip over all the bookmarks in the starting pages of a document and just get the links of the hyperlinks.

      Now I have to manually set the pages that contain bookmarks so they are not included in the array.

      Is there any way to determine if a link is a book mark or hyperlink in java script?

       

      It would help automate the conversion I need below

      John

       

       

      Main Problem:

      I have been working on converting a set of pdf files with 1000’s of hyperlinks like www.site.com\folder1\file1.pdf#page=10

      To jump to a local copy of the files with a relative type link

      ../folder1/file1.pdf and then go to the proper page.

      I have found that it can be done manually by changing the hyperlink to a javascript

      var otherDoc = app.openDoc('../folder1/file1.pdf', this);otherDoc.pageNum = 10 - 1;

      and setting each destination file with a disclose()=true;

      Based on the help so far that java script cannot access the hyperlink value in a link

      See: http://forums.adobe.com/thread/1039908?tstart=60

      I have resorted to the following plan using acrobat javascript, an external keyboard macro recorder and excel in combination to get around the problem

      Four folder level acrobat javascripts with “buttons”

      One to get all the link quads in an array, in the pdf and report the total number

      The second creates a form field in the far corner of the first page and moves there.

      The third jumps to each link found by creating a form field just to the left of the link and zooms in so it can be selected by a “mouse click” from the keyboard macro recorder 

      The forth deletes the form field

       

      The keyboard macro recorder runs javascript 2 and then 3 then clicks on the link just to the right of the middle of the screen and uses keys to get to the advanced editing to get to edit the hyperlink .

      The hyperlink is then copied to excel where it is converted using string functions to the needed javascript text to be copied back.

      To the acrobat file into a java script (after deleting the hyperlink)

      Rinse/lather/repeat

       

      I have been able to convert about 150 links an hour.

      Better then hand typing, but not like having java access to the links.

       

      I am looking to improve the solution

        • 1. Re: Is there any way to determine if a link is a book mark or hyperlink in java script
          Test Screen Name Most Valuable Participant

          I haven't looked at this lately to see if this has changed, but I never thought that any method in Acrobat would mix up bookmarks and links. In fact, bookmarks don't really have a quad, since the quad is for the SOURCE, and bookmarks have no source, they just live in their own panel.

          • 2. Re: Is there any way to determine if a link is a book mark or hyperlink in java script
            HJS2 Level 1

            thanks for your help.

             

            I may have been confusing a "acrobat bookmark" and a bookmark in a word file that is converted to a pdf and ends up being a

            link of the type:

             

            "Go to a page in this document"

             

            which I do not want in my array vs

            a link of the action type:

             

            "Open a web link"

             

            Which I do want

             

             

            John

             

            My code, note how I have to skip pages with "Go to a page in this document" links depending on the document, I would like to use the same code for each document and skip over the "Go to a page in this document" links :

             

            global.ilinkindex = 1; 
            global.aLinkquads = [ [0, 1, 1, 0, 0],
                   [0, 0, 0, 0, 0] ];

            function GetLinkArray()
            {

             

            global.ilinkindex = 1;
            var iTotalLinks=0;
             

             

            // for ( var p = 0; p < this.numPages - 8 ; p++)                   // end before bookmarks for each page of the file x.pdf

             

            //  for ( var p = 0; p < this.numPages; p++)                     // for each page of the file

            for ( var p = 23; p < this.numPages; p++)                     // start after bookmarks for each page of the file y.pdf

            {
              var cropbox = this.getPageBox("Crop", p);
              var alinksonpage = this.getLinks(p, cropbox);            // get array of links on page
              for ( var ll = 0; ll < alinksonpage.length; ll++)
              {
               var linkquads = alinksonpage[ll].rect;     // get link Quads
               linkquads[4] = p;          // add page number to link Quads array

                global.aLinkquads[global.ilinkindex] = linkquads; // add quads to global link Quads array
                global.ilinkindex++;
              }

             

            }
            iTotalLinks = global.aLinkquads.length - 1;
            global.ilinkindex = 1;

            app.alert("Number of Links in Document is " + iTotalLinks );

             

            }