• 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: problems saving pdf
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problems saving pdf


  • Subject: Re: problems saving pdf
  • From: Shane Stanley <email@hidden>
  • Date: Thu, 09 Apr 2015 11:02:48 +1000

On 9 Apr 2015, at 10:50 am, David Crowe <email@hidden> wrote:

In my experience you need to use Acrobat's built-in _javascript_ (which you can execute via applescript) in order to do this.

You can certainly do it in _javascript_, but with the change I suggested, RJay's script works fine.

I will send you a script that I have that I think does exactly what you want. You go to a page in the PDF file, activate the script and it copies page 1 to current page to a separate PDF file, deletes the pages, and positions you back at the new page 1. It has a primitive mechanism for numbering the files you produce sequentially.

I presume something like this old script I have lying around, and which still seems to work OK:

on open fileList
set originalFile to item 1 of fileList
set saveTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to {":"}
set originalDocName to text item -1 of (originalFile as text)
set AppleScript's text item delimiters to {"."}
set originalDocNameStub to text 1 thru text item -2 of originalDocName
set AppleScript's text item delimiters to saveTID


set deskPath to path to desktop as text


tell application id "com.adobe.Acrobat.Pro" -- Adobe Acrobat Pro.app
open originalFile
tell document originalDocName
set pageCount to count each page
end tell
repeat with i from 1 to pageCount


if i > 1 then
open originalFile
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 originalDocNameStub & "-" & (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 tell
end open

For some things you need to use the built-in _javascript_, but certainly not all.

-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>

 _______________________________________________
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

  • Prev by Date: Re: problems saving pdf
  • Next by Date: Re: problems saving pdf
  • Previous by thread: Re: problems saving pdf
  • Next by thread: OS 10.2.3 Applescript Editor gone.
  • Index(es):
    • Date
    • Thread