• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Can Acrobat PDF's be saved as single pages via Applescript Part 2
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can Acrobat PDF's be saved as single pages via Applescript Part 2


  • Subject: Re: Can Acrobat PDF's be saved as single pages via Applescript Part 2
  • From: Ray Robertson <email@hidden>
  • Date: Sat, 07 Jan 2017 10:18:40 -0500

Brian,

I worked on this issue years ago when we were doing AppleScript Pro Sessions. The approach I took then still appears to be working: Deleting all but a single page, saving that, and repeating. I tested the script below, and it still works in 10.12.2 with Acrobat Pro XI. I don’t think that is the current version of Acrobat, but I haven’t dealt with this in a while as I use Skim for most PDF scripting now.

FYI, I’m not bothering to update the script below to modernized it, such as using “as text” instead of “as string” and “as Unicode text”. This script is likely over a decade old, which doesn’t make me feel young.

Ray Robertson


-- This version takes a more straight-forward approach of repeatedly opening the document, deleting unused pages, and saving with linearizing. This approach would not have resulted in smaller file sizes in older versions of Acrobat

on open fileList
set originalFilePath to item 1 of fileList
-- Because Acrobat struggles with document names in open files, this script gets the name from the Finder, This could be done with text item delimiters parsing the file path, as shown in the alternate script
tell application "Finder"
set originalDocName to name of originalFilePath
end tell


set deskPath to path to desktop as Unicode text


tell application "Adobe Acrobat Pro"
with timeout of 600 seconds
open originalFilePath
tell document originalDocName
set pageCount to count each page
end tell
repeat with i from 1 to pageCount


if i > 1 then
open originalFilePath
end if
tell document originalDocName
if i = 1 then
delete pages first 2 last pageCount
else if i = pageCount then
delete pages first 1 last (pageCount - 1)
else
delete pages first (i + 1) last pageCount
delete pages first 1 last (i - 1)
end if
set pageName to page number of page i
end tell
set newDocName to (i as string) & ".pdf"
set newDocPath to deskPath & newDocName
save document originalDocName to file newDocPath with linearize
close document newDocName saving no
end repeat
end timeout
end tell
end open











 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Can Acrobat PDF's be saved as single pages via Applescript (From: Brian Christmas <email@hidden>)

  • Prev by Date: Can Acrobat PDF's be saved as single pages via Applescript
  • Next by Date: Re: Can Acrobat PDF's be saved as single pages via Applescript
  • Previous by thread: Can Acrobat PDF's be saved as single pages via Applescript
  • Next by thread: Re: Can Acrobat PDF's be saved as single pages via Applescript
  • Index(es):
    • Date
    • Thread