0 Replies Latest reply on Jul 23, 2014 1:13 PM by InMarketing

    How to get the exact size of a Indesign document into a slug info box

    InMarketing

      Hey guys,

       

      I have this following code to get my slug box automatically filled out with an applescript:

       

      set mgDate to do shell script "date '+%d/%m/%y'"

       

      tell application "Adobe InDesign CS6"

          tell active document

              set mgPath to file path as string

              set mgName to name

              set text item delimiters of AppleScript to ":"

              set mgShortName to text item 1 of mgName

              set text item delimiters of AppleScript to "_"

              set mgClient to text item 3 of mgShortName

              set mgCode to text item 1 of mgShortName

              set mgTypeDoc to text item 5 of mgShortName

              set mgRetailer to text item 4 of mgShortName

              set mgJobNumber to text item 2 of mgShortName

              set text item delimiters of AppleScript to default

             

              repeat with mgPage from 1 to count pages

                  set mgWidth to item 4 of bounds of page mgPage

                  set mgWidth to mgWidth as integer

                  set mgHeight to item 3 of bounds of page mgPage

                  set mgHeight to mgHeight as integer

                  set mgDimensions to ((mgWidth as string) & "x" & mgHeight as string) & "inches"

                 

                 

                  set active page of layout window 1 to page mgPage

                  tell active page of layout window 1

                      try -- check to see that correct SLUG is on the page

                          set mgFrame to ((text frame 1 of group 1) whose label is "SLUG")

                      on error

                          try

                              set mgFrame to (text frame 1 whose label is "SLUG")

                          on error

                              display dialog "Your SLUG should be in place on every page." & return & return & "(Note : the correct SLUG has been given a script label to help with automation)"

                          end try

                      end try

                     

                      tell table 1 of mgFrame

                          set contents of cell 2 of row 1 to mgCode

                          set contents of cell 6 of row 1 to mgClient

                          set contents of cell 4 of row 1 to mgDate

                          set contents of cell 8 of row 1 to mgTypeDoc

                          set contents of cell 2 of row 2 to mgJobNumber

                          set contents of cell 6 of row 2 to mgRetailer

                          set contents of cell 8 of row 2 to mgDimensions

                          set contents of cell 4 of row 3 to mgPage as string

                          if contents of cell 4 of row 2 is "#" then

                              set contents of cell 4 of row 2 to "1"

                          else

                              set contents of cell 4 of row 2 to (contents of cell 4 of row 2) + 1 as string

                          end if

                      end tell

                  end tell

              end repeat

             

          end tell

      end tell

      Screen Shot 2014-07-23 at 3.57.25 PM.png

       

      When I run this applescript, it rounds up the decimal number of document size.... For example, for Us letter size, instead writing down 8.5 it will put 9 in.

      Does somebody know how to fix that?

      I also want my applescript says automatically if the document size is in Inches or Pixels, or centimeters. Thanks for your help!!!!!


      Sorry for my english, I am french!