Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Do you have any idea how to extract a part of a PDF document and save it as PDF? On OS X it is absolutely trivial by using Preview. I tried PDF editor and other programs but to no avail.

I would like a program where I select the part that I want and then save it as pdf with a simple command like CMD+N on OS X. I want the extracted part to be saved in PDF format and not jpeg etc.

share|improve this question
Did you try ImageMagick? –  Martin Schröder Nov 26 '12 at 7:51
That's for bitmap I need something that saves as PDF! –  user72469 Nov 27 '12 at 6:18
pdfshuffler in the repos. –  Marc Mar 6 '14 at 23:44

11 Answers 11

pdftk is a useful multi-platform tool for that (pdftk homepage).

pdftk A=full-pdf.pdf cat A12-15 output outfile_p12-15.pdf

you pass the filename of the main pdf to a variable, e.g. A, the you tell it to only include certain pages (12-15 in this example) and output it to a new file.

share|improve this answer
+1, but as per Andrzej's answer this can be simplified to pdftk full-pdf.pdf cat 12-15 output outfile_p12-15.pdf. No need for the variable. –  Sparhawk Feb 18 at 1:55

very Simple, use default PDF reader :

print as file. that is it! print menu


setting new PDF

share|improve this answer
flippin brilliant –  andybleaden Dec 22 '14 at 17:28
Produces catastrophic results with beamer files, maps and any other documents that do not conform with the printer page format. –  Luís de Sousa Jan 13 at 13:48
@LuísdeSousa Just set the correct format under "Page Setup" –  Юнгвирт Тони Jan 28 at 19:26

Page range - Nautilus script


I created a slightly more advanced script based on the tutorial @ThiagoPonte linked to. Its key features are

  • that it's GUI based,
  • compatible with spaces in file names,
  • and that it preserves all PDF attributes including image compression levels


enter image description here


# TITLE:        PDFextract v. 0.1 by MHC (http://askubuntu.com/users/81372/mhc)
# LICENSE:      GNU GPL v3 (http://www.gnu.org/licenses/gpl.html)
# DESCRIPTION:  PDFextract is a simple PDF extraction script based on Ghostscript which allows you to extract
#               a page range of your choice from a PDF document. In contrast to other scripts PDFextract preserves 
#               _all_ attributes of your original PDF file and does not compress embedded images further 
#               than they are. PDFextract comes with a simple GUI based on YAD, an advanced Zenity fork.
#               This script was inspired by Kurt Pfeifle's PDF extraction script 
#               (http://www.linuxjournal.com/content/tech-tip-extract-pages-pdf)
# DEPENDENCIES: ghostscript,poppler-utils,yad,notify-send
# NOTES:        If you are running Ubuntu you can install YAD from the webupd8 PPA via
#               sudo add-apt-repository ppa:webupd8team/y-ppa-manager && sudo apt-get update && sudo apt-get install yad
# USAGE:        Move the script to your file manager's script directory and make it executable 
#               ($HOME/.gnome2/nautilus-scripts for Nautilus)


