Crop PDF
HI,
Sorry i don't know the place to write this so writing here...
I am croping pdf to trim size using applescript.
1. Crop Pages -> Get the Trim box values
2. Place the values (T, L, B, R) to the Crop box.
3. Select All radio button
4. Click Ok.
Following these steps in apple script but after cropping the pdf (ie., after completing script) no changes in pdf. Actually values are asigned to crop process but no changes. I could not get the issue. Can anyone help me?
Code:
------------- Process --------
set pdfFile to choose file
my mainProcess(pdfFile)
display dialog "Process Completed!!!"
-------------- Functions ---------
on mainProcess(pdfFile)
local trimboxFlg, cropboxFlg
set cropboxFlg to 0
set trim_box to ""
tell application "Adobe Acrobat Pro"
activate
open pdfFile
delay 1
set trimVals to my getTrimValues()
--display dialog "trimVals " & trimVals
--set trimVals to {0.545, 0.545, 0.545, 0.545}
delay 1
my cropProcess(trimVals)
end tell
end mainProcess
on cropProcess(trimVals)
local cropboxFlg, boxTypeValue2
set boxTypeValue2 to "CropBox"
set cropboxFlg to 0
tell application "System Events"
tell process "Acrobat"
click menu item "Crop Pages..." of menu 1 of menu bar item "Document" of menu bar 1
if exists window "Crop Pages" then
tell window "Crop Pages"
tell pop up button 1 of group "Crop Margins"
set boxType to value of item 1 as string
if boxType is not equal to boxTypeValue2 then
click
click menu item boxTypeValue2 of menu 1 -- click TrimBox
set cropboxFlg to 1
else
set cropboxFlg to 1
end if
end tell
--click button "Revert To Selection" of group "Margin Controls" of group "Crop Margins"
if cropboxFlg is equal to 1 then -- Get trim box values
set value of text field 1 of group "Margin Controls" of group "Crop Margins" to (item 1 of trimVals) as string
set value of text field 2 of group "Margin Controls" of group "Crop Margins" to (item 2 of trimVals) as string
set value of text field 3 of group "Margin Controls" of group "Crop Margins" to (item 3 of trimVals) as string
set value of text field 4 of group "Margin Controls" of group "Crop Margins" to (item 4 of trimVals) as string
end if
click radio button "All" of group "Page Range"
click button "OK"
end tell
else
display dialog "ELSE..."
end if
end tell
end tell
end cropProcess
on getTrimValues()
local trimTop, trimBottom, trimLeft, trimRight
local trim_box, trimboxFlg
set boxTypeValue1 to "TrimBox"
set trimboxFlg to 0
set trimTop to 0
set trimBottom to 0
set trimLeft to 0
set trimRight to 0
tell application "System Events"
tell process "Acrobat"
click menu item "Crop Pages..." of menu 1 of menu bar item "Document" of menu bar 1
if exists window "Crop Pages" then
tell window "Crop Pages"
tell pop up button 1 of group "Crop Margins"
set boxType to value of item 1 as string
if boxType is not equal to boxTypeValue1 then
click
click menu item boxTypeValue1 of menu 1 -- click TrimBox
set trimboxFlg to 1
else
set trimboxFlg to 1
end if
end tell
if trimboxFlg is equal to 1 then
set trimTop to the value of text field 1 of group "Margin Controls" of group "Crop Margins" as string
set trimBottom to the value of text field 2 of group "Margin Controls" of group "Crop Margins" as string
set trimLeft to the value of text field 3 of group "Margin Controls" of group "Crop Margins" as string
set trimRight to the value of text field 4 of group "Margin Controls" of group "Crop Margins" as string
end if
end tell
end if
end tell
end tell
return {trimTop, trimBottom, trimLeft, trimRight}
end getTrimValues
- Sudha K
