Thanks to a script from Mark67 I’ve been able to get closer.
I’ve modified the original to not look for deviceN and other aspects not needed.
This script is setup to expect files created a specific way from Quark. Mine are not. This seems to be causing the pageboxes not to be recognized.
This is the result of a folder with two files in a folder is below
original.pdf No MediaBox No BleedBox No TrimBox No CropBox
extra.pdf No MediaBox No BleedBox No TrimBox No CropBox
How do I adjust this script to reference the Acrobat info for page boxes?
Also how do I get it to include the page count of each file in the results?
Can this be made so you drop a folder on it rather than pointing to it manually?
Any input is appreciated,
John
set Q1 to "Do you want to include all the subfolders" & return & "within your folder selection?"
set theDialog to display dialog Q1 buttons {"No", "Yes", "Cancel"} default button 1 with icon note
if button returned of theDialog is "Yes" then
set inputFolder to choose folder with prompt "Where is the top level folder of PFD's?" without invisibles
tell application "Finder"
set filesList to (files of entire contents of inputFolder whose name extension is "pdf" or file type is "PDF ")
end tell
else
tell application "Finder"
set inputFolder to choose folder with prompt "Where is the folder of PFD's?" without invisibles
set filesList to (files of inputFolder whose name extension is "pdf" or file type is "PDF ")
end tell
end if
set countA to count of filesList
if countA = 0 then
tell application "Finder"
display dialog "Your selection contained no PDF files to check!" buttons {"Cancel"} default button 1 giving up after 3
end tell
end if
--
repeat with aFile in filesList
tell application "Finder"
set theFile to aFile as alias
set docName to name of theFile
end tell
set MediaBox to my GREPSearch(theFile, "MediaBox")
set BleedBox to my GREPSearch(theFile, "BleedBox")
set TrimBox to my GREPSearch(theFile, "TrimBox")
set CropBox to my GREPSearch(theFile, "CropBox")
--
my writelog(docName, MediaBox, BleedBox, TrimBox, CropBox)
end repeat
--
set ReadFile to ((path to desktop folder) as text) & "PDF Info Log.txt" as alias
tell application "TextEdit"
activate
open ReadFile
end tell
--
on GREPSearch(theFile, BoxType)
set SearchString to BoxType & "\\[[. [:digit:]]{1,}\\]"
try
set BoxText to find text SearchString in theFile with regexp and string result
set FoundString to the result
set BoxText to my BoxMeasure(BoxType, FoundString)
return BoxText
on error
return ("No " & BoxType) as text
end try
end GREPSearch
--
on BoxMeasure(BoxType, FoundString)
set x to text ((BoxType's length) + 2) thru -2 of FoundString
set {L, B, R, T} to my GetTextItem(x, " ", 0)
set {L, B, R, T} to {L as number, B as number, R as number, T as number}
set H to (((((T - B) / 72) as inches) as centimeters) as number) * 10
set W to (((((R - L) / 72) as inches) as centimeters) as number) * 10
set thisHeight to my RoundDecimal(H, 3, to nearest)
set thisWidth to my RoundDecimal(W, 3, to nearest)
return thisWidth & "mm " & thisHeight & "mm" as string
end BoxMeasure
--
on RoundDecimal(NumberToRound, DecimalPlace, RoundType)
set RoundFactor to 10 ^ DecimalPlace
NumberToRound * RoundFactor
round result rounding RoundType
result / RoundFactor
end RoundDecimal
--
on GetTextItem(ThisString, ThisDelim, ThisItem)
copy the text item delimiters to OldDelims
set the text item delimiters to ThisDelim
if class of ThisItem is list then
set fromItem to (item 1 of ThisItem) as integer
set toitem to (item 2 of ThisItem) as integer
set arrItem to (text items fromItem thru toitem of ThisString)
else
set arrItem to every text item of ThisString
end if
set the text item delimiters to OldDelims
if class of ThisItem is list then
return arrItem as text
else
if ThisItem is not 0 then
return (item ThisItem of arrItem) as text
else
return arrItem
end if
end if
end GetTextItem
--
on writelog(docName, MediaBox, BleedBox, TrimBox, CropBox)
set theLog to ((path to desktop folder) as text) & "PDF Info Log.txt"
try
open for access file the theLog with write permission
write (docName & tab & tab & tab & MediaBox & tab & BleedBox & tab & TrimBox & tab & CropBox & return) to file the theLog starting at eof
close access file the theLog
on error
try
close access file the theLog
end try
end try
end writelog