gs -dFirstPage=$1 -dLastPage=$2 -sOutputFile="${3%.pdf}_p${1}-p${2}.pdf" -dSAFER -dNOPAUSE -dBATCH -dPDFSETTING=/default -sDEVICE=pdfwrite -dCompressFonts=true -c \
".setpdfwrite << /EncodeColorImages true /DownsampleMonoImages false /SubsetFonts true /ASCII85EncodePages false /DefaultRenderingIntent /Default /ColorConversionStrategy \
/LeaveColorUnchanged /MonoImageDownsampleThreshold 1.5 /ColorACSImageDict << /VSamples [ 1 1 1 1 ] /HSamples [ 1 1 1 1 ] /QFactor 0.4 /Blend 1 >> /GrayACSImageDict \
<< /VSamples [ 1 1 1 1 ] /HSamples [ 1 1 1 1 ] /QFactor 0.4 /Blend 1 >> /PreserveOverprintSettings false /MonoImageResolution 300 /MonoImageFilter /FlateEncode \
/GrayImageResolution 300 /LockDistillerParams false /EncodeGrayImages true /MaxSubsetPCT 100 /GrayImageDict << /VSamples [ 1 1 1 1 ] /HSamples [ 1 1 1 1 ] /QFactor \
0.4 /Blend 1 >> /ColorImageFilter /FlateEncode /EmbedAllFonts true /UCRandBGInfo /Remove /AutoRotatePages /PageByPage /ColorImageResolution 300 /ColorImageDict << \
/VSamples [ 1 1 1 1 ] /HSamples [ 1 1 1 1 ] /QFactor 0.4 /Blend 1 >> /CompatibilityLevel 1.4 /EncodeMonoImages true /GrayImageDownsampleThreshold 1.5 \
/AutoFilterGrayImages false /GrayImageFilter /FlateEncode /DownsampleGrayImages false /AutoFilterColorImages false /DownsampleColorImages false /CompressPages true \
/ColorImageDownsampleThreshold 1.5 /PreserveHalftoneInfo false >> setdistillerparams" -f "$3"

PAGECOUNT=$(pdfinfo "$DOCUMENT" | grep Pages | sed 's/[^0-9]*//') #determine page count

SETTINGS=($(yad --window-icon application-pdf --image application-pdf --width 300 --form --separator=" " --title="PDFextract" --text \
    "Please choose the page range" --field="Start:NUM" 1[!1..$PAGECOUNT[!1]] --field="End:NUM" $PAGECOUNT[!1..$PAGECOUNT[!1]] \
    --button="gtk-ok:0" --button="gtk-cancel:1"))

RET=$? #Save return value

STARTPAGE=$(printf %.0f ${SETTINGS[0]}) #round numbers and store array in variables
STOPPAGE=$(printf %.0f ${SETTINGS[1]})



#Analyze return value
if [[ $RET = 0 ]] #Did the user click on OK? if so
      if [ $STARTPAGE -gt $STOPPAGE ] # check for errors in the input
        then #there are errors
            yad --image dialog-warning --title "PDFExtract Warning" --button="Try again:0" --text "<b>   Start page higher than stop page.   </b>"
            runjob $DOCUMENT # let the user correct the input
        else #if there are no errors
            gsconverter $STARTPAGE $STOPPAGE "$DOCUMENT" #extract pages
            RET=$? #store return value
            if [ $RET = 0 ] #check for errors and notify the user
                  notify-send -i application-pdf "PDFextract" "Pages $STARTPAGE to $STOPPAGE succesfully extracted."
                  notify-send -i application-pdf "PDFextract" "There was an error. Please check the CLI output."
  else #if not
      exit 1 #exit script

runjob "$DOCUMENT"


Installation instructions can be found here:

How can I install a Nautilus script?

All dependencies are listed above.

Partial pages - PDF Shuffler


PDF-Shuffler is a small python-gtk application, which helps the user to merge or split pdf documents and rotate, crop and rearrange their pages using an interactive and intuitive graphical interface. It is a frontend for python-pyPdf.


sudo apt-get install pdfshuffler


PDF-Shuffler can crop and delete single PDF pages. You can use it to extract a page range from a document or even partial pages using the cropping function:

enter image description here

Page elements - Inkscape


Inkscape is a very powerful open-source vector graphics editor. It supports a wide range of different formats, including PDF files. You can use it to extract, modify and save page elements from a PDF file.


sudo apt-get install inkscape


1.) Open the PDF file of your choice with Inkscape. An import dialog will appear. Choose the page you want to extract elements from. Leave the other settings as they are:

enter image description here

2.) In Inkscape click and drag to select the element(s) you want to extract:

enter image description here

3.) Invert the selection with ! and delete the selected object with DELETE:

enter image description here

