I’m posting my final script here as a reference for others that may find the code useful. This script converts a multiple page PDF into separate JPG and PSD files - these files are sets of ads that run in different markets. Each file is trimmed to Letter size, and each has a caption containing the Brand, Publication, Run Date, Ad Size, and ad Type
beep
display dialog "This script will save your Multi-Page PDF file out as real purty JPG files!" buttons {"Dude, you rock!"} default button 1 with icon 1 giving up after 10
--choose your PDF file
set theFile to alias choose file of type "PDF " with prompt "Choose a PDF file to process"
--choose your destination
set destinationFolder to choose folder with prompt "Where the do you want your new JPG files?"
tell application "Finder"
set pdfFileName to name of theFile
set targetFolder to «class cfol» of theFile as string
end tell
set newPdfFileName to pdfFileName --as string
set newPdfFileName to characters 1 thru -5 of newPdfFileName as string
-- count the pages of the PDF, and save out a lower res version
tell application "Acrobat 6.0.1 Professional"
open theFile
set pageCount to (count of pages in document pdfFileName)
set LowResPDFname to (targetFolder & newPdfFileName & "_LR" & ".pdf") as string
save document 1 to file LowResPDFname with linearize
end tell
-- the text entered below determines our title
set BrandName to text returned of (display dialog "What's the brand/product?" default answer "")
set RunDate to text returned of (display dialog "Enter the ad's run date" default answer "")
set PubName to text returned of (display dialog "Publication Name?" default answer "")
set AdSize to text returned of (display dialog "What's the size of these ads? (Full-Page, etc)" default answer "")
set AdType to text returned of (display dialog "Enter the type of ad (FSI, etc)?" default answer "FSI")
-- close the PDF file, move on
tell application "Acrobat 6.0.1 Professional"
close document 1
end tell
tell application "Adobe Photoshop CS"
activate
-- don't display dialogs
set display dialogs to never
-- determinine the file name, process the page
repeat with currentPage from 1 to pageCount
set LastLetter to {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K"} --as string
open theFile as PDF with options {class:PDF open options, width:inches 11, height:inches 17, mode:RGB, resolution:200, use antialias:true, page:currentPage, constrain proportions:true}
set MyNewJPG to (name of current document) as string
set CharCount to (number of characters of MyNewJPG)
set the MyNewJpgName to (characters 1 thru (the CharCount - 5) of the MyNewJPG) as string
set MyNewFile to current document
--set background color
-- work on this file using inches
set units to inches
-- trim and set up the file
resize canvas MyNewFile width 7.375 anchor position middle center
resize canvas MyNewFile height 10.5 anchor position middle center
crop MyNewFile bounds {0, 0, 7.375, 10.5}
resize image MyNewFile height 10
resize canvas MyNewFile width 8.5 anchor position middle center
resize canvas MyNewFile height 10.5 anchor position middle center
resize canvas MyNewFile height 11 anchor position top center
resize image MyNewFile height 11
-- add a drop shadow to the layer
-- you'll need to be sure that you save your style in the Photoshop styles pallet
apply layer style art layer "Layer 1" of MyNewFile using "New Styles"
set Mycaption to (BrandName & " " & RunDate & " " & AdSize & " " & PubName & " " & AdType & " " & (item currentPage of LastLetter))
set the_layer to make art layer in current document with properties {kind:text layer, name:"Name Layer"}
tell text object of the_layer
set position to {4.25, 10.75}
set contents to Mycaption
set stroke color to {class:RGB color, blue:0, green:0, red:0}
set size to 24
set justification to center
set MyBrandNewName to (destinationFolder & MyNewJpgName & (item currentPage of LastLetter) & ".jpg") as string
set MyBrandNewName2 to (destinationFolder & MyNewJpgName & (item currentPage of LastLetter) & ".psd") as string
set JPGSaveOptions to {class:JPEG save options, format options:standard, quality:12, embed color profile:false}
set PSDSaveOptions to {class:Photoshop save options, save layers:true, save alpha channels:true, save annotations:true}
-- flatten it
save current document in file MyBrandNewName2 with options PSDSaveOptions appending lowercase extension with copying
flatten MyNewFile
save current document in file MyBrandNewName as JPEG with options JPGSaveOptions appending lowercase extension with copying
close current document saving no
end tell
end repeat
end tell
-- gather up the original PDF and the Low Res PDF to the same folder as the processed files
tell application "Finder"
activate
move file theFile to destinationFolder
move file LowResPDFname to destinationFolder
beep
beep
beep
end tell
Any suggestions to make this simpler or faster would be appreciated!