Search code examples
resizeapplescriptadobe-indesign

InDesign Applescript Resizing Placed Images


Please explain how to make applescript understand I want to select all images on the active page (which in my case are going to be one), to resize the image and fit frame to content.

tell application "Adobe InDesign CS6"
    set myPagecount to count pages of active document
    repeat with i from 1 to myPagecount
        set thisImage to select every graphic frame of page i
        tell content of thisImage
            set height to "11in"
            set width to "8.5in"
            fit given frame to content
        end tell
    end repeat
end tell

This obviously doesn't work...

Thanks!


Solution

  • Just to give you some ideas:

    tell application "Adobe InDesign CS5.5"
        activate
        set myPagecount to count pages of active document
        tell active document    
            set myPage to page 1
            tell page myPage
                tell item 1 of all graphics of myPage
                    set geometric bounds of it to {10, 10, 0, 0}
                end tell
            end tell
        end tell
    end tell
    

    Just reference your page and loop through the collection of all graphics. You will need to change values for geometric bounds, use quotation marks for inches ("8.5in").

    =================================

    Edited:

    The code above actually resizes graphics/pdf inside the frame. I added 2 versions - one for the pdf and one for the frame. You need to set your values in geometric bounds

    tell application "Adobe InDesign CS6"
        activate
        set myPagecount to count pages of active document
        tell active document
            set myPage to page 1
            tell page myPage
                tell item 1 of all graphics of myPage
                    set geometric bounds of it to {100, 100, 0, 0}
                end tell
                tell text frame 1 of myPage
                    set geometric bounds of it to {100, 100, 0, 0}
                end tell
            end tell
        end tell
    end tell