Extract Selected range of Pages of a PDF as a PDF File in Linux
You downloaded a PDF file and you are only interested in particular pages say 23-56 and the rest of it is useless for you, then you can use the GhostScript utility to extract these range of pages as a new PDF so you can save on size, and gain on reading confidence ( I hate books with huge no. of pages .. ) .
You can do this via this command
$ gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER \ -dFirstPage=22 -dLastPage=36 \ -sOutputFile=outfile_p22-p36.pdf 100p-inputfile.pdf
Remember to change the following params here
100p-inputfile.pdf Change it to your own input PDF file
-dFirstPage=22 Change it with your starting page range
-dLastPage=36 Change it to your range’s last page
-sOutputFile=pages22-36.pdf Change it to any arbitrary filename of your own
This is the easiest and the fastest method to achieve a page range extract as it uses the native GhostScript utility which is available in every distro of Unix/Linux Nowdays , so you can use it without installing any package or utility .
This can also be done with the pdftk tool, which should also be available in most distros. There is also a gui tool for pdftk available (although that has to be downloaded from a website).
I found this method to be much better, although a little cryptic for people who are not used to
Compared to pdftk, this doesn’t need any special packages installed. Pdftk package needs a lot of
java-based/-dependent packages to be installed. I say that’s a plus point.
Thanks for the tip.
You are welcome Incubus0h on our Blog, and yes that’s the very plus point with pdftk, hav’nt used it much but Liked the concept as it may come handy some day .
this method is much (,much!) faster than pdftk