try
set
sourceFile to
choose file with prompt "Select a PDF file"
on error errMsg
number
errNum
if
errNum is -128 then
display dialog "User cancelled."
else
display dialog "Unknown choose file error"
end
if
return
end try
--get the file name then strip out the file extension
tell
application "Finder"
set
myName to name
of sourceFile
set
myName to ((characters 1
thru -5 of myName) as
string)
end tell
set
myName to myName & " FRONT.pdf"
--do acrobat stuff
tell
application "Adobe Acrobat Pro"
activate
open
sourceFile
set
mediaSize
to get media box
of page 1
of active doc
--get media box so our new doc can be made the same size
--make a new document then set its size to the source file size
set
newFront
to make new
document
tell
newFront
tell
page 1
set
media box to
mediaSize
end
tell
end
tell
insert pages
newFront
after 0 from
active doc
starting with 1 number of pages 1
insert bookmarks no
bring to front
newFront
end tell
--set the file path to save the new docs to
tell me
to activate
set
folderPath to choose folder
with prompt "Choose a folder to save the separated pages to."
set defaultPath
to (folderPath as text) &
myName
--save the new doc
tell
application "Adobe Acrobat Pro"
activate
tell
active doc
if
modified is
true then
save
to
file (defaultPath)
end
if
end
tell
end tell