My Blog has moved to Github Pages

Tuesday 14 December 2010

Splitting pdf's using pdftk

Found a nice command-line tool for hacking around with pdf's: pdftk (pdf toolkit).

Installation in ubuntu is typically easy: sudo apt-get install pdftk

I couldn't find a lot of documentation, although there is a book by the author of pdftk (the book doesn't exclusively cover pdftk).

I only wanted to split a multi-page pdf into multiple separate pages, so one of the examples on that site did it for me...

pdftk A=mypdf.pdf cat A1 output page1.pdf
pdftk A=mypdf.pdf cat A2 output page2.pdf
... etc

2 comments:

  1. I tried using pdftk to split a multi-page PDF once. It was very easy and convenient to use, but missed some important features I needed, for example specifying the number of digits in the name (Page01 or Page1), split all at the same time and give a specific naming to each page... I managed to do all these stuff using Ghostscript. It's a bit more complex to use but has powerful features and is nicely fast. Try this command for example:

    gs -dBATCH -dNOPAUSE -dSAFER -sDEVICE=jpeg -dJPEGQ=100 -r100x100 -sOutputFile=Page%02d.jpg "%f"

    p.s.: used this in an acquisition ;)

    ReplyDelete
  2. Nice, thanks Emile, i'll try ghostscript :)

    Re: pdftk, I also wanted "split all at the same time" but couldn't see a way to express it. I have a feeling that pdftk can do a lot more than I could figure out, just the documentation is lacking.

    ReplyDelete