2 Replies Latest reply on Nov 19, 2008 7:08 AM by (Stefan_Thomas)

    anchor all images within a document

      Hello everynbody,

      i am currently triing to write a script that loops all (not anchored) graphics within a document. I want to anchor the image because i want them to move along with the text.

      Here are the steps i took so far:
      ---------------------------------

      1. Iterating through graphics using "myDocument.allGraphics"
      2. Check if "myGraphic.parent.parent.constructor.name" is Character or Page. If it is character the image is already anchored.
      3. Iterate through all text frames on the page of the current image and
      determine one frame that overlaps the Rectangle of the image.
      4. Determine the everage height of a line of the frame (Heigh of frame / number of lines)
      5. Determine the line number of the insertion point for the graphic (=iLine)
      6. Determine the average number of characters per line (=averageChars)
      7. Calculate the average width of a chracter (width if text frame / average number of chars per line)
      8. Calculate the number of characters for the indention (horicontal) of the graphic (=iChars)
      9. Insert graphic as follows:
      var myNewGraphic = matchingFrame.insertionPoints.item(iChars + iLines * averageChars).place(file, false);
      10. Delete the original graphic and it´s rectangle

      My problems are as follows:
      1. The insertion position of the image is never correct even though the calculated line number (iLines) and the calculated indention (iChars) is correct.
      2. After insertion of the image the text does not flow correctly around the contures of the image
      3. I dont know how to set the options for anchored objects as listed in (Objekt -> Verankertes Objekt -> Optionen IN GERMAN VERSION OF INDESIGN)

      I am using Windows XP SP3, i am working with Adobe InDesign CS3 and for scripting i am using JavaScript (for compatibility between MAC and WINDOWS).

      Thanks everybody. If the source code is needed i will provide it.
        • 1. Re: anchor all images within a document
          Peter Kahrel Adobe Community Professional & MVP
          Thomas,

          >1. The insertion position of the image is never correct

          You need to start at the end of the document and work your way to the beginning. This is to ensure that references to graphics and frames remain constant.

          >2./3. I dont know how to set the options for anchored objects as listed in (Objekt -> Verankertes Objekt -> Optionen IN GERMAN VERSION OF INDESIGN)

          All these are enumerations, so you should use the English names. The object-model viewer shows the terms you can use (see under anchorPosition, anchorObjectDefault, anchorObjectSettings, etc.).

          Peter
          • 2. Re: anchor all images within a document
            I'd love to help with this script, because I need to do this very thing myself. Would you be willing to post the script or send to thomas [at-symbol] eload24.com? It would really save me a lot of time, thanks!