OK… so the next step… I can add this information to my current script, but not being familiar with using the routines,
on getPageSize(theFile)
I don’t know how to properly insert it into my code.
I put the USE commands at the very top… and the ON getPageSize routine after the last tell. But when I call out the getPageSize from within my code it I get an error, can’t continue. Any thoughts?
Here’s my messy uncommented code:
use framework "Foundation"
use framework "Quartz"
use scripting additions
tell application "Finder"
set volume_ to "G1"
if (list disks) does not contain volume_ then
mount volume "smb://graphics101/G1"
--display dialog "volume is now mounted"
else
--display dialog "volume is already mounted"
end if
end tell
tell application "Adobe InDesign CC 2019"
activate
set PDF crop of PDF place preferences to crop media
set myRotateMatrix to make transformation matrix with properties {counterclockwise rotation angle:270}
set myKTRotateMatrix to make transformation matrix with properties {counterclockwise rotation angle:180}
set my_dialog_result to display dialog "Job Number?" default answer "" buttons {"Branded", "Generic", "cancel"} default button "Branded"
set button_returned to the button returned of my_dialog_result
set JobNum to the text returned of my_dialog_result
set MyDestFolder to "G1:CentralPDFProofs:" & JobNum & ":"
set MyArtPDF to "G1:CentralPDFProofs:" & JobNum & ":" & JobNum & "art.pdf"
set MyBCPDF to "G1:CentralPDFProofs:" & JobNum & ":" & JobNum & "bc.pdf"
set MySheetPDF to "G1:CentralPDFProofs:" & JobNum & ":" & JobNum & "sheet.pdf"
-- BEGIN PDF SIZE CALC
set theFile to MySheetPDF
set {pageWidth, pageHeight} to getPageSize(theFile)
-- END PDF SIZE CALC
try
tell application "Finder"
set MyJobFolder to (name of 1st folder of folder "G1:Art Department 2:Work Files2:" whose name begins with JobNum) as string
set myDestFile to "G1:Art Department 2:Work Files2:" & MyJobFolder & ":" & JobNum & "proof.indd"
end tell
on error
set my_lost_folder to display dialog "Crap, I can't find that folder. Should I put this in the PDF folder?"
tell application "Finder"
set MyJobFolder to (name of 1st folder of folder "G1:CentralPDFProofs:" whose name begins with JobNum) as string
set myDestFile to "G1:CentralPDFProofs:" & MyJobFolder & ":" & JobNum & "proof.indd"
end tell
end try
if button_returned = "branded" then
open file "macintosh HD:Users:davidklucznik:Desktop:PDF-VIDS.indt"
else
open file "macintosh HD:Users:davidklucznik:Desktop:PDF-GENERIC.indt"
end if
tell document 1 to set view preferences's ruler origin to page origin
set rulerOrigin to ruler origin of view preferences
if rulerOrigin is not page origin then set ruler origin of view preferences to page origin --(spread origin/page origin/spine origin)
--set PDF crop of PDF place preferences to crop media
tell page 1 of document 1
try
place file MyArtPDF
set geometric bounds of first rectangle to {0.1, 0.1, 4, 8.4}
send to back first rectangle
on error
display dialog "ARTWORK PDF missing"
end try
--end tell
end tell
tell page 2 of document 1
--set myBox2 to make rectangle with properties {geometric bounds:{0, 8.5, 11, 17}, stroke weight:"0", name:"BCpdfBOX"}
--tell myBox2
try
place file MyBCPDF
set geometric bounds of first rectangle to {0, 8.5, 5, 17}
send to back first rectangle
on error
display dialog "BC missing"
end try
--end tell
end tell
tell document 1 to set view preferences's ruler origin to page origin
tell page 3 of document 1
set myBox3 to make rectangle with properties {geometric bounds:{0, 8.5, 11, 17}, stroke weight:"0"}
tell myBox3
set fitting alignment of frame fitting options to center anchor
try
place file MySheetPDF
on error
display dialog "SHEET missing"
end try
end tell
transform myBox3 in page coordinates from center anchor with matrix myRotateMatrix
set geometric bounds of myBox3 to {0, 12.4375, 11, 20.9375}
move myBox3 by {-3.9375, 0}
end tell
set MyDup to duplicate myBox3 to page 1 of document 1
tell page 2 of document 1
set geometric bounds of MyDup to {0.35, 0.14, 3, 2.85}
move MyDup by {11.2, 5.375}
-- tell MyDup
-- set geometric bounds of MyDup to {5.67, 0.45, 8.36, 12.05}
-- move by {2.5, -0.215}
-- end tell
transform MyDup in page coordinates from center anchor with matrix myKTRotateMatrix
-- set geometric bounds of MyDup to {0, 8.5, 2.5, 11.125}
-- move MyDup to {11.5, 5.5}
-- set rotation angle of MyDup to 180
end tell
tell application "Adobe InDesign CC 2019"
save document 1 to myDestFile
end tell
end tell
on getPageSize(theFile)
set theURL to current application's |NSURL|'s fileURLWithPath:(POSIX path of theFile)
set pdfDoc to current application's PDFDocument's alloc()'s initWithURL:theURL
set thePage to pdfDoc's pageAtIndex:0 -- page 1
set pageSize to thePage's boundsForBox:(current application's kPDFDisplayBoxMediaBox)
set pageWidth to (current application's NSWidth(pageSize)) / 72
set pageHeight to (current application's NSHeight(pageSize)) / 72
return {pageWidth, pageHeight}
end getPageSize