Re: Split PDF and reduce file size - finished script in PDFTK
Re: Split PDF and reduce file size - finished script in PDFTK
- Subject: Re: Split PDF and reduce file size - finished script in PDFTK
- From: Ian Cook <email@hidden>
- Date: Fri, 12 Aug 2005 07:36:21 +0100
I've now had a chance to compare acrobat vs pdftk and for this task there is
no comparison. With Marks help I have now got pdftk to work. The PDF Tool
Kit is amazing. It splits a 92 page pdf into single files in about 12
seconds on my G4. Usually I'm a vanilla bloke, I don't like using plug-ins
as my scripts are used on loads of different production machines, but this
makes installing pdftk well worth it. Especially as the installation is now
so easy and there's so much more that pdftk does.
I'm putting my script below and some notes as I think that ANYONE needing to
manipulate pdfs might find this helpful, especially as the scripting
dictionary in acrobat is utterly pathetic. I had it running in 6 and then
tried it in 7 and got other errors.
1. I loaded pdftk (freeware) from here
http://www.accesspdf.com/article.php/20041130153545577
using the OSX installer. I'd just like to re-iterate what Mark said - it
loads EVERYTHING you need - don't worry about having to mess around with
GCC, GCJ or any command line tweaks - just use the installer and restart.
2. Here's the script...
tell application "Finder"
--select a file
set the theFile to (choose file with prompt "Select the file to burst:")
as alias
--get the path to the enclosing folder
set oldDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to {":"}
set theFolder to (((text items 1 thru ((count every text item of
(theFile as string)) - 1)) of (theFile as string))) as string
set AppleScript's text item delimiters to oldDelimiters
--get the file name
set theFileName to the name of theFile
end tell
--run pdftk burst command
do shell script "/usr/local/bin/pdftk " & (POSIX path of theFile) & " burst
output " & (POSIX path of theFolder) & "/" & theFileName & "_d.pdf"
And as if by magic your files will appear. Please note the following
-When running from Applescript you have to use the POSIX path on the shell
command
-If you don not specify an output the files will end up in the top level of
your start-up drive
- The d bit - the 3 means - add the page number with 3 digits
All the commands are listed here
http://www.pdfhacks.com/pdftk/
Ian Cook
email@hidden
on 10/8/05 19:56, Mark J. Reed at email@hidden wrote:
> I recommend you install pdftk and use it (you can resort to "do shell
> script" from an AppleScript if you aren't comfortable with raw UNIX
> scripting).
>
> You can get pdftk here:
>
> http://www.accesspdf.com/article.php/20041130153545577
>
> If you'll browse around you'll see lots of horror stories about how
> hard it is to get pdftk to work on a Mac, involving downloading and
> building gcc from scrratch in order to get a version of gcj that you
> can use oto build pdftk . . . but that's old news. The page above has
> a link to a disk image with an installer for pdftk that just works (on
> Panther and 10.4.1, at least; not 10.4.0). Just use
>
> pdftk file.pdf burst
>
> And voila - one pdf file per page.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden