Awhile back I wrote the article ‘OS X Command line Image Manipulation‘ which shows how to use the ’sips’ command to rasterize a PDF document into a PNG, JPG or any other image format file.
A reader then asked how to do this with a multi-page PDF document. From what I can tell, its not possible with the ’sips’ command by itself. However, a little poking around on the internet revealed another very useful command-line tool when dealing with PDF documents – ‘pdftk’.
http://www.accesspdf.com/pdftk/index.html
‘pdftk’ is an open source command line tool for manipulating PDF documents. In particular, it can extract the pages of a single PDF document into their own PDF document files.
By using ‘pdftk’ to extract each page into a its own PDF document file, we can now use ’sips’ to convert the files into our desired rasterized image format.
Installing ‘pdftk’
Easiest method is to download it from the web -
http://www.pdfhacks.com/pdftk/OSX-10.3/pdftk1.12_OSX10.3.dmg.gz
Note – I have not tried this version as I found the next method more to my liking…
Mac Ports
If you’re running Mac ports, you can install it via command line
sudo port install pdftk
This can take a *long* time if gcc needs to be built. Just be patient, it’ll finish eventually!
Using ‘pdftk’
Once installed, simply issue the command
pdftk multi-page.pdf burst
where multi-page.pdf contains the pages you want extracted. This will result in each page being written as its own PDF document in your current working directory. The filenames will be ‘pg_000x.pdf’ where x is the page number.
Integrating with ’sips’ at this point is trivial, as you can customize the output file naming scheme of pdftk to whatever you need.
Posted by mcoopet 

Posted by mcoopet 
Posted by mcoopet 
