views:

59

answers:

3

Hi,

I have a bunch of pdf documents and all of them contain a title page that I want to remove. Is there a way to programmatically remove them? Most of the pdf utilities I found can only combine documents but not remove pages. In the print dialog I can choose page 2 to and then print to a file, but I can't find anyway to access this function programmatically.

Thanks!!

+1  A: 

Hello!

Use pdftk.

To remove page 8:

pdftk in.pdf cat 1-7 9-end output out.pdf
Benoit
that's easy, thanks!
ceiling cat
Btw, in case anyone else is also too lazy to figure out how to build pdftk (macport is still having problem with gcc42), here is a binaryhttp://fredericiana.com/2010/03/01/pdftk-1-41-for-mac-os-x-10-6/
ceiling cat
A: 

-[PDFDocument removePageAtIndex:] looks like it should make this possible. By the way, Preview.app can remove a page, but it isn't scriptable, so that's not a programmatic solution.

JWWalker
A: 

Just for the record: you can also use Ghostscript:

gs \
  -o removed-page-1-from-input.pdf \
  -sDEVICE=pdfwrite \
  -dFirstPage=2 \
  /path/to/input.pdf

However, pdftk is the better tool for that job (and was already recommended to you).

Also, this Ghostscript commandline could change some of the properties in your input.pdf because it essentially re-distills it. This could be a desired change or not. To control individual aspects of this behavior (or to suppress some of them), a more complicated commandline with more parameters is required.

pdftk will re-use the original PDF objects for each page as-is.

pipitas