projectz

Tech, Gadgets, Photography, Social Media and Poor Spelling

Extracting pages from a pdf file using linux command line

This is one of those useful command line tricks which a sysadmin needs in the brains toolbox.

pdftk is a tool which we can use to split or extract pages from a pdf document.


To install pdfktk on debian based systems

sudo apt-get install pdftk
Let us say we have a pdf file,temp.pdf, with 100 pages in it. We want to extranct the pages 20 to 30 and create a new pdf . We can do it using pdftk

pdftk temp.pdf cat 20-30 output new.pdf 

If the command returns to the prompt with no errors, we will have a new pdf file in the same directory with the name new.pdf.

We can pick specific pages instead of a range by just passing the page numbers.

To create a new pdf by extracting pages 21,25, and 28 we can use.

pdftk temp.pdf cat 21 25 28 output new.pdf
We can also select only even/odd pages by passing the option even/odd respectively

To extract all the odd numbered pages we can use the range as 1-end and use the keyword odd.

pdftk temp.pdf cat 1-endodd

Source: http://tuxthink.blogspot.co.uk/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Information

This entry was posted on October 8, 2012 by in guides, Linux, Ubuntu and tagged , , , , , , , .
%d bloggers like this: