Lubos Rendek

The only solution is determination.

Remove Pages From PDF Document Using PDF Toolkit

| Comments

The task of removing/excluding pages from the PDF document is a easy task with tool such as PDF toolkit ( pdftk ) in our hands. Suppose that our document has 51 pages. To see number of pages of your PDF document use pdfinfo command:

1
2
3
4
5
6
7
8
9
10
11
12
13
$ pdfinfo mydocument.pdf 
Title:          slides.dvi
Creator:        dvips(k) 5.98 Copyright 2009 Radical Eye Software
Producer:       GPL Ghostscript 9.05
CreationDate:   Mon Mar  4 11:13:36 2013
ModDate:        Mon Mar  4 11:13:36 2013
Tagged:         no
Pages:          51
Encrypted:      no
Page size:      595 x 842 pts (A4)
File size:      1729446 bytes
Optimized:      no
PDF version:    1.4

Now suppose we want to remove page 21. To do that we use pdftk command:

1
pdftk mydocument.pdf cat 1-20 22-end output newdocument.pdf

The above command will output only page 1-20 and pages 22-51 and thus leaving page 21 out. Similarly the same can be achieved when removing multiple pages. In the next example we are going to remove pages 15,16,17,20.

1
pdftk mydocument.pdf cat 1-14 18-19 21-end output newdocument.pdf

The same principle can applied when need to extract a single page from the entire document. Let’s say we need to extract page 20. The do that we use command:

1
pdftk mydocument.pdf cat 20 output newdocument.pdf

Comments