4.) Crop the document to the remaining objects by accessing the Document Properties dialog with CTRL+SHIFT+D and selecting "fit document to image":

enter image description here

5.) Save the document as a PDF file from the File --> Save as dialog:

6.) If there are bitmap/raster images in your cropped document you can set their DPI in the dialog that appears next:

enter image description here

7.) If you followed all steps you will have produced a true PDF file that only consists of the objects of your choice:

enter image description here

share|improve this answer
Great effort. Thanks! I understand that it does not allow to select a portion of a page, but only whole pages. Am I right? –  carnendil Apr 17 '13 at 23:36
@carnendil : Yes, exactly. I don't think ghostscript is capable of that. But there might be other solutions out there to do this programmatically. For now I have edited my answer with an alternate (and a bit hackish) solution using PDF-shuffler. –  Glutanimate Apr 18 '13 at 5:11
ok, I've added a different method using Inkscape. –  Glutanimate Apr 18 '13 at 6:13
awesome contribution –  Sascha Gottfried Jan 9 at 16:47

Save this as a shell script, like pdfextractor.sh:

# this function uses 3 arguments:
#     $1 is the first page of the range to extract
#     $2 is the last page of the range to extract
#     $3 is the input file
#     output file will be named "inputfile_pXX-pYY.pdf"
gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER \
   -dFirstPage=${1} \
   -dLastPage=${2} \
   -sOutputFile=${3%.pdf}_p${1}-p${2}.pdf \

To run type:

./pdfextractor.sh 4 20 myfile.pdf

1)4 refers to the page it will start the new pdf.

2)20 refers to the page it will end the pdf with.

3)myfile.pdf is the pdf file you want to extract parts.

The output would be myfile_p4_p20.pdf in the same directory the original pdf file.

All this and more information here: Tech Tip

share|improve this answer

pdftk (sudo apt-get install pdftk) is a great command line too for PDF manipulation. Here are some examples of what pdftk can do:

   Collate scanned pages
     pdftk A=even.pdf B=odd.pdf shuffle A B output collated.pdf
     or if odd.pdf is in reverse order:
     pdftk A=even.pdf B=odd.pdf shuffle A Bend-1 output collated.pdf

   Join in1.pdf and in2.pdf into a new PDF, out1.pdf
     pdftk in1.pdf in2.pdf cat output out1.pdf
     or (using handles):
     pdftk A=in1.pdf B=in2.pdf cat A B output out1.pdf
     or (using wildcards):
     pdftk *.pdf cat output combined.pdf

   Remove page 13 from in1.pdf to create out1.pdf
     pdftk in.pdf cat 1-12 14-end output out1.pdf
     pdftk A=in1.pdf cat A1-12 A14-end output out1.pdf

   Burst a single PDF document into pages and dump its data to
     pdftk in.pdf burst

   Rotate the first PDF page to 90 degrees clockwise
     pdftk in.pdf cat 1east 2-end output out.pdf

   Rotate an entire PDF document to 180 degrees
     pdftk in.pdf cat 1-endsouth output out.pdf

In your case, I would do:

     pdftk A=input.pdf cat A<page_range> output output.pdf
share|improve this answer

Have you tried PDF Mod?

You can for example.. extract pages and save them as pdf.


PDF Mod is a simple tool for modifying PDF documents. It can rotate, extract, remove
and reorder pages via drag and drop. Multiple documents may be combined via drag
and drop. You may also edit the title, subject, author and keywords of a PDF
document using PDF Mod.

Install via the software center

Hope this will useful.


share|improve this answer
YES, I actually did try it but it does NOT allow me to save part of a page e.g. a plot as pdf... Unless I dont see the option. It allows me to extract a whole page from a document but that is not what I want –  user72469 Nov 26 '12 at 2:21

As it turns out, I can do it with imagemagick. If you don't have it, install simply with:

sudo apt-get install imagemagick

Note 1: I've tried this with a one-page pdf (I'm learning to use imagemagick, so I didn't want more trouble than necessary). I don't know if/how it will work with multiple pages, but you can extract one page of interest with pdftk:

pdftk A=myfile.pdf cat A1 output page1.pdf

where you indicate the page number to be split out (in the example above, A1 selects the first page).

Note 2: The resulting image using this procedure will be a raster.

Open the pdf with the command display, which is part of the imagemagick suite:

display file.pdf

Mine looked like this:

imagemagick display of a pdf
Click on the image to see a full resolution version

Now you click on the window and a menu will pop to the side. There, select Transform | Crop.

imagemagick transform>crop menu

Back in the main window, you can select the area you want to crop by simply dragging the pointer (classic corner-to-corner selection).

selection of area to crop
Notice the hand-shaped pointer around the image while selecting

This selection can be refined before proceeding to the next step.

EDIT: Once you are done, take notice of the little rectangle that appears on the upper left corner (see the image above). It shows the dimensions of the area selected first (e.g. 281x218) and second the coordinates of the first corner (e.g. +256+215).

Write down the dimensions of the selected area; you'll need it at the moment of saving the cropped image.

Now, back at the pop menu (which now is the specific "crop" menu), click the button Crop.

imagemagick crop menu

Finally, once you are satisfied with the results of cropping, click on menu File | Save

Navigate to the folder where you want to save the cropped pdf, type a name, click the button Format, on the "Select image format type" window select PDF and click the button Select. Back on the "Browse and select a file" window, click the button Save.

imagemagick save as pdf

EDIT: Before saving, imagemagick will ask to "select page geometry". Here, you type the dimensions of your cropped image, using a simple letter "x" to separate width and height.

imagemagick select page geometry

Now, you can do all this perfectly from the command line (the command is convert with option -crop) -- surely it's faster, but you would have to know beforehand the coordinates of the image you want to extract. Check man convert and an example in their webpage.

share|improve this answer
DIdn't know about imagemagick's GUI. Looks interesting. However, please correct me if I'm wrong but I think imagemagick can't handle vectorized images. So what you're exporting is likely going to be a raster/bitmap image only. In that case this method is the same as taking taking a screenshot of a region of the document. –  Glutanimate Apr 19 '13 at 8:23
Indeed, imagemagick works only raster images, and display is just one command of the suite. There are plenty of interfaces for imagemagick -- check their webpage. For vector images the best solution is, I think, your method with Inkscape. –  carnendil Apr 19 '13 at 15:00
You might want to add a disclaimer at the top of the answer as a caution that this will convert from vector to raster graphics. This property makes it a fundamentally different approach. –  bluenote10 Jul 9 '14 at 15:10

pDF Split and Merge is quite useful for this and other PDF manipulation operations.

Download from here

share|improve this answer
You can download the latest version from the link above, but if you prefer the convenience of the Software Center, you can also install it from there (or from the terminal, through sudo apt-get install pdfsam). However, the version in Ubuntu is quite outdated, as it's still in version 1.1.4 whereas the sourceforge version is already 2.2.2. –  Waldir Leoncio Feb 14 '14 at 18:00

There is a command line utility called pdfseparate.

From the docs:

pdfseparate sample.pdf sample-%d.pdf

extracts  all pages from sample.pdf, if i.e. sample.pdf has 3 pages, it

sample-1.pdf, sample-2.pdf, sample-3.pdf

Or, to select a single page (in this case, the first page) from the file sample.pdf:

pdfseparate -f 1 -l 1 sample.pdf sample-1.pdf
share|improve this answer

You can use rpdf split to merge and modify PDF documents in general. Alternatively there's an online service to do this

To download the rpdf split software please click here

share|improve this answer

If you want to extract from your PDFs, you can use http://www.sumnotes.net. It's an amazing tool to extract notes, highlights, and images from PDFs. You can also watch tutorials on Youtube by typing sumnotes.

I hope you will enjoy it!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.