2 Replies Latest reply on Dec 5, 2013 3:12 AM by SeniorSSS

    Beginers question - where to find Links.* options?

    SeniorSSS Level 2

      Hello!

       

      And again me I try again to script and have dificulties to find how to accsess such things like Actual PPi, Scale etc. I need to get that information to be able to rescale images with PS.

      So far i "know"  .name  and thats it.

       

      Thanks!

        • 1. Re: Beginers question - where to find Links.* options?
          Laubender Adobe Community Professional & MVP

          @SeniorSSS – these properties are not part of the Links objects, but are (partially, e.g. there is no "dimesions" property) properties of the images that are placed.

           

          You can get access to the placed graphic from the Links object to its parent property:

           

          var myLink = app.documents[0].links[0];
          var myPlacedThing = myLink.parent;
          

           

          In case your link (in my example the first link in the links list) is a JPEG or a TIFF file, the parent is of type "Image".
          To get it always right one could go further and resolve the specifier for that parent.

           

          myPlacedThing could be well a "Graphic", a "Movie", a "Sound" or a "Story".

           

          Resolving the specifier and "make it open" to read-out or apply its properties, one could do the following:

           

          var myPlacedThing = myLink.parent.getElements()[0];
          

           

          In case of an Image (a subtype of "Graphic", you could then check its properties like actualPpi etc.
          As I said: there is no "dimesions" property. For that case one has to calculate the dimensions of that image.

           

          Here some links to the DOM (Document Object Model) documentation Jongware provides:

           

          http://www.jongware.com/idjshelp.html

           

          Here the online documentation in HTML (you will find it more comfortable to use the CHM files Jongware provides):

           

          Link Object:

           

          http://jongware.mit.edu/idcs6js/pc_Link.html

           

          Image Object:

           

          http://jongware.mit.edu/idcs6js/pc_Image.html

           

          And another thing: to go from the Link object to the container object that holds the placed asset (=Graphic, Movie, Sound – NOT Story!!), you could ask for the parent.parent of the link and resolve its specifier:

           

          var myContainerOfPlacedThing = app.documents[0].links[0].parent.parent.getElements()[0];
          

           

          Be aware, that in case of a Story object the parent.parent of the Link is the Document object itself!
          Quite complicated. But this is the way it is ;-)

           

          Ah. One thing. To calculate the "dimensions" of an placed image see the following thread in the Swiss/German InDesign Scriptung forum at hilfdirselbst.ch:

           

          Solution provided by Hans Haesler, refined a bit by me:

           

          Johannes Puff

          Bildabmessungen auslesen

          (Read out dimensions of image)

          http://www.hilfdirselbst.ch/gforum/gforum.cgi?post=520393#520393

           

          Uwe

          1 person found this helpful
          • 2. Re: Beginers question - where to find Links.* options?
            SeniorSSS Level 2

            Thanks a lot!

             

            Very helpfull information and links. Lot of stuff to understand but doable now. Thanks again!