MACSCRPT Archives

April 2014

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Nobumi Iyanaga <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Sat, 5 Apr 2014 19:51:57 +0900
Content-Type:
text/plain
Parts/Attachments:
text/plain (57 lines)
Hello Barry and Shane,

Thank you very much for the two scripts. I don't own PDFPen, but I have Adobe Acrobat and PDF Clerk Pro. The script by Barry worked just fine with the both applications. I didn't know that Acrobat was so much scriptable.

In both applications, the script works very quickly, though Acrobat seems a little speedier than PDF Clerk Pro. What is slow is the process to save the result. Moreover, PED Clerk Pro, at least, creates a huge file (what was 30 MB becomes something like 2 GB). When I reduce the file size with Acrobat, it returns to a normal size file -- but the process of reducing the file is VERY slow...

I would like to try Shane's script, but I am still on Mountain Lion, so I will go to Marvericks to try it.

Anyway, thank you so much again.

Best regard,

Nobumi Iyanaga
Tokyo,
Japan

On Apr 4, 2014, at 5:31 PM, Shane Stanley <[log in to unmask]> wrote:

> On 4 Apr 2014, at 1:55 pm, Nobumi Iyanaga <[log in to unmask]> wrote:
> 
>> I have many pdf files for which I would like to change the pagination -- for example reverse it completely, from the last page up to the first page, or invert (put page 1 as page 2, and page 2 to as page 1; page 4 as page 3, and page 3 as page 4, and so on).
>> 
>> I would like to ask if there is any tool that can automate such tasks, and how it is possible.
> 
> If you're running Mavericks, you can do it in AppleScriptObjC. Save the following as an ASObjC-based library (that is, as a .scptd file in ~/Library/Script Libraries/, with Cocoa-AppleScript checked in the Bundle Contents drawer):
> 
> use framework "Foundation"
> use framework "Quartz"
> 
> on reversePDF:thePath outputTo:newPath
> 	set inNSURL to current application's NSURL's fileURLWithPath:thePath
> 	set outNSURL to current application's NSURL's fileURLWithPath:newPath
> 	set theDoc to current application's PDFDocument's alloc()'s initWithURL:inNSURL
> 	set theCount to theDoc's pageCount() as integer
> 	set firstPage to 0
> 	set lastPage to (theCount - 1)
> 	repeat with i from 1 to (theCount div 2)
> 		(theDoc's exchangePageAtIndex:firstPage withPageAtIndex:lastPage)
> 		set firstPage to firstPage + 1
> 		set lastPage to lastPage - 1
> 	end repeat
> 	theDoc's writeToURL:outNSURL
> end reversePDF:outputTo:
> 
> Then you'd call it from your script like this:
> 
> use theLib : script "<name of script lib>"
> 
> set thePath to "/Users/shane/Desktop/Whatever.pdf"
> set newPath to "/Users/shane/Desktop/Whatever-2.pdf"
> theLib's reversePDF:thePath outputTo:newPath
> 
> 
> -- 
> Shane Stanley <[log in to unmask]>
> <www.macosxautomation.com/applescript/apps/>

ATOM RSS1 RSS2