2 Replies Latest reply on Sep 20, 2018 1:15 AM by lucas.maximus

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

    lucas.maximus Level 1

      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

        • 1. Re: Use actual page size in AppleScript, not document setup size.
          Kevin Parrott Level 2

          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

          • 2. Re: Use actual page size in AppleScript, not document setup size.
            lucas.maximus Level 1

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