1 Reply Latest reply on Jul 25, 2010 8:40 AM by Muppet Mark-QAl63s

    How can I extract the document size of a PDF for Excel

    mikekmikek

      I have about 350 PDF's of signage for a client and we need to export the dimensions of each sign into an Excel spreadsheet. How can I do that?

        • 1. Re: How can I extract the document size of a PDF for Excel
          Muppet Mark-QAl63s Level 4

          If you are on the Mac OS then you could do this with a simple AppleScript. Just write the data to csv file and open that in Excel…

           

          This test worked for me… The sizes are in inches but the conversion could easily be changed to whatever…

           

          set PDF_Folder to (choose folder without invisibles)

          set CSV_File to (path to desktop as text) & "PDF_Sizes.csv"

          --

          tell application "Finder"

          set PDF_List to every file of PDF_Folder whose name extension = "pdf"

          end tell

          --

          repeat with This_PDF in PDF_List

          set This_PDF to This_PDF as alias

          set PDF_Name to name of (info for This_PDF)

          set PDF_PosixPath to quoted form of POSIX path of This_PDF

          set PDF_Pages to last word of (do shell script "/usr/bin/mdls -name kMDItemNumberOfPages " & PDF_PosixPath) as integer

          set PDF_Height to last word of (do shell script "/usr/bin/mdls -name kMDItemPageHeight " & PDF_PosixPath) as integer

          set PDF_Height to PDF_Height / 72

          set PDF_Width to last word of (do shell script "/usr/bin/mdls -name kMDItemPageWidth " & PDF_PosixPath) as integer

          set PDF_Width to PDF_Width / 72

          set PDF_Data to PDF_Name & "," & PDF_Height & "," & PDF_Width & "," & PDF_Pages & return

          --

          write_to_file(PDF_Data, CSV_File, true)

          --

          end repeat

          --

          beep

          display alert "All done…" giving up after 4

          --

          on write_to_file(this_data, target_file, append_data)

          try

          set the target_file to the target_file as string

          set the open_target_file to open for access file target_file with write permission

          if append_data is false then set eof of the open_target_file to 0

          write this_data to the open_target_file starting at eof

          close access the open_target_file

          return true

          on error

          try

          close access file target_file

          end try

          return false

          end try

          end write_to_file