6 Replies Latest reply on Nov 11, 2008 3:01 PM by Loic.Aigon

    Add link to page

      Hi is it possible to display the name of a linked file on a page. I don't want to display all linked files just a few. I'm an absolute noob with indesign

      cheers
        • 1. Re: Add link to page
          Loic.Aigon Adobe Community Professional
          If you just want to know the name of the links, you may just have a look on the links palette. Once a picture is selected, the link is highlighted in the palette but you probably know that already.
          The fact is writing the script would be probably longer than just looking in the palette if you want to know the names for two or three images.
          However, the fact is "how" do you want the name of the linked files you selected ? Do you think about an alert ?
          Moreover what if the placed graphics you want to know the link's name are on several pages. Should you have to launch the script on each page to get your info ?
          A more ambitious way should be to create a text frame with the name inside. This object should be placed on an upper layer that you could switch off & on. At this step, let's do it for any placed graphics once & for all.
          I wil try to do something but I am sure someone will throw you something in a couple of minutes.
          Loic
          • 2. Re: Add link to page
            Loic.Aigon Adobe Community Professional
            Hi again,<br />Here is a script for labbeling placed graphics. Copy & paste into a text editor,save it as linklabelling.jsx then place it in the indesign script folder and launch it from indesign.<br />Loic<br /><br />//Link labelling - Loic Aigon - November 2008<br />//Labels all placed graphics with link name on upper layer name "link names"<br />//Suit it to your needs.<br /><br />//Check for documents open<br />if(app.documents.length!=0)<br />{<br />     var ad = app.activeDocument;<br />     var lks = ad.links;<br />     //Check for placed graphics<br />     if(lks.length>0)<br />     {<br />          var lays = ad.layers;<br />          var test = lays.everyItem().name;<br />          <br />          //Check if a layer named "links name" already exists<br />          if(String(test).indexOf("links name")>=0)<br />          {<br />               ad.layers.item("links name").remove();<br />          }<br />          ad.layers.add({name:"links name"});<br />          var lkslbl = ad.pageItems.everyItem().label;<br />          var lblcount = 0;<br />          <br />          //Check for every link if a label already exists meaning the script was launched formerly<br />          for(j=0; j<lks.length;j++)<br />          {<br />               if(String(lkslbl).indexOf(lks[j].name)==-1)<br />               {<br />                    //call to function<br />                    linkName(lks[j]);<br />                    lblcount+=1;<br />               }<br />          }<br />          //Dialog for switching on/off the links name layer at end of script<br />          if(lblcount>0 || String(test).indexOf("links name")!=-1)<br />          {<br />               ad.layers.item("links name").locked = true;<br />               var showlayer = confirm("Display links name layer ?");<br />               if(showlayer==false)<br />               {<br />                    ad.layers.item("links name").visible=false;<br />               }<br />               else<br />               {<br />                    ad.layers.item("links name").visible=true;<br />               }<br />          }<br />     }<br />     else<br />     {<br />          alert("You have no placed graphic in your document");<br />     }<br />}<br />else<br />{<br />     alert("You have no documents open");<br />}<br /><br />function linkName(link)<br />{<br />     var gf = link.parent.parent;<br />     var gfgb = gf.geometricBounds;<br />     var lktf = ad.textFrames.add(ad.layers.item("links name"),{geometricBounds:[gfgb[0],gfgb[1],(gfgb[0]+10),(gfgb[1]+50)]});<br />     lktf.contents = link.name;<br />     lktf.fit(FitOptions.FRAME_TO_CONTENT);<br />     lktf.label = link.name;<br />}<br />Hope it helps.
            • 3. Re: Add link to page
              Level 1
              Hi Loic, thx for the code. It places all the text on the 1st page at the top left hand side of the layout frame.
              I want to place text on top of the image on the page it occurs in the document
              • 4. Re: Add link to page
                Loic.Aigon Adobe Community Professional
                Hi for the pages issue, yeah my mistake.<br />I realized that going to bed and starting closing my eyes then...oups!<br />But it was no big deal to fix that.<br />Here you are :<br /><br />//Link labelling - Loic Aigon - November 2008<br />//Labels all placed graphics with link name on upper layer name "link names"<br />//Suit it to your needs.<br /><br />//Check for documents open<br />if(app.documents.length!=0)<br />{<br />     var ad = app.activeDocument;<br />     var lks = ad.links;<br />     //Check for placed graphics<br />     if(lks.length>0)<br />     {<br />          var lays = ad.layers;<br />          var test = lays.everyItem().name;<br /><br />          //Check if a layer named "links name" already exists<br />          if(String(test).indexOf("links name")>=0)<br />          {<br />               ad.layers.item("links name").remove();<br />          }<br />          ad.layers.add({name:"links name"});<br />          var lkslbl = ad.pageItems.everyItem().label;<br />          var lblcount = 0;<br /><br />          //Check for every link if a label already exists meaning the script was launched formerly<br />          for(j=0; j<lks.length;j++) <br />          { <br />               if(String(lkslbl).indexOf(lks[j].name)==-1) <br />               { <br />                    //call to function <br />                    linkName(lks[j]); <br />                    lblcount+=1; <br />               } <br />          }<br />     } <br /><br />     //Dialog for switching on/off the links name layer at end of script <br />     if(lblcount>0 || String(test).indexOf("links name")!=-1)<br />     {<br />          ad.layers.item("links name").locked = true;<br />          var showlayer = confirm("Display links name layer ?");<br />          if(showlayer==false)<br />          {<br />               ad.layers.item("links name").visible=false;<br />          }<br />          else<br />          {<br />               ad.layers.item("links name").visible=true;<br />          }<br />     }<br />     else<br />     {<br />     alert("You have no placed graphic in your document");<br />     }<br />}<br />else<br />{<br />alert("You have no documents open");<br />}<br /><br />function linkName(link)<br />{<br />     var gf = link.parent.parent;<br />     if(gf.parent.constructor.name == "Group")<br />     {<br />          var lkpg = gf.parent.parent;<br />     }<br />     else<br />     {<br />          var lkpg = gf.parent;<br />     }<br />     var gfgb = gf.geometricBounds;<br />     var lktf = lkpg.textFrames.add(ad.layers.item("links name"),{geometricBounds:[gfgb[0],gfgb[1],(gfgb[0]+10),(gfgb[1]+50)]});<br />     lktf.contents = link.name;<br />     lktf.fit(FitOptions.FRAME_TO_CONTENT);<br />     lktf.label = link.name;<br />} <br />Let me know if everything is fine. It works well on CS3 Mac OSX<br />Loic
                • 5. Re: Add link to page
                  Level 1
                  Hi Loic, this is sweet on windows XP with CS2. There may be multiple images on one page. Can the text be placed inside the image border?

                  BTW you are a legend, thank you
                  • 6. Re: Add link to page
                    Loic.Aigon Adobe Community Professional
                    Hi, <br />here it is,<br />This version deals with the frame border. I "stylized" the contents of the frame so it will fit whatever the background image is dark or light.<br /><br />"you are a legend" : It would be nice if it was true ! I am only a little ant aspiring to become so :-) <br /><br />Regards,<br />Loic<br /><br />//Link labelling - Loic Aigon - November 2008<br />//Labels all placed graphics with link name on upper layer name "link names"<br />//Suit it to your needs.<br /><br />//Check for documents open<br />if(app.documents.length!=0)<br />{<br />     var ad = app.activeDocument;<br />     var lks = ad.links;<br />     //Check for placed graphics<br />     if(lks.length>0)<br />     {<br />          var lays = ad.layers;<br />          var test = lays.everyItem().name;<br /><br />          //Check if a layer named "links name" already exists<br />          if(String(test).indexOf("links name")>=0)<br />          {<br />               ad.layers.item("links name").remove();<br />          }<br />          ad.layers.add({name:"links name"});<br />          var lkslbl = ad.pageItems.everyItem().label;<br />          var lblcount = 0;<br /><br />          //Check for every link if a label already exists meaning the script was launched formerly<br />          for(j=0; j<lks.length;j++) <br />          { <br />               if(String(lkslbl).indexOf(lks[j].name)==-1) <br />               { <br />                    //call to function <br />                    linkName(lks[j]); <br />                    lblcount+=1; <br />               } <br />          }<br />     } <br /><br />     //Dialog for switching on/off the links name layer at end of script <br />     if(lblcount>0 || String(test).indexOf("links name")!=-1)<br />     {<br />          ad.layers.item("links name").locked = true;<br />          var showlayer = confirm("Display links name layer ?");<br />          if(showlayer==false)<br />          {<br />               ad.layers.item("links name").visible=false;<br />          }<br />          else<br />          {<br />               ad.layers.item("links name").visible=true;<br />          }<br />     }<br />     else<br />     {<br />     alert("You have no placed graphic in your document");<br />     }<br />}<br />else<br />{<br />alert("You have no documents open");<br />}<br /><br />function linkName(link)<br />{<br />     var gf = link.parent.parent;<br />     if(gf.parent.constructor.name == "Group")<br />     {<br />          var lkpg = gf.parent.parent;<br />     }<br />     else<br />     {<br />          var lkpg = gf.parent;<br />     }<br />     var gfgb = gf.geometricBounds;<br />     var gfsw = gf.strokeWeight/(2.83*2);<br />     var lktf = lkpg.textFrames.add(ad.layers.item("links name"),{geometricBounds:[(gfgb[0]+gfsw+2),(gfgb[1]+gfsw+2),(gfgb[0]+gfsw+12),(gfgb[1]+gfs w+52)]});<br />     lktf.contents = link.name;<br />     //Stylize the placed content. May appear differently if you moved the swatches in the swatches palette.<br />     lktf.texts[0].fillColor = ad.swatches[1];<br />     lktf.texts[0].strokeColor = ad.swatches[2];<br />     lktf.texts[0].strokeWeight = "0.25pt";<br />     lktf.fit(FitOptions.FRAME_TO_CONTENT);<br />     lktf.label = link.name;<br />}