Skip to main content
Known Participant
September 12, 2018
Question

Use actual page size in AppleScript, not document setup size.

  • September 12, 2018
  • 1 reply
  • 1344 views

Hi all,

Hope somebody could point me in the right direction...

I have a droplet app written in AppleScript. It looks for the page size of the documents dropped and uses that info. Just for testing I have a dialog at the end which returns this.

The problem;

The app only returns the document size, as in the size displayed in the 'Document setup' window. I need to use the actual page size, as a large number of my clients use the page tool to adjust the page sizes. I need it to always use the actual page size.

Has anyone run into a similar problem?

My code is below, thanks in advance for any help

on open mgItems

  repeat with mgThisItem in mgItems

  tell application id “com.adobe.InDesign”

  try

  open mgThisItem

  tell active document

  my get_documentSizes()

  tell document preferences

  tell document preferences

  set overallwidth to page width

  set overallHeight to page height

  end tell

  end tell

  end tell

  close active document

  on error

  -- decide what kind of error handling you want to include if the file won’t open

  end try

  end tell

  -- rest of script for email processing here

  end repeat

  display dialog overallwidth

end open

This topic has been closed for replies.

1 reply

Inspiring
September 12, 2018

this will return the correct page size, round to closest whole numbers

on open mgItems

    repeat with mgThisItem in mgItems

        tell application id "com.adobe.InDesign"

            try

                open mgThisItem

                tell active document

                    set {a, b, c, d} to bounds of page 1

                    set PG_HEIGHT to round c

                    set PG_WIDTH to round d

                end tell

                close active document saving no

                display dialog "Height " & PG_HEIGHT & "mm" & "  Width " & PG_WIDTH & "mm" as string giving up after 3

            on error

                -- decide what kind of error handling you want to include if the file won’t open

            end try

        end tell

        -- rest of script for email processing here

    end repeat

end open

Known Participant
September 20, 2018

Thanks, managed to plug this code in and use perfectly !

Community Expert
September 23, 2018

Hi Lucas,

did you test the script with a document where the spread view was rotated?

Regards,
Uwe