3 Replies Latest reply on Oct 23, 2008 9:55 AM by (Olav_Kvern)

    Offset placed image within rectangle

      I need the code that allows me to offset image within a rectangle. Hopefully within properties as I place image on imageFrame. I've googled for quite a while. All help appreciated.

      set filePath to alias "Mac_3a:Users:kevin:Documents:DustBin:20080807:theImage.pdf"

      tell application "Adobe InDesign CS3" to tell document 1
      set imageFrame to make rectangle at page 1 with properties {geometric bounds:{0, 0, 5, 7}}
      place filePath on imageFrame with properties {absolute horizontal scale:30, absolute vertical scale:30}
      end tell
        • 1. Re: Offset placed image within rectangle
          sstanleyau Level 4
          You need to set the geometric bounds of the graphic after you've placed it.<br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au>
          • 2. Re: Offset placed image within rectangle
            Level 1
            This code works, if slightly inaccurate in placement. Please notice the commented code showing an error when attempting to retrieve geometric bounds of the image within the rectangle. Any thoughts on that error?

            set frameBounds to {0.0, 0.0, 11.0, 8.5}
            set linkPath to alias "Mac_3a:Users:kevin:Pictures:Faux Fur.jpg"
            set linkOffset to {-1, -3, 0, 0}

            tell application "Adobe InDesign CS3"
            tell document 1
            tell page 1
            set imageFrame to make rectangle with properties {geometric bounds:frameBounds}
            set framedImage to place linkPath on imageFrame with properties {absolute horizontal scale:100, absolute vertical scale:100, geometric bounds:linkOffset}
            -- tell framedImage to get geometric bounds -- this code errors
            end tell
            end tell
            end tell
            • 3. Re: Offset placed image within rectangle
              Level 1
              Hi Kevin,

              You can use the move method. Something like this:

              --Measurement units are points.
              
              set frameBounds to {0, 0, 712, 692}
              set linkPath to alias "hazuki:test.jpg"

              tell application "Adobe InDesign CS3"
              tell document 1
                tell page 1
                 set imageFrame to make rectangle with properties {geometric bounds:frameBounds}
                 set framedImage to place linkPath on imageFrame with properties {absolute horizontal scale:100, absolute vertical scale:100}
                 --The place method returns an array.
                 tell item 1 of framedImage
                  move by {-216, -72}
                 end tell
                end tell
              end tell
              end tell

              Thanks,

              Ole