How can I extract a page range / a part of a PDF?












365















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






  • 3





    That's for bitmap I need something that saves as PDF!

    – user72469
    Nov 27 '12 at 6:18






  • 3





    pdfshuffler in the repos.

    – Marc
    Mar 6 '14 at 23:44






  • 1





    pdfshuffler doen't work anymore in Ubuntu 14.04+. You can always use the print dialog or a terminal based alternative like pdfseparate

    – Rho
    Mar 7 '16 at 20:00











  • @Rho The version directly installed via apt-get still works fine for me in 16.04. Maybe they fixed the bugs, if there were some?

    – xji
    Feb 15 '17 at 16:48
















365















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






  • 3





    That's for bitmap I need something that saves as PDF!

    – user72469
    Nov 27 '12 at 6:18






  • 3





    pdfshuffler in the repos.

    – Marc
    Mar 6 '14 at 23:44






  • 1





    pdfshuffler doen't work anymore in Ubuntu 14.04+. You can always use the print dialog or a terminal based alternative like pdfseparate

    – Rho
    Mar 7 '16 at 20:00











  • @Rho The version directly installed via apt-get still works fine for me in 16.04. Maybe they fixed the bugs, if there were some?

    – xji
    Feb 15 '17 at 16:48














365












365








365


111






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
















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.







pdf






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 3 '14 at 18:55









Braiam

52.1k20136222




52.1k20136222










asked Nov 26 '12 at 2:06









user72469user72469

1,829393




1,829393













  • Did you try ImageMagick?

    – Martin Schröder
    Nov 26 '12 at 7:51






  • 3





    That's for bitmap I need something that saves as PDF!

    – user72469
    Nov 27 '12 at 6:18






  • 3





    pdfshuffler in the repos.

    – Marc
    Mar 6 '14 at 23:44






  • 1





    pdfshuffler doen't work anymore in Ubuntu 14.04+. You can always use the print dialog or a terminal based alternative like pdfseparate

    – Rho
    Mar 7 '16 at 20:00











  • @Rho The version directly installed via apt-get still works fine for me in 16.04. Maybe they fixed the bugs, if there were some?

    – xji
    Feb 15 '17 at 16:48



















  • Did you try ImageMagick?

    – Martin Schröder
    Nov 26 '12 at 7:51






  • 3





    That's for bitmap I need something that saves as PDF!

    – user72469
    Nov 27 '12 at 6:18






  • 3





    pdfshuffler in the repos.

    – Marc
    Mar 6 '14 at 23:44






  • 1





    pdfshuffler doen't work anymore in Ubuntu 14.04+. You can always use the print dialog or a terminal based alternative like pdfseparate

    – Rho
    Mar 7 '16 at 20:00











  • @Rho The version directly installed via apt-get still works fine for me in 16.04. Maybe they fixed the bugs, if there were some?

    – xji
    Feb 15 '17 at 16:48

















Did you try ImageMagick?

– Martin Schröder
Nov 26 '12 at 7:51





Did you try ImageMagick?

– Martin Schröder
Nov 26 '12 at 7:51




3




3





That's for bitmap I need something that saves as PDF!

– user72469
Nov 27 '12 at 6:18





That's for bitmap I need something that saves as PDF!

– user72469
Nov 27 '12 at 6:18




3




3





pdfshuffler in the repos.

– Marc
Mar 6 '14 at 23:44





pdfshuffler in the repos.

– Marc
Mar 6 '14 at 23:44




1




1





pdfshuffler doen't work anymore in Ubuntu 14.04+. You can always use the print dialog or a terminal based alternative like pdfseparate

– Rho
Mar 7 '16 at 20:00





pdfshuffler doen't work anymore in Ubuntu 14.04+. You can always use the print dialog or a terminal based alternative like pdfseparate

– Rho
Mar 7 '16 at 20:00













@Rho The version directly installed via apt-get still works fine for me in 16.04. Maybe they fixed the bugs, if there were some?

– xji
Feb 15 '17 at 16:48





@Rho The version directly installed via apt-get still works fine for me in 16.04. Maybe they fixed the bugs, if there were some?

– xji
Feb 15 '17 at 16:48










15 Answers
15






active

oldest

votes


















406














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



pdftk full-pdf.pdf cat 12-15 output outfile_p12-15.pdf


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






share|improve this answer





















  • 4





    If I want to extract pages 1-10, 15, and 17, how do I write the command?

    – Patrick Li
    Oct 12 '16 at 8:26






  • 24





    @PatrickLi pdftk A=in.pdf cat A1-10 A15 A17 output out.pdf

    – m8mble
    Oct 28 '16 at 12:06






  • 6





    Note that pdftk is not available in Ubuntu 18.04. (see askubuntu.com/questions/1028522/…)

    – alkamid
    Jun 30 '18 at 12:05






  • 6





    @alkamid it is: sudo snap install pdftk

    – Qubix
    Sep 23 '18 at 18:51






  • 5





    Although pdftk is certainly a tool that can do the job, I would recommend against it. This is not free software, but an clunky piece of shareware. Also it needs the JVM. A more reasonable tool is qpdf, as suggested in another answer.

    – leftaroundabout
    Nov 13 '18 at 13:11



















221














very Simple, use default PDF reader :



print as file. that is it!
print menu



then



setting new PDF






share|improve this answer



















  • 12





    flippin brilliant

    – andybleaden
    Dec 22 '14 at 17:28






  • 14





    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 '15 at 13:48








  • 9





    This can result in file with a much larger size than the original document.

    – dat
    Dec 8 '15 at 17:06






  • 7





    so it does not "extract" the page range. It creates a new pdf from the old one, as if you used high-definition printer/scanner pair.

    – sylvainulg
    Aug 11 '16 at 9:36






  • 6





    Good for simple cases, but undesired results in documents with highlighting comments: the highlighting becomes 100% opacity and blocks the text.

    – loved.by.Jesus
    Oct 16 '16 at 20:30



















72














Page range - Nautilus script





Overview



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 based on three different backends that are capable of preserving all attributes of the original file


Screenshot



enter image description here



Code



#!/bin/bash
#
# TITLE: PDFextract
#
# AUTHOR: (c) 2013-2015 Glutanimate (https://github.com/Glutanimate)
#
# VERSION: 0.2
#
# LICENSE: GNU GPL v3 (http://www.gnu.org/licenses/gpl.html)
#
# OVERVIEW: PDFextract is a simple PDF extraction script based on Ghostscript/qpdf/cpdf.
# It provides a simple way to extract a page range from a PDF document and is meant
# to be used as a file manager script/addon (e.g. Nautilus script).
#
# FEATURES: - simple GUI based on YAD, an advanced Zenity fork.
# - preserves _all_ attributes of your original PDF file and does not compress
# embedded images further than they are.
# - can choose from three different backends: ghostscript, qpdf, cpdf
#
# DEPENDENCIES: ghostscript/qpdf/cpdf poppler-utils yad libnotify-bin
#
# You need to install at least one of the three backends supported by this script.
#
# - ghostscript, qpdf, poppler-utils, and libnotify-bin are available via
# the standard Ubuntu repositories
# - cpdf is a commercial CLI PDF toolkit that is free for personal use.
# It can be downloaded here: https://github.com/coherentgraphics/cpdf-binaries
# - yad can be installed from the webupd8 PPA with the following command:
# sudo add-apt-repository ppa:webupd8team/y-ppa-manager && apt-get update && apt-get install yad
#
# NOTES: Here is a quick comparison of the advantages and disadvantages of each backend:
#
# speed metadata preservation content preservation license
# ghostscript: -- ++ ++ open-source
# cpdf: - ++ ++ proprietary
# qpdf: ++ + ++ open-source
#
# Results might vary depending on the document and the version of the tool in question.
#
# INSTALLATION: https://askubuntu.com/a/236415
#
# This script was inspired by Kurt Pfeifle's PDF extraction script
# (http://www.linuxjournal.com/content/tech-tip-extract-pages-pdf)
#
# Originally posted on askubuntu
# (https://askubuntu.com/a/282453)

# Variables

DOCUMENT="$1"
BACKENDSELECTION="^qpdf!ghostscript!cpdf"

# Functions

check_input(){
if [[ -z "$1" ]]; then
notify "Error: No input file selected."
exit 1
elif [[ ! "$(file -ib "$1")" == *application/pdf* ]]; then
notify "Error: Not a valid PDF file."
exit 1
fi
}

check_deps () {
for i in "$@"; do
type "$i" > /dev/null 2>&1
if [[ "$?" != "0" ]]; then
MissingDeps+="$i"
fi
done
}

ghostscriptextract(){
gs -dFirstPage="$STARTPAGE "-dLastPage="$STOPPAGE" -sOutputFile="$OUTFILE" -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.7 /EncodeMonoImages true /GrayImageDownsampleThreshold 1.5
/AutoFilterGrayImages false /GrayImageFilter /FlateEncode /DownsampleGrayImages false /AutoFilterColorImages false /DownsampleColorImages false /CompressPages true
/ColorImageDownsampleThreshold 1.5 /PreserveHalftoneInfo false >> setdistillerparams" -f "$DOCUMENT"
}

cpdfextract(){
cpdf "$DOCUMENT" "$STARTPAGE-$STOPPAGE" -o "$OUTFILE"
}

qpdfextract(){
qpdf --linearize "$DOCUMENT" --pages "$DOCUMENT" "$STARTPAGE-$STOPPAGE" -- "$OUTFILE"
echo "$OUTFILE"
return 0 # even benign qpdf warnings produce error codes, so we suppress them
}

notify(){
echo "$1"
notify-send -i application-pdf "PDFextract" "$1"
}

dialog_warning(){
echo "$1"
yad --center --image dialog-warning
--title "PDFExtract Warning"
--text "$1"
--button="Try again:0"
--button="Exit:1"

[[ "$?" != "0" ]] && exit 0
}

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

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

SETTINGSRET="$?"

[[ "$SETTINGSRET" != "0" ]] && exit 1

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

check_deps "$BACKEND"

if [[ -n "$MissingDeps" ]]; then
dialog_warning "Error, missing dependency: $MissingDeps"
unset MissingDeps
dialog_settings
return
fi

if [[ "$STARTPAGE" -gt "$STOPPAGE" ]]; then
dialog_warning "<b> Start page higher than stop page. </b>"
dialog_settings
return
fi

OUTFILE="${DOCUMENT%.pdf} (p${STARTPAGE}-p${STOPPAGE}).pdf"
}

extract_pages(){
$EXTRACTOR
EXTRACTORRET="$?"
if [[ "$EXTRACTORRET" = "0" ]]; then
notify "Pages $STARTPAGE to $STOPPAGE succesfully extracted."
else
notify "There has been an error. Please check the CLI output."
fi
}


# Main

check_input "$1"
dialog_settings
extract_pages


Installation



Please follow the generic installation instructions for Nautilus scripts. Make sure to read the script header carefully as it will help to clarify the installation and usage of the script.





Partial pages - PDF Shuffler





Overview




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.




Installation



sudo apt-get install pdfshuffler


Usage



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





Overview



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.



Installation



sudo apt-get install inkscape


Usage



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








  • 2





    @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








  • 3





    ok, I've added a different method using Inkscape.

    – Glutanimate
    Apr 18 '13 at 6:13






  • 1





    pdfshuffler is not sufficient if you want to extract a part of the PDF page. The original PDF data of the page is still preserved in the file. Do not use this method if you want to remove sensitive data from a PDF file.

    – Rob W
    Nov 7 '15 at 11:48



















40














QPDF is great. Use it this way to extract pages 1-10 from input.pdf and save it as output.pdf.



qpdf --pages input.pdf 1-10 -- input.pdf output.pdf


Please note that input.pdf is written twice.



You can install it by invoking:



apt-get install qpdf


Or, by going to Ubuntu apps directory:



Install via the software center



It is a great tool for PDF manipulation, which is very fast, has very few dependencies. "It can encrypt and linearize files, expose the internals of a PDF file, and do many other operations useful to end users and PDF developers."



http://sourceforge.net/projects/qpdf/






share|improve this answer





















  • 2





    The only problem I had with this is that is still lists all the pages in the table of contents, despite most being removed. Apart from, brilliant thanks! :)

    – Wilf
    Nov 10 '15 at 14:24






  • 2





    Great software. Nice

    – Anwar
    Aug 4 '16 at 11:42






  • 1





    Warning - Files are all huge..about the same size as the original.

    – Corey Alix
    Nov 27 '18 at 0:50











  • One of the best options, since qpdf is robust and doesn't alter (downsample images etc.) the contents of the PDF file.

    – rbrito
    Nov 29 '18 at 7:52











  • Works, but that syntax for specifying the pages (listing the input file twice, then adding --) is really weird.

    – Dan Dascalescu
    Feb 23 at 1:43



















35














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



#!/bin/bash
# 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
${3}


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



















  • 12





    Let's keep it simple: gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dFirstPage=1 -dLastPage=10 -sOutputFile=output.pdf input.pdf

    – Ho1
    Sep 9 '15 at 7:14













  • and How do I specify input file?

    – Anwar
    Aug 4 '16 at 10:53






  • 1





    -1 for doing bash parameter expansion outside double-quoted string. (should be "-sOutputFile=${3%.pdf}_p${1}-p${2}.pdf" etc. (note the quotes)).

    – Rotsor
    Jan 21 '17 at 16:16













  • @Ho1 please write it as a new answer, it really helps!

    – Joshua Salazar
    Oct 3 '18 at 18:36



















22














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
produces

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



















  • 2





    great tool! much faster than pdftk

    – Anwar
    Apr 8 '15 at 5:57






  • 3





    Good, but it is only limited to one page, and if you want more than that, you will get separate pages.

    – Ho1
    Sep 9 '15 at 7:19






  • 2





    Sure, though one can follow the above command with pdfunite to produce a single document.

    – jdmcbr
    Sep 9 '15 at 15:22






  • 3





    If you have a huge document and need to split all pages, it is really fast and useful.

    – MEDVIS
    Apr 27 '16 at 10:32



















19














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
or:
pdftk A=in1.pdf cat A1-12 A14-end output out1.pdf

Burst a single PDF document into pages and dump its data to
doc_data.txt
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
























  • Package 'pdftk' has no installation candidate

    – FireInTheSky
    Oct 21 '18 at 3:02



















15














In any system that a TeX distribution is installed:



pdfjam <input file> <page ranges> -o <output file>


For example:



pdfjam original.pdf 5-10 -o out.pdf


See https://tex.stackexchange.com/a/79626/8666






share|improve this answer
























  • this was the only one that worked for me .

    – FireInTheSky
    Oct 21 '18 at 3:12



















7














Have you tried PDF Mod?



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



Description:



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.



Regars.






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











  • I use it regularly, great tool! but I had a document with about 170 pages that pdfmod could not handle.

    – loved.by.Jesus
    Oct 16 '16 at 20:54











  • Wow. This is surprisingly smooth. Threw my 512 page real book at it (50MiB) and it... was prompt. UI is a breeze. For a CLI junkie like me it takes some level of GUI to convince me, but this will do!

    – sehe
    Oct 12 '17 at 6:50











  • PDF Mod has bugs running in Kubuntu 18

    – Joshua Salazar
    Oct 3 '18 at 18:37



















7














I was trying to do the same. All you have to do is:





  1. install pdftk:



    sudo apt-get install pdftk



  2. if you want to extract random pages:



    pdftk myoldfile.pdf cat 1 2 4 5 output mynewfile.pdf



  3. if you want to extract a range:



    pdftk myoldfile.pdf cat 1-2 4-5 output mynewfile.pdf



Please check the source for more infos.






share|improve this answer


























  • I find this answer best because it shows how you can input multiple ranges.

    – Roman Luštrik
    Nov 7 '18 at 8:41



















6














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.



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



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






  • 1





    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






  • 2





    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



















2














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



Download from here






share|improve this answer





















  • 1





    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











  • The latest 3.x (currently 3.1.0) has a .deb package that can be installed on Ubuntu and has an Extract Pages module that does what the OP asked

    – Andrea Vacondio
    Aug 6 '16 at 8:25






  • 1





    @Andrea Vacondio Bravo for your excellent edit! You're helping to make the internet safe. I found out that the file from the old link at sourceforge.net has crap embedded in it . The new owners of the SourceForge website said they were going to stop doing this, but obviously they lied.

    – karel
    Aug 6 '16 at 8:41





















2














As the original user asked for an interactive tool and not a command line tool: An easy solution is to use any PDF viewer (okular on Kubuntu, evince or even Firefox on Ubuntu) and then just use the standard print dialog, choose "print to PDF file", and then select in the extended settings dialog, which pages to "print". This variant has some drawbacks, as some gimmicks on the original PDF (like rotated pages, forms etc.) might get lost, but it works straightforward for most simple PDFs.






share|improve this answer































    0














    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

































      0














      Found this tool and am quite happy with it: https://pdf.io/split/






      share|improve this answer








      New contributor




      YakovK is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















        Your Answer








        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "89"
        };
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function() {
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled) {
        StackExchange.using("snippets", function() {
        createEditor();
        });
        }
        else {
        createEditor();
        }
        });

        function createEditor() {
        StackExchange.prepareEditor({
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader: {
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        },
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        });


        }
        });














        draft saved

        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f221962%2fhow-can-i-extract-a-page-range-a-part-of-a-pdf%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        15 Answers
        15






        active

        oldest

        votes








        15 Answers
        15






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        406














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



        pdftk full-pdf.pdf cat 12-15 output outfile_p12-15.pdf


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






        share|improve this answer





















        • 4





          If I want to extract pages 1-10, 15, and 17, how do I write the command?

          – Patrick Li
          Oct 12 '16 at 8:26






        • 24





          @PatrickLi pdftk A=in.pdf cat A1-10 A15 A17 output out.pdf

          – m8mble
          Oct 28 '16 at 12:06






        • 6





          Note that pdftk is not available in Ubuntu 18.04. (see askubuntu.com/questions/1028522/…)

          – alkamid
          Jun 30 '18 at 12:05






        • 6





          @alkamid it is: sudo snap install pdftk

          – Qubix
          Sep 23 '18 at 18:51






        • 5





          Although pdftk is certainly a tool that can do the job, I would recommend against it. This is not free software, but an clunky piece of shareware. Also it needs the JVM. A more reasonable tool is qpdf, as suggested in another answer.

          – leftaroundabout
          Nov 13 '18 at 13:11
















        406














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



        pdftk full-pdf.pdf cat 12-15 output outfile_p12-15.pdf


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






        share|improve this answer





















        • 4





          If I want to extract pages 1-10, 15, and 17, how do I write the command?

          – Patrick Li
          Oct 12 '16 at 8:26






        • 24





          @PatrickLi pdftk A=in.pdf cat A1-10 A15 A17 output out.pdf

          – m8mble
          Oct 28 '16 at 12:06






        • 6





          Note that pdftk is not available in Ubuntu 18.04. (see askubuntu.com/questions/1028522/…)

          – alkamid
          Jun 30 '18 at 12:05






        • 6





          @alkamid it is: sudo snap install pdftk

          – Qubix
          Sep 23 '18 at 18:51






        • 5





          Although pdftk is certainly a tool that can do the job, I would recommend against it. This is not free software, but an clunky piece of shareware. Also it needs the JVM. A more reasonable tool is qpdf, as suggested in another answer.

          – leftaroundabout
          Nov 13 '18 at 13:11














        406












        406








        406







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



        pdftk full-pdf.pdf cat 12-15 output outfile_p12-15.pdf


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






        share|improve this answer















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



        pdftk full-pdf.pdf cat 12-15 output outfile_p12-15.pdf


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







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Feb 16 '16 at 21:54









        Tim

        19.9k1486141




        19.9k1486141










        answered Apr 17 '13 at 15:21









        Martin HMartin H

        4,21011212




        4,21011212








        • 4





          If I want to extract pages 1-10, 15, and 17, how do I write the command?

          – Patrick Li
          Oct 12 '16 at 8:26






        • 24





          @PatrickLi pdftk A=in.pdf cat A1-10 A15 A17 output out.pdf

          – m8mble
          Oct 28 '16 at 12:06






        • 6





          Note that pdftk is not available in Ubuntu 18.04. (see askubuntu.com/questions/1028522/…)

          – alkamid
          Jun 30 '18 at 12:05






        • 6





          @alkamid it is: sudo snap install pdftk

          – Qubix
          Sep 23 '18 at 18:51






        • 5





          Although pdftk is certainly a tool that can do the job, I would recommend against it. This is not free software, but an clunky piece of shareware. Also it needs the JVM. A more reasonable tool is qpdf, as suggested in another answer.

          – leftaroundabout
          Nov 13 '18 at 13:11














        • 4





          If I want to extract pages 1-10, 15, and 17, how do I write the command?

          – Patrick Li
          Oct 12 '16 at 8:26






        • 24





          @PatrickLi pdftk A=in.pdf cat A1-10 A15 A17 output out.pdf

          – m8mble
          Oct 28 '16 at 12:06






        • 6





          Note that pdftk is not available in Ubuntu 18.04. (see askubuntu.com/questions/1028522/…)

          – alkamid
          Jun 30 '18 at 12:05






        • 6





          @alkamid it is: sudo snap install pdftk

          – Qubix
          Sep 23 '18 at 18:51






        • 5





          Although pdftk is certainly a tool that can do the job, I would recommend against it. This is not free software, but an clunky piece of shareware. Also it needs the JVM. A more reasonable tool is qpdf, as suggested in another answer.

          – leftaroundabout
          Nov 13 '18 at 13:11








        4




        4





        If I want to extract pages 1-10, 15, and 17, how do I write the command?

        – Patrick Li
        Oct 12 '16 at 8:26





        If I want to extract pages 1-10, 15, and 17, how do I write the command?

        – Patrick Li
        Oct 12 '16 at 8:26




        24




        24





        @PatrickLi pdftk A=in.pdf cat A1-10 A15 A17 output out.pdf

        – m8mble
        Oct 28 '16 at 12:06





        @PatrickLi pdftk A=in.pdf cat A1-10 A15 A17 output out.pdf

        – m8mble
        Oct 28 '16 at 12:06




        6




        6





        Note that pdftk is not available in Ubuntu 18.04. (see askubuntu.com/questions/1028522/…)

        – alkamid
        Jun 30 '18 at 12:05





        Note that pdftk is not available in Ubuntu 18.04. (see askubuntu.com/questions/1028522/…)

        – alkamid
        Jun 30 '18 at 12:05




        6




        6





        @alkamid it is: sudo snap install pdftk

        – Qubix
        Sep 23 '18 at 18:51





        @alkamid it is: sudo snap install pdftk

        – Qubix
        Sep 23 '18 at 18:51




        5




        5





        Although pdftk is certainly a tool that can do the job, I would recommend against it. This is not free software, but an clunky piece of shareware. Also it needs the JVM. A more reasonable tool is qpdf, as suggested in another answer.

        – leftaroundabout
        Nov 13 '18 at 13:11





        Although pdftk is certainly a tool that can do the job, I would recommend against it. This is not free software, but an clunky piece of shareware. Also it needs the JVM. A more reasonable tool is qpdf, as suggested in another answer.

        – leftaroundabout
        Nov 13 '18 at 13:11













        221














        very Simple, use default PDF reader :



        print as file. that is it!
        print menu



        then



        setting new PDF






        share|improve this answer



















        • 12





          flippin brilliant

          – andybleaden
          Dec 22 '14 at 17:28






        • 14





          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 '15 at 13:48








        • 9





          This can result in file with a much larger size than the original document.

          – dat
          Dec 8 '15 at 17:06






        • 7





          so it does not "extract" the page range. It creates a new pdf from the old one, as if you used high-definition printer/scanner pair.

          – sylvainulg
          Aug 11 '16 at 9:36






        • 6





          Good for simple cases, but undesired results in documents with highlighting comments: the highlighting becomes 100% opacity and blocks the text.

          – loved.by.Jesus
          Oct 16 '16 at 20:30
















        221














        very Simple, use default PDF reader :



        print as file. that is it!
        print menu



        then



        setting new PDF






        share|improve this answer



















        • 12





          flippin brilliant

          – andybleaden
          Dec 22 '14 at 17:28






        • 14





          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 '15 at 13:48








        • 9





          This can result in file with a much larger size than the original document.

          – dat
          Dec 8 '15 at 17:06






        • 7





          so it does not "extract" the page range. It creates a new pdf from the old one, as if you used high-definition printer/scanner pair.

          – sylvainulg
          Aug 11 '16 at 9:36






        • 6





          Good for simple cases, but undesired results in documents with highlighting comments: the highlighting becomes 100% opacity and blocks the text.

          – loved.by.Jesus
          Oct 16 '16 at 20:30














        221












        221








        221







        very Simple, use default PDF reader :



        print as file. that is it!
        print menu



        then



        setting new PDF






        share|improve this answer













        very Simple, use default PDF reader :



        print as file. that is it!
        print menu



        then



        setting new PDF







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 14 '13 at 10:25









        Abdennour TOUMIAbdennour TOUMI

        5,19543446




        5,19543446








        • 12





          flippin brilliant

          – andybleaden
          Dec 22 '14 at 17:28






        • 14





          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 '15 at 13:48








        • 9





          This can result in file with a much larger size than the original document.

          – dat
          Dec 8 '15 at 17:06






        • 7





          so it does not "extract" the page range. It creates a new pdf from the old one, as if you used high-definition printer/scanner pair.

          – sylvainulg
          Aug 11 '16 at 9:36






        • 6





          Good for simple cases, but undesired results in documents with highlighting comments: the highlighting becomes 100% opacity and blocks the text.

          – loved.by.Jesus
          Oct 16 '16 at 20:30














        • 12





          flippin brilliant

          – andybleaden
          Dec 22 '14 at 17:28






        • 14





          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 '15 at 13:48








        • 9





          This can result in file with a much larger size than the original document.

          – dat
          Dec 8 '15 at 17:06






        • 7





          so it does not "extract" the page range. It creates a new pdf from the old one, as if you used high-definition printer/scanner pair.

          – sylvainulg
          Aug 11 '16 at 9:36






        • 6





          Good for simple cases, but undesired results in documents with highlighting comments: the highlighting becomes 100% opacity and blocks the text.

          – loved.by.Jesus
          Oct 16 '16 at 20:30








        12




        12





        flippin brilliant

        – andybleaden
        Dec 22 '14 at 17:28





        flippin brilliant

        – andybleaden
        Dec 22 '14 at 17:28




        14




        14





        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 '15 at 13:48







        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 '15 at 13:48






        9




        9





        This can result in file with a much larger size than the original document.

        – dat
        Dec 8 '15 at 17:06





        This can result in file with a much larger size than the original document.

        – dat
        Dec 8 '15 at 17:06




        7




        7





        so it does not "extract" the page range. It creates a new pdf from the old one, as if you used high-definition printer/scanner pair.

        – sylvainulg
        Aug 11 '16 at 9:36





        so it does not "extract" the page range. It creates a new pdf from the old one, as if you used high-definition printer/scanner pair.

        – sylvainulg
        Aug 11 '16 at 9:36




        6




        6





        Good for simple cases, but undesired results in documents with highlighting comments: the highlighting becomes 100% opacity and blocks the text.

        – loved.by.Jesus
        Oct 16 '16 at 20:30





        Good for simple cases, but undesired results in documents with highlighting comments: the highlighting becomes 100% opacity and blocks the text.

        – loved.by.Jesus
        Oct 16 '16 at 20:30











        72














        Page range - Nautilus script





        Overview



        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 based on three different backends that are capable of preserving all attributes of the original file


        Screenshot



        enter image description here



        Code



        #!/bin/bash
        #
        # TITLE: PDFextract
        #
        # AUTHOR: (c) 2013-2015 Glutanimate (https://github.com/Glutanimate)
        #
        # VERSION: 0.2
        #
        # LICENSE: GNU GPL v3 (http://www.gnu.org/licenses/gpl.html)
        #
        # OVERVIEW: PDFextract is a simple PDF extraction script based on Ghostscript/qpdf/cpdf.
        # It provides a simple way to extract a page range from a PDF document and is meant
        # to be used as a file manager script/addon (e.g. Nautilus script).
        #
        # FEATURES: - simple GUI based on YAD, an advanced Zenity fork.
        # - preserves _all_ attributes of your original PDF file and does not compress
        # embedded images further than they are.
        # - can choose from three different backends: ghostscript, qpdf, cpdf
        #
        # DEPENDENCIES: ghostscript/qpdf/cpdf poppler-utils yad libnotify-bin
        #
        # You need to install at least one of the three backends supported by this script.
        #
        # - ghostscript, qpdf, poppler-utils, and libnotify-bin are available via
        # the standard Ubuntu repositories
        # - cpdf is a commercial CLI PDF toolkit that is free for personal use.
        # It can be downloaded here: https://github.com/coherentgraphics/cpdf-binaries
        # - yad can be installed from the webupd8 PPA with the following command:
        # sudo add-apt-repository ppa:webupd8team/y-ppa-manager && apt-get update && apt-get install yad
        #
        # NOTES: Here is a quick comparison of the advantages and disadvantages of each backend:
        #
        # speed metadata preservation content preservation license
        # ghostscript: -- ++ ++ open-source
        # cpdf: - ++ ++ proprietary
        # qpdf: ++ + ++ open-source
        #
        # Results might vary depending on the document and the version of the tool in question.
        #
        # INSTALLATION: https://askubuntu.com/a/236415
        #
        # This script was inspired by Kurt Pfeifle's PDF extraction script
        # (http://www.linuxjournal.com/content/tech-tip-extract-pages-pdf)
        #
        # Originally posted on askubuntu
        # (https://askubuntu.com/a/282453)

        # Variables

        DOCUMENT="$1"
        BACKENDSELECTION="^qpdf!ghostscript!cpdf"

        # Functions

        check_input(){
        if [[ -z "$1" ]]; then
        notify "Error: No input file selected."
        exit 1
        elif [[ ! "$(file -ib "$1")" == *application/pdf* ]]; then
        notify "Error: Not a valid PDF file."
        exit 1
        fi
        }

        check_deps () {
        for i in "$@"; do
        type "$i" > /dev/null 2>&1
        if [[ "$?" != "0" ]]; then
        MissingDeps+="$i"
        fi
        done
        }

        ghostscriptextract(){
        gs -dFirstPage="$STARTPAGE "-dLastPage="$STOPPAGE" -sOutputFile="$OUTFILE" -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.7 /EncodeMonoImages true /GrayImageDownsampleThreshold 1.5
        /AutoFilterGrayImages false /GrayImageFilter /FlateEncode /DownsampleGrayImages false /AutoFilterColorImages false /DownsampleColorImages false /CompressPages true
        /ColorImageDownsampleThreshold 1.5 /PreserveHalftoneInfo false >> setdistillerparams" -f "$DOCUMENT"
        }

        cpdfextract(){
        cpdf "$DOCUMENT" "$STARTPAGE-$STOPPAGE" -o "$OUTFILE"
        }

        qpdfextract(){
        qpdf --linearize "$DOCUMENT" --pages "$DOCUMENT" "$STARTPAGE-$STOPPAGE" -- "$OUTFILE"
        echo "$OUTFILE"
        return 0 # even benign qpdf warnings produce error codes, so we suppress them
        }

        notify(){
        echo "$1"
        notify-send -i application-pdf "PDFextract" "$1"
        }

        dialog_warning(){
        echo "$1"
        yad --center --image dialog-warning
        --title "PDFExtract Warning"
        --text "$1"
        --button="Try again:0"
        --button="Exit:1"

        [[ "$?" != "0" ]] && exit 0
        }

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

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

        SETTINGSRET="$?"

        [[ "$SETTINGSRET" != "0" ]] && exit 1

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

        check_deps "$BACKEND"

        if [[ -n "$MissingDeps" ]]; then
        dialog_warning "Error, missing dependency: $MissingDeps"
        unset MissingDeps
        dialog_settings
        return
        fi

        if [[ "$STARTPAGE" -gt "$STOPPAGE" ]]; then
        dialog_warning "<b> Start page higher than stop page. </b>"
        dialog_settings
        return
        fi

        OUTFILE="${DOCUMENT%.pdf} (p${STARTPAGE}-p${STOPPAGE}).pdf"
        }

        extract_pages(){
        $EXTRACTOR
        EXTRACTORRET="$?"
        if [[ "$EXTRACTORRET" = "0" ]]; then
        notify "Pages $STARTPAGE to $STOPPAGE succesfully extracted."
        else
        notify "There has been an error. Please check the CLI output."
        fi
        }


        # Main

        check_input "$1"
        dialog_settings
        extract_pages


        Installation



        Please follow the generic installation instructions for Nautilus scripts. Make sure to read the script header carefully as it will help to clarify the installation and usage of the script.





        Partial pages - PDF Shuffler





        Overview




        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.




        Installation



        sudo apt-get install pdfshuffler


        Usage



        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





        Overview



        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.



        Installation



        sudo apt-get install inkscape


        Usage



        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








        • 2





          @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








        • 3





          ok, I've added a different method using Inkscape.

          – Glutanimate
          Apr 18 '13 at 6:13






        • 1





          pdfshuffler is not sufficient if you want to extract a part of the PDF page. The original PDF data of the page is still preserved in the file. Do not use this method if you want to remove sensitive data from a PDF file.

          – Rob W
          Nov 7 '15 at 11:48
















        72














        Page range - Nautilus script





        Overview



        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 based on three different backends that are capable of preserving all attributes of the original file


        Screenshot



        enter image description here



        Code



        #!/bin/bash
        #
        # TITLE: PDFextract
        #
        # AUTHOR: (c) 2013-2015 Glutanimate (https://github.com/Glutanimate)
        #
        # VERSION: 0.2
        #
        # LICENSE: GNU GPL v3 (http://www.gnu.org/licenses/gpl.html)
        #
        # OVERVIEW: PDFextract is a simple PDF extraction script based on Ghostscript/qpdf/cpdf.
        # It provides a simple way to extract a page range from a PDF document and is meant
        # to be used as a file manager script/addon (e.g. Nautilus script).
        #
        # FEATURES: - simple GUI based on YAD, an advanced Zenity fork.
        # - preserves _all_ attributes of your original PDF file and does not compress
        # embedded images further than they are.
        # - can choose from three different backends: ghostscript, qpdf, cpdf
        #
        # DEPENDENCIES: ghostscript/qpdf/cpdf poppler-utils yad libnotify-bin
        #
        # You need to install at least one of the three backends supported by this script.
        #
        # - ghostscript, qpdf, poppler-utils, and libnotify-bin are available via
        # the standard Ubuntu repositories
        # - cpdf is a commercial CLI PDF toolkit that is free for personal use.
        # It can be downloaded here: https://github.com/coherentgraphics/cpdf-binaries
        # - yad can be installed from the webupd8 PPA with the following command:
        # sudo add-apt-repository ppa:webupd8team/y-ppa-manager && apt-get update && apt-get install yad
        #
        # NOTES: Here is a quick comparison of the advantages and disadvantages of each backend:
        #
        # speed metadata preservation content preservation license
        # ghostscript: -- ++ ++ open-source
        # cpdf: - ++ ++ proprietary
        # qpdf: ++ + ++ open-source
        #
        # Results might vary depending on the document and the version of the tool in question.
        #
        # INSTALLATION: https://askubuntu.com/a/236415
        #
        # This script was inspired by Kurt Pfeifle's PDF extraction script
        # (http://www.linuxjournal.com/content/tech-tip-extract-pages-pdf)
        #
        # Originally posted on askubuntu
        # (https://askubuntu.com/a/282453)

        # Variables

        DOCUMENT="$1"
        BACKENDSELECTION="^qpdf!ghostscript!cpdf"

        # Functions

        check_input(){
        if [[ -z "$1" ]]; then
        notify "Error: No input file selected."
        exit 1
        elif [[ ! "$(file -ib "$1")" == *application/pdf* ]]; then
        notify "Error: Not a valid PDF file."
        exit 1
        fi
        }

        check_deps () {
        for i in "$@"; do
        type "$i" > /dev/null 2>&1
        if [[ "$?" != "0" ]]; then
        MissingDeps+="$i"
        fi
        done
        }

        ghostscriptextract(){
        gs -dFirstPage="$STARTPAGE "-dLastPage="$STOPPAGE" -sOutputFile="$OUTFILE" -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.7 /EncodeMonoImages true /GrayImageDownsampleThreshold 1.5
        /AutoFilterGrayImages false /GrayImageFilter /FlateEncode /DownsampleGrayImages false /AutoFilterColorImages false /DownsampleColorImages false /CompressPages true
        /ColorImageDownsampleThreshold 1.5 /PreserveHalftoneInfo false >> setdistillerparams" -f "$DOCUMENT"
        }

        cpdfextract(){
        cpdf "$DOCUMENT" "$STARTPAGE-$STOPPAGE" -o "$OUTFILE"
        }

        qpdfextract(){
        qpdf --linearize "$DOCUMENT" --pages "$DOCUMENT" "$STARTPAGE-$STOPPAGE" -- "$OUTFILE"
        echo "$OUTFILE"
        return 0 # even benign qpdf warnings produce error codes, so we suppress them
        }

        notify(){
        echo "$1"
        notify-send -i application-pdf "PDFextract" "$1"
        }

        dialog_warning(){
        echo "$1"
        yad --center --image dialog-warning
        --title "PDFExtract Warning"
        --text "$1"
        --button="Try again:0"
        --button="Exit:1"

        [[ "$?" != "0" ]] && exit 0
        }

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

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

        SETTINGSRET="$?"

        [[ "$SETTINGSRET" != "0" ]] && exit 1

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

        check_deps "$BACKEND"

        if [[ -n "$MissingDeps" ]]; then
        dialog_warning "Error, missing dependency: $MissingDeps"
        unset MissingDeps
        dialog_settings
        return
        fi

        if [[ "$STARTPAGE" -gt "$STOPPAGE" ]]; then
        dialog_warning "<b> Start page higher than stop page. </b>"
        dialog_settings
        return
        fi

        OUTFILE="${DOCUMENT%.pdf} (p${STARTPAGE}-p${STOPPAGE}).pdf"
        }

        extract_pages(){
        $EXTRACTOR
        EXTRACTORRET="$?"
        if [[ "$EXTRACTORRET" = "0" ]]; then
        notify "Pages $STARTPAGE to $STOPPAGE succesfully extracted."
        else
        notify "There has been an error. Please check the CLI output."
        fi
        }


        # Main

        check_input "$1"
        dialog_settings
        extract_pages


        Installation



        Please follow the generic installation instructions for Nautilus scripts. Make sure to read the script header carefully as it will help to clarify the installation and usage of the script.





        Partial pages - PDF Shuffler





        Overview




        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.




        Installation



        sudo apt-get install pdfshuffler


        Usage



        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





        Overview



        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.



        Installation



        sudo apt-get install inkscape


        Usage



        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








        • 2





          @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








        • 3





          ok, I've added a different method using Inkscape.

          – Glutanimate
          Apr 18 '13 at 6:13






        • 1





          pdfshuffler is not sufficient if you want to extract a part of the PDF page. The original PDF data of the page is still preserved in the file. Do not use this method if you want to remove sensitive data from a PDF file.

          – Rob W
          Nov 7 '15 at 11:48














        72












        72








        72







        Page range - Nautilus script





        Overview



        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 based on three different backends that are capable of preserving all attributes of the original file


        Screenshot



        enter image description here



        Code



        #!/bin/bash
        #
        # TITLE: PDFextract
        #
        # AUTHOR: (c) 2013-2015 Glutanimate (https://github.com/Glutanimate)
        #
        # VERSION: 0.2
        #
        # LICENSE: GNU GPL v3 (http://www.gnu.org/licenses/gpl.html)
        #
        # OVERVIEW: PDFextract is a simple PDF extraction script based on Ghostscript/qpdf/cpdf.
        # It provides a simple way to extract a page range from a PDF document and is meant
        # to be used as a file manager script/addon (e.g. Nautilus script).
        #
        # FEATURES: - simple GUI based on YAD, an advanced Zenity fork.
        # - preserves _all_ attributes of your original PDF file and does not compress
        # embedded images further than they are.
        # - can choose from three different backends: ghostscript, qpdf, cpdf
        #
        # DEPENDENCIES: ghostscript/qpdf/cpdf poppler-utils yad libnotify-bin
        #
        # You need to install at least one of the three backends supported by this script.
        #
        # - ghostscript, qpdf, poppler-utils, and libnotify-bin are available via
        # the standard Ubuntu repositories
        # - cpdf is a commercial CLI PDF toolkit that is free for personal use.
        # It can be downloaded here: https://github.com/coherentgraphics/cpdf-binaries
        # - yad can be installed from the webupd8 PPA with the following command:
        # sudo add-apt-repository ppa:webupd8team/y-ppa-manager && apt-get update && apt-get install yad
        #
        # NOTES: Here is a quick comparison of the advantages and disadvantages of each backend:
        #
        # speed metadata preservation content preservation license
        # ghostscript: -- ++ ++ open-source
        # cpdf: - ++ ++ proprietary
        # qpdf: ++ + ++ open-source
        #
        # Results might vary depending on the document and the version of the tool in question.
        #
        # INSTALLATION: https://askubuntu.com/a/236415
        #
        # This script was inspired by Kurt Pfeifle's PDF extraction script
        # (http://www.linuxjournal.com/content/tech-tip-extract-pages-pdf)
        #
        # Originally posted on askubuntu
        # (https://askubuntu.com/a/282453)

        # Variables

        DOCUMENT="$1"
        BACKENDSELECTION="^qpdf!ghostscript!cpdf"

        # Functions

        check_input(){
        if [[ -z "$1" ]]; then
        notify "Error: No input file selected."
        exit 1
        elif [[ ! "$(file -ib "$1")" == *application/pdf* ]]; then
        notify "Error: Not a valid PDF file."
        exit 1
        fi
        }

        check_deps () {
        for i in "$@"; do
        type "$i" > /dev/null 2>&1
        if [[ "$?" != "0" ]]; then
        MissingDeps+="$i"
        fi
        done
        }

        ghostscriptextract(){
        gs -dFirstPage="$STARTPAGE "-dLastPage="$STOPPAGE" -sOutputFile="$OUTFILE" -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.7 /EncodeMonoImages true /GrayImageDownsampleThreshold 1.5
        /AutoFilterGrayImages false /GrayImageFilter /FlateEncode /DownsampleGrayImages false /AutoFilterColorImages false /DownsampleColorImages false /CompressPages true
        /ColorImageDownsampleThreshold 1.5 /PreserveHalftoneInfo false >> setdistillerparams" -f "$DOCUMENT"
        }

        cpdfextract(){
        cpdf "$DOCUMENT" "$STARTPAGE-$STOPPAGE" -o "$OUTFILE"
        }

        qpdfextract(){
        qpdf --linearize "$DOCUMENT" --pages "$DOCUMENT" "$STARTPAGE-$STOPPAGE" -- "$OUTFILE"
        echo "$OUTFILE"
        return 0 # even benign qpdf warnings produce error codes, so we suppress them
        }

        notify(){
        echo "$1"
        notify-send -i application-pdf "PDFextract" "$1"
        }

        dialog_warning(){
        echo "$1"
        yad --center --image dialog-warning
        --title "PDFExtract Warning"
        --text "$1"
        --button="Try again:0"
        --button="Exit:1"

        [[ "$?" != "0" ]] && exit 0
        }

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

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

        SETTINGSRET="$?"

        [[ "$SETTINGSRET" != "0" ]] && exit 1

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

        check_deps "$BACKEND"

        if [[ -n "$MissingDeps" ]]; then
        dialog_warning "Error, missing dependency: $MissingDeps"
        unset MissingDeps
        dialog_settings
        return
        fi

        if [[ "$STARTPAGE" -gt "$STOPPAGE" ]]; then
        dialog_warning "<b> Start page higher than stop page. </b>"
        dialog_settings
        return
        fi

        OUTFILE="${DOCUMENT%.pdf} (p${STARTPAGE}-p${STOPPAGE}).pdf"
        }

        extract_pages(){
        $EXTRACTOR
        EXTRACTORRET="$?"
        if [[ "$EXTRACTORRET" = "0" ]]; then
        notify "Pages $STARTPAGE to $STOPPAGE succesfully extracted."
        else
        notify "There has been an error. Please check the CLI output."
        fi
        }


        # Main

        check_input "$1"
        dialog_settings
        extract_pages


        Installation



        Please follow the generic installation instructions for Nautilus scripts. Make sure to read the script header carefully as it will help to clarify the installation and usage of the script.





        Partial pages - PDF Shuffler





        Overview




        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.




        Installation



        sudo apt-get install pdfshuffler


        Usage



        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





        Overview



        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.



        Installation



        sudo apt-get install inkscape


        Usage



        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















        Page range - Nautilus script





        Overview



        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 based on three different backends that are capable of preserving all attributes of the original file


        Screenshot



        enter image description here



        Code



        #!/bin/bash
        #
        # TITLE: PDFextract
        #
        # AUTHOR: (c) 2013-2015 Glutanimate (https://github.com/Glutanimate)
        #
        # VERSION: 0.2
        #
        # LICENSE: GNU GPL v3 (http://www.gnu.org/licenses/gpl.html)
        #
        # OVERVIEW: PDFextract is a simple PDF extraction script based on Ghostscript/qpdf/cpdf.
        # It provides a simple way to extract a page range from a PDF document and is meant
        # to be used as a file manager script/addon (e.g. Nautilus script).
        #
        # FEATURES: - simple GUI based on YAD, an advanced Zenity fork.
        # - preserves _all_ attributes of your original PDF file and does not compress
        # embedded images further than they are.
        # - can choose from three different backends: ghostscript, qpdf, cpdf
        #
        # DEPENDENCIES: ghostscript/qpdf/cpdf poppler-utils yad libnotify-bin
        #
        # You need to install at least one of the three backends supported by this script.
        #
        # - ghostscript, qpdf, poppler-utils, and libnotify-bin are available via
        # the standard Ubuntu repositories
        # - cpdf is a commercial CLI PDF toolkit that is free for personal use.
        # It can be downloaded here: https://github.com/coherentgraphics/cpdf-binaries
        # - yad can be installed from the webupd8 PPA with the following command:
        # sudo add-apt-repository ppa:webupd8team/y-ppa-manager && apt-get update && apt-get install yad
        #
        # NOTES: Here is a quick comparison of the advantages and disadvantages of each backend:
        #
        # speed metadata preservation content preservation license
        # ghostscript: -- ++ ++ open-source
        # cpdf: - ++ ++ proprietary
        # qpdf: ++ + ++ open-source
        #
        # Results might vary depending on the document and the version of the tool in question.
        #
        # INSTALLATION: https://askubuntu.com/a/236415
        #
        # This script was inspired by Kurt Pfeifle's PDF extraction script
        # (http://www.linuxjournal.com/content/tech-tip-extract-pages-pdf)
        #
        # Originally posted on askubuntu
        # (https://askubuntu.com/a/282453)

        # Variables

        DOCUMENT="$1"
        BACKENDSELECTION="^qpdf!ghostscript!cpdf"

        # Functions

        check_input(){
        if [[ -z "$1" ]]; then
        notify "Error: No input file selected."
        exit 1
        elif [[ ! "$(file -ib "$1")" == *application/pdf* ]]; then
        notify "Error: Not a valid PDF file."
        exit 1
        fi
        }

        check_deps () {
        for i in "$@"; do
        type "$i" > /dev/null 2>&1
        if [[ "$?" != "0" ]]; then
        MissingDeps+="$i"
        fi
        done
        }

        ghostscriptextract(){
        gs -dFirstPage="$STARTPAGE "-dLastPage="$STOPPAGE" -sOutputFile="$OUTFILE" -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.7 /EncodeMonoImages true /GrayImageDownsampleThreshold 1.5
        /AutoFilterGrayImages false /GrayImageFilter /FlateEncode /DownsampleGrayImages false /AutoFilterColorImages false /DownsampleColorImages false /CompressPages true
        /ColorImageDownsampleThreshold 1.5 /PreserveHalftoneInfo false >> setdistillerparams" -f "$DOCUMENT"
        }

        cpdfextract(){
        cpdf "$DOCUMENT" "$STARTPAGE-$STOPPAGE" -o "$OUTFILE"
        }

        qpdfextract(){
        qpdf --linearize "$DOCUMENT" --pages "$DOCUMENT" "$STARTPAGE-$STOPPAGE" -- "$OUTFILE"
        echo "$OUTFILE"
        return 0 # even benign qpdf warnings produce error codes, so we suppress them
        }

        notify(){
        echo "$1"
        notify-send -i application-pdf "PDFextract" "$1"
        }

        dialog_warning(){
        echo "$1"
        yad --center --image dialog-warning
        --title "PDFExtract Warning"
        --text "$1"
        --button="Try again:0"
        --button="Exit:1"

        [[ "$?" != "0" ]] && exit 0
        }

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

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

        SETTINGSRET="$?"

        [[ "$SETTINGSRET" != "0" ]] && exit 1

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

        check_deps "$BACKEND"

        if [[ -n "$MissingDeps" ]]; then
        dialog_warning "Error, missing dependency: $MissingDeps"
        unset MissingDeps
        dialog_settings
        return
        fi

        if [[ "$STARTPAGE" -gt "$STOPPAGE" ]]; then
        dialog_warning "<b> Start page higher than stop page. </b>"
        dialog_settings
        return
        fi

        OUTFILE="${DOCUMENT%.pdf} (p${STARTPAGE}-p${STOPPAGE}).pdf"
        }

        extract_pages(){
        $EXTRACTOR
        EXTRACTORRET="$?"
        if [[ "$EXTRACTORRET" = "0" ]]; then
        notify "Pages $STARTPAGE to $STOPPAGE succesfully extracted."
        else
        notify "There has been an error. Please check the CLI output."
        fi
        }


        # Main

        check_input "$1"
        dialog_settings
        extract_pages


        Installation



        Please follow the generic installation instructions for Nautilus scripts. Make sure to read the script header carefully as it will help to clarify the installation and usage of the script.





        Partial pages - PDF Shuffler





        Overview




        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.




        Installation



        sudo apt-get install pdfshuffler


        Usage



        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





        Overview



        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.



        Installation



        sudo apt-get install inkscape


        Usage



        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














        share|improve this answer



        share|improve this answer








        edited Apr 13 '17 at 12:24









        Community

        1




        1










        answered Apr 17 '13 at 15:11









        GlutanimateGlutanimate

        16.3k873132




        16.3k873132













        • 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








        • 2





          @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








        • 3





          ok, I've added a different method using Inkscape.

          – Glutanimate
          Apr 18 '13 at 6:13






        • 1





          pdfshuffler is not sufficient if you want to extract a part of the PDF page. The original PDF data of the page is still preserved in the file. Do not use this method if you want to remove sensitive data from a PDF file.

          – Rob W
          Nov 7 '15 at 11:48



















        • 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








        • 2





          @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








        • 3





          ok, I've added a different method using Inkscape.

          – Glutanimate
          Apr 18 '13 at 6:13






        • 1





          pdfshuffler is not sufficient if you want to extract a part of the PDF page. The original PDF data of the page is still preserved in the file. Do not use this method if you want to remove sensitive data from a PDF file.

          – Rob W
          Nov 7 '15 at 11:48

















        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







        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






        2




        2





        @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







        @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






        3




        3





        ok, I've added a different method using Inkscape.

        – Glutanimate
        Apr 18 '13 at 6:13





        ok, I've added a different method using Inkscape.

        – Glutanimate
        Apr 18 '13 at 6:13




        1




        1





        pdfshuffler is not sufficient if you want to extract a part of the PDF page. The original PDF data of the page is still preserved in the file. Do not use this method if you want to remove sensitive data from a PDF file.

        – Rob W
        Nov 7 '15 at 11:48





        pdfshuffler is not sufficient if you want to extract a part of the PDF page. The original PDF data of the page is still preserved in the file. Do not use this method if you want to remove sensitive data from a PDF file.

        – Rob W
        Nov 7 '15 at 11:48











        40














        QPDF is great. Use it this way to extract pages 1-10 from input.pdf and save it as output.pdf.



        qpdf --pages input.pdf 1-10 -- input.pdf output.pdf


        Please note that input.pdf is written twice.



        You can install it by invoking:



        apt-get install qpdf


        Or, by going to Ubuntu apps directory:



        Install via the software center



        It is a great tool for PDF manipulation, which is very fast, has very few dependencies. "It can encrypt and linearize files, expose the internals of a PDF file, and do many other operations useful to end users and PDF developers."



        http://sourceforge.net/projects/qpdf/






        share|improve this answer





















        • 2





          The only problem I had with this is that is still lists all the pages in the table of contents, despite most being removed. Apart from, brilliant thanks! :)

          – Wilf
          Nov 10 '15 at 14:24






        • 2





          Great software. Nice

          – Anwar
          Aug 4 '16 at 11:42






        • 1





          Warning - Files are all huge..about the same size as the original.

          – Corey Alix
          Nov 27 '18 at 0:50











        • One of the best options, since qpdf is robust and doesn't alter (downsample images etc.) the contents of the PDF file.

          – rbrito
          Nov 29 '18 at 7:52











        • Works, but that syntax for specifying the pages (listing the input file twice, then adding --) is really weird.

          – Dan Dascalescu
          Feb 23 at 1:43
















        40














        QPDF is great. Use it this way to extract pages 1-10 from input.pdf and save it as output.pdf.



        qpdf --pages input.pdf 1-10 -- input.pdf output.pdf


        Please note that input.pdf is written twice.



        You can install it by invoking:



        apt-get install qpdf


        Or, by going to Ubuntu apps directory:



        Install via the software center



        It is a great tool for PDF manipulation, which is very fast, has very few dependencies. "It can encrypt and linearize files, expose the internals of a PDF file, and do many other operations useful to end users and PDF developers."



        http://sourceforge.net/projects/qpdf/






        share|improve this answer





















        • 2





          The only problem I had with this is that is still lists all the pages in the table of contents, despite most being removed. Apart from, brilliant thanks! :)

          – Wilf
          Nov 10 '15 at 14:24






        • 2





          Great software. Nice

          – Anwar
          Aug 4 '16 at 11:42






        • 1





          Warning - Files are all huge..about the same size as the original.

          – Corey Alix
          Nov 27 '18 at 0:50











        • One of the best options, since qpdf is robust and doesn't alter (downsample images etc.) the contents of the PDF file.

          – rbrito
          Nov 29 '18 at 7:52











        • Works, but that syntax for specifying the pages (listing the input file twice, then adding --) is really weird.

          – Dan Dascalescu
          Feb 23 at 1:43














        40












        40








        40







        QPDF is great. Use it this way to extract pages 1-10 from input.pdf and save it as output.pdf.



        qpdf --pages input.pdf 1-10 -- input.pdf output.pdf


        Please note that input.pdf is written twice.



        You can install it by invoking:



        apt-get install qpdf


        Or, by going to Ubuntu apps directory:



        Install via the software center



        It is a great tool for PDF manipulation, which is very fast, has very few dependencies. "It can encrypt and linearize files, expose the internals of a PDF file, and do many other operations useful to end users and PDF developers."



        http://sourceforge.net/projects/qpdf/






        share|improve this answer















        QPDF is great. Use it this way to extract pages 1-10 from input.pdf and save it as output.pdf.



        qpdf --pages input.pdf 1-10 -- input.pdf output.pdf


        Please note that input.pdf is written twice.



        You can install it by invoking:



        apt-get install qpdf


        Or, by going to Ubuntu apps directory:



        Install via the software center



        It is a great tool for PDF manipulation, which is very fast, has very few dependencies. "It can encrypt and linearize files, expose the internals of a PDF file, and do many other operations useful to end users and PDF developers."



        http://sourceforge.net/projects/qpdf/







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Sep 9 '15 at 7:16

























        answered Sep 9 '15 at 7:10









        Ho1Ho1

        9451914




        9451914








        • 2





          The only problem I had with this is that is still lists all the pages in the table of contents, despite most being removed. Apart from, brilliant thanks! :)

          – Wilf
          Nov 10 '15 at 14:24






        • 2





          Great software. Nice

          – Anwar
          Aug 4 '16 at 11:42






        • 1





          Warning - Files are all huge..about the same size as the original.

          – Corey Alix
          Nov 27 '18 at 0:50











        • One of the best options, since qpdf is robust and doesn't alter (downsample images etc.) the contents of the PDF file.

          – rbrito
          Nov 29 '18 at 7:52











        • Works, but that syntax for specifying the pages (listing the input file twice, then adding --) is really weird.

          – Dan Dascalescu
          Feb 23 at 1:43














        • 2





          The only problem I had with this is that is still lists all the pages in the table of contents, despite most being removed. Apart from, brilliant thanks! :)

          – Wilf
          Nov 10 '15 at 14:24






        • 2





          Great software. Nice

          – Anwar
          Aug 4 '16 at 11:42






        • 1





          Warning - Files are all huge..about the same size as the original.

          – Corey Alix
          Nov 27 '18 at 0:50











        • One of the best options, since qpdf is robust and doesn't alter (downsample images etc.) the contents of the PDF file.

          – rbrito
          Nov 29 '18 at 7:52











        • Works, but that syntax for specifying the pages (listing the input file twice, then adding --) is really weird.

          – Dan Dascalescu
          Feb 23 at 1:43








        2




        2





        The only problem I had with this is that is still lists all the pages in the table of contents, despite most being removed. Apart from, brilliant thanks! :)

        – Wilf
        Nov 10 '15 at 14:24





        The only problem I had with this is that is still lists all the pages in the table of contents, despite most being removed. Apart from, brilliant thanks! :)

        – Wilf
        Nov 10 '15 at 14:24




        2




        2





        Great software. Nice

        – Anwar
        Aug 4 '16 at 11:42





        Great software. Nice

        – Anwar
        Aug 4 '16 at 11:42




        1




        1





        Warning - Files are all huge..about the same size as the original.

        – Corey Alix
        Nov 27 '18 at 0:50





        Warning - Files are all huge..about the same size as the original.

        – Corey Alix
        Nov 27 '18 at 0:50













        One of the best options, since qpdf is robust and doesn't alter (downsample images etc.) the contents of the PDF file.

        – rbrito
        Nov 29 '18 at 7:52





        One of the best options, since qpdf is robust and doesn't alter (downsample images etc.) the contents of the PDF file.

        – rbrito
        Nov 29 '18 at 7:52













        Works, but that syntax for specifying the pages (listing the input file twice, then adding --) is really weird.

        – Dan Dascalescu
        Feb 23 at 1:43





        Works, but that syntax for specifying the pages (listing the input file twice, then adding --) is really weird.

        – Dan Dascalescu
        Feb 23 at 1:43











        35














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



        #!/bin/bash
        # 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
        ${3}


        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



















        • 12





          Let's keep it simple: gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dFirstPage=1 -dLastPage=10 -sOutputFile=output.pdf input.pdf

          – Ho1
          Sep 9 '15 at 7:14













        • and How do I specify input file?

          – Anwar
          Aug 4 '16 at 10:53






        • 1





          -1 for doing bash parameter expansion outside double-quoted string. (should be "-sOutputFile=${3%.pdf}_p${1}-p${2}.pdf" etc. (note the quotes)).

          – Rotsor
          Jan 21 '17 at 16:16













        • @Ho1 please write it as a new answer, it really helps!

          – Joshua Salazar
          Oct 3 '18 at 18:36
















        35














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



        #!/bin/bash
        # 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
        ${3}


        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



















        • 12





          Let's keep it simple: gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dFirstPage=1 -dLastPage=10 -sOutputFile=output.pdf input.pdf

          – Ho1
          Sep 9 '15 at 7:14













        • and How do I specify input file?

          – Anwar
          Aug 4 '16 at 10:53






        • 1





          -1 for doing bash parameter expansion outside double-quoted string. (should be "-sOutputFile=${3%.pdf}_p${1}-p${2}.pdf" etc. (note the quotes)).

          – Rotsor
          Jan 21 '17 at 16:16













        • @Ho1 please write it as a new answer, it really helps!

          – Joshua Salazar
          Oct 3 '18 at 18:36














        35












        35








        35







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



        #!/bin/bash
        # 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
        ${3}


        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













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



        #!/bin/bash
        # 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
        ${3}


        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












        share|improve this answer



        share|improve this answer










        answered Apr 16 '13 at 17:40









        ThiagoPonteThiagoPonte

        1,3461121




        1,3461121








        • 12





          Let's keep it simple: gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dFirstPage=1 -dLastPage=10 -sOutputFile=output.pdf input.pdf

          – Ho1
          Sep 9 '15 at 7:14













        • and How do I specify input file?

          – Anwar
          Aug 4 '16 at 10:53






        • 1





          -1 for doing bash parameter expansion outside double-quoted string. (should be "-sOutputFile=${3%.pdf}_p${1}-p${2}.pdf" etc. (note the quotes)).

          – Rotsor
          Jan 21 '17 at 16:16













        • @Ho1 please write it as a new answer, it really helps!

          – Joshua Salazar
          Oct 3 '18 at 18:36














        • 12





          Let's keep it simple: gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dFirstPage=1 -dLastPage=10 -sOutputFile=output.pdf input.pdf

          – Ho1
          Sep 9 '15 at 7:14













        • and How do I specify input file?

          – Anwar
          Aug 4 '16 at 10:53






        • 1





          -1 for doing bash parameter expansion outside double-quoted string. (should be "-sOutputFile=${3%.pdf}_p${1}-p${2}.pdf" etc. (note the quotes)).

          – Rotsor
          Jan 21 '17 at 16:16













        • @Ho1 please write it as a new answer, it really helps!

          – Joshua Salazar
          Oct 3 '18 at 18:36








        12




        12





        Let's keep it simple: gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dFirstPage=1 -dLastPage=10 -sOutputFile=output.pdf input.pdf

        – Ho1
        Sep 9 '15 at 7:14







        Let's keep it simple: gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dFirstPage=1 -dLastPage=10 -sOutputFile=output.pdf input.pdf

        – Ho1
        Sep 9 '15 at 7:14















        and How do I specify input file?

        – Anwar
        Aug 4 '16 at 10:53





        and How do I specify input file?

        – Anwar
        Aug 4 '16 at 10:53




        1




        1





        -1 for doing bash parameter expansion outside double-quoted string. (should be "-sOutputFile=${3%.pdf}_p${1}-p${2}.pdf" etc. (note the quotes)).

        – Rotsor
        Jan 21 '17 at 16:16







        -1 for doing bash parameter expansion outside double-quoted string. (should be "-sOutputFile=${3%.pdf}_p${1}-p${2}.pdf" etc. (note the quotes)).

        – Rotsor
        Jan 21 '17 at 16:16















        @Ho1 please write it as a new answer, it really helps!

        – Joshua Salazar
        Oct 3 '18 at 18:36





        @Ho1 please write it as a new answer, it really helps!

        – Joshua Salazar
        Oct 3 '18 at 18:36











        22














        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
        produces

        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



















        • 2





          great tool! much faster than pdftk

          – Anwar
          Apr 8 '15 at 5:57






        • 3





          Good, but it is only limited to one page, and if you want more than that, you will get separate pages.

          – Ho1
          Sep 9 '15 at 7:19






        • 2





          Sure, though one can follow the above command with pdfunite to produce a single document.

          – jdmcbr
          Sep 9 '15 at 15:22






        • 3





          If you have a huge document and need to split all pages, it is really fast and useful.

          – MEDVIS
          Apr 27 '16 at 10:32
















        22














        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
        produces

        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



















        • 2





          great tool! much faster than pdftk

          – Anwar
          Apr 8 '15 at 5:57






        • 3





          Good, but it is only limited to one page, and if you want more than that, you will get separate pages.

          – Ho1
          Sep 9 '15 at 7:19






        • 2





          Sure, though one can follow the above command with pdfunite to produce a single document.

          – jdmcbr
          Sep 9 '15 at 15:22






        • 3





          If you have a huge document and need to split all pages, it is really fast and useful.

          – MEDVIS
          Apr 27 '16 at 10:32














        22












        22








        22







        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
        produces

        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













        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
        produces

        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












        share|improve this answer



        share|improve this answer










        answered Oct 29 '14 at 18:17









        jdmcbrjdmcbr

        33637




        33637








        • 2





          great tool! much faster than pdftk

          – Anwar
          Apr 8 '15 at 5:57






        • 3





          Good, but it is only limited to one page, and if you want more than that, you will get separate pages.

          – Ho1
          Sep 9 '15 at 7:19






        • 2





          Sure, though one can follow the above command with pdfunite to produce a single document.

          – jdmcbr
          Sep 9 '15 at 15:22






        • 3





          If you have a huge document and need to split all pages, it is really fast and useful.

          – MEDVIS
          Apr 27 '16 at 10:32














        • 2





          great tool! much faster than pdftk

          – Anwar
          Apr 8 '15 at 5:57






        • 3





          Good, but it is only limited to one page, and if you want more than that, you will get separate pages.

          – Ho1
          Sep 9 '15 at 7:19






        • 2





          Sure, though one can follow the above command with pdfunite to produce a single document.

          – jdmcbr
          Sep 9 '15 at 15:22






        • 3





          If you have a huge document and need to split all pages, it is really fast and useful.

          – MEDVIS
          Apr 27 '16 at 10:32








        2




        2





        great tool! much faster than pdftk

        – Anwar
        Apr 8 '15 at 5:57





        great tool! much faster than pdftk

        – Anwar
        Apr 8 '15 at 5:57




        3




        3





        Good, but it is only limited to one page, and if you want more than that, you will get separate pages.

        – Ho1
        Sep 9 '15 at 7:19





        Good, but it is only limited to one page, and if you want more than that, you will get separate pages.

        – Ho1
        Sep 9 '15 at 7:19




        2




        2





        Sure, though one can follow the above command with pdfunite to produce a single document.

        – jdmcbr
        Sep 9 '15 at 15:22





        Sure, though one can follow the above command with pdfunite to produce a single document.

        – jdmcbr
        Sep 9 '15 at 15:22




        3




        3





        If you have a huge document and need to split all pages, it is really fast and useful.

        – MEDVIS
        Apr 27 '16 at 10:32





        If you have a huge document and need to split all pages, it is really fast and useful.

        – MEDVIS
        Apr 27 '16 at 10:32











        19














        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
        or:
        pdftk A=in1.pdf cat A1-12 A14-end output out1.pdf

        Burst a single PDF document into pages and dump its data to
        doc_data.txt
        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
























        • Package 'pdftk' has no installation candidate

          – FireInTheSky
          Oct 21 '18 at 3:02
















        19














        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
        or:
        pdftk A=in1.pdf cat A1-12 A14-end output out1.pdf

        Burst a single PDF document into pages and dump its data to
        doc_data.txt
        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
























        • Package 'pdftk' has no installation candidate

          – FireInTheSky
          Oct 21 '18 at 3:02














        19












        19








        19







        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
        or:
        pdftk A=in1.pdf cat A1-12 A14-end output out1.pdf

        Burst a single PDF document into pages and dump its data to
        doc_data.txt
        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













        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
        or:
        pdftk A=in1.pdf cat A1-12 A14-end output out1.pdf

        Burst a single PDF document into pages and dump its data to
        doc_data.txt
        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












        share|improve this answer



        share|improve this answer










        answered Oct 29 '14 at 18:23









        Andrzej PronobisAndrzej Pronobis

        577412




        577412













        • Package 'pdftk' has no installation candidate

          – FireInTheSky
          Oct 21 '18 at 3:02



















        • Package 'pdftk' has no installation candidate

          – FireInTheSky
          Oct 21 '18 at 3:02

















        Package 'pdftk' has no installation candidate

        – FireInTheSky
        Oct 21 '18 at 3:02





        Package 'pdftk' has no installation candidate

        – FireInTheSky
        Oct 21 '18 at 3:02











        15














        In any system that a TeX distribution is installed:



        pdfjam <input file> <page ranges> -o <output file>


        For example:



        pdfjam original.pdf 5-10 -o out.pdf


        See https://tex.stackexchange.com/a/79626/8666






        share|improve this answer
























        • this was the only one that worked for me .

          – FireInTheSky
          Oct 21 '18 at 3:12
















        15














        In any system that a TeX distribution is installed:



        pdfjam <input file> <page ranges> -o <output file>


        For example:



        pdfjam original.pdf 5-10 -o out.pdf


        See https://tex.stackexchange.com/a/79626/8666






        share|improve this answer
























        • this was the only one that worked for me .

          – FireInTheSky
          Oct 21 '18 at 3:12














        15












        15








        15







        In any system that a TeX distribution is installed:



        pdfjam <input file> <page ranges> -o <output file>


        For example:



        pdfjam original.pdf 5-10 -o out.pdf


        See https://tex.stackexchange.com/a/79626/8666






        share|improve this answer













        In any system that a TeX distribution is installed:



        pdfjam <input file> <page ranges> -o <output file>


        For example:



        pdfjam original.pdf 5-10 -o out.pdf


        See https://tex.stackexchange.com/a/79626/8666







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Sep 1 '17 at 20:18









        Ioannis FilippidisIoannis Filippidis

        25327




        25327













        • this was the only one that worked for me .

          – FireInTheSky
          Oct 21 '18 at 3:12



















        • this was the only one that worked for me .

          – FireInTheSky
          Oct 21 '18 at 3:12

















        this was the only one that worked for me .

        – FireInTheSky
        Oct 21 '18 at 3:12





        this was the only one that worked for me .

        – FireInTheSky
        Oct 21 '18 at 3:12











        7














        Have you tried PDF Mod?



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



        Description:



        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.



        Regars.






        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











        • I use it regularly, great tool! but I had a document with about 170 pages that pdfmod could not handle.

          – loved.by.Jesus
          Oct 16 '16 at 20:54











        • Wow. This is surprisingly smooth. Threw my 512 page real book at it (50MiB) and it... was prompt. UI is a breeze. For a CLI junkie like me it takes some level of GUI to convince me, but this will do!

          – sehe
          Oct 12 '17 at 6:50











        • PDF Mod has bugs running in Kubuntu 18

          – Joshua Salazar
          Oct 3 '18 at 18:37
















        7














        Have you tried PDF Mod?



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



        Description:



        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.



        Regars.






        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











        • I use it regularly, great tool! but I had a document with about 170 pages that pdfmod could not handle.

          – loved.by.Jesus
          Oct 16 '16 at 20:54











        • Wow. This is surprisingly smooth. Threw my 512 page real book at it (50MiB) and it... was prompt. UI is a breeze. For a CLI junkie like me it takes some level of GUI to convince me, but this will do!

          – sehe
          Oct 12 '17 at 6:50











        • PDF Mod has bugs running in Kubuntu 18

          – Joshua Salazar
          Oct 3 '18 at 18:37














        7












        7








        7







        Have you tried PDF Mod?



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



        Description:



        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.



        Regars.






        share|improve this answer















        Have you tried PDF Mod?



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



        Description:



        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.



        Regars.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 11 '17 at 19:03









        Community

        1




        1










        answered Nov 26 '12 at 2:17









        Roman RaguetRoman Raguet

        8,21113139




        8,21113139













        • 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











        • I use it regularly, great tool! but I had a document with about 170 pages that pdfmod could not handle.

          – loved.by.Jesus
          Oct 16 '16 at 20:54











        • Wow. This is surprisingly smooth. Threw my 512 page real book at it (50MiB) and it... was prompt. UI is a breeze. For a CLI junkie like me it takes some level of GUI to convince me, but this will do!

          – sehe
          Oct 12 '17 at 6:50











        • PDF Mod has bugs running in Kubuntu 18

          – Joshua Salazar
          Oct 3 '18 at 18:37



















        • 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











        • I use it regularly, great tool! but I had a document with about 170 pages that pdfmod could not handle.

          – loved.by.Jesus
          Oct 16 '16 at 20:54











        • Wow. This is surprisingly smooth. Threw my 512 page real book at it (50MiB) and it... was prompt. UI is a breeze. For a CLI junkie like me it takes some level of GUI to convince me, but this will do!

          – sehe
          Oct 12 '17 at 6:50











        • PDF Mod has bugs running in Kubuntu 18

          – Joshua Salazar
          Oct 3 '18 at 18:37

















        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





        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













        I use it regularly, great tool! but I had a document with about 170 pages that pdfmod could not handle.

        – loved.by.Jesus
        Oct 16 '16 at 20:54





        I use it regularly, great tool! but I had a document with about 170 pages that pdfmod could not handle.

        – loved.by.Jesus
        Oct 16 '16 at 20:54













        Wow. This is surprisingly smooth. Threw my 512 page real book at it (50MiB) and it... was prompt. UI is a breeze. For a CLI junkie like me it takes some level of GUI to convince me, but this will do!

        – sehe
        Oct 12 '17 at 6:50





        Wow. This is surprisingly smooth. Threw my 512 page real book at it (50MiB) and it... was prompt. UI is a breeze. For a CLI junkie like me it takes some level of GUI to convince me, but this will do!

        – sehe
        Oct 12 '17 at 6:50













        PDF Mod has bugs running in Kubuntu 18

        – Joshua Salazar
        Oct 3 '18 at 18:37





        PDF Mod has bugs running in Kubuntu 18

        – Joshua Salazar
        Oct 3 '18 at 18:37











        7














        I was trying to do the same. All you have to do is:





        1. install pdftk:



          sudo apt-get install pdftk



        2. if you want to extract random pages:



          pdftk myoldfile.pdf cat 1 2 4 5 output mynewfile.pdf



        3. if you want to extract a range:



          pdftk myoldfile.pdf cat 1-2 4-5 output mynewfile.pdf



        Please check the source for more infos.






        share|improve this answer


























        • I find this answer best because it shows how you can input multiple ranges.

          – Roman Luštrik
          Nov 7 '18 at 8:41
















        7














        I was trying to do the same. All you have to do is:





        1. install pdftk:



          sudo apt-get install pdftk



        2. if you want to extract random pages:



          pdftk myoldfile.pdf cat 1 2 4 5 output mynewfile.pdf



        3. if you want to extract a range:



          pdftk myoldfile.pdf cat 1-2 4-5 output mynewfile.pdf



        Please check the source for more infos.






        share|improve this answer


























        • I find this answer best because it shows how you can input multiple ranges.

          – Roman Luštrik
          Nov 7 '18 at 8:41














        7












        7








        7







        I was trying to do the same. All you have to do is:





        1. install pdftk:



          sudo apt-get install pdftk



        2. if you want to extract random pages:



          pdftk myoldfile.pdf cat 1 2 4 5 output mynewfile.pdf



        3. if you want to extract a range:



          pdftk myoldfile.pdf cat 1-2 4-5 output mynewfile.pdf



        Please check the source for more infos.






        share|improve this answer















        I was trying to do the same. All you have to do is:





        1. install pdftk:



          sudo apt-get install pdftk



        2. if you want to extract random pages:



          pdftk myoldfile.pdf cat 1 2 4 5 output mynewfile.pdf



        3. if you want to extract a range:



          pdftk myoldfile.pdf cat 1-2 4-5 output mynewfile.pdf



        Please check the source for more infos.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 26 '16 at 13:05









        David Foerster

        28.3k1365111




        28.3k1365111










        answered May 3 '16 at 4:00









        theCodetheCode

        18116




        18116













        • I find this answer best because it shows how you can input multiple ranges.

          – Roman Luštrik
          Nov 7 '18 at 8:41



















        • I find this answer best because it shows how you can input multiple ranges.

          – Roman Luštrik
          Nov 7 '18 at 8:41

















        I find this answer best because it shows how you can input multiple ranges.

        – Roman Luštrik
        Nov 7 '18 at 8:41





        I find this answer best because it shows how you can input multiple ranges.

        – Roman Luštrik
        Nov 7 '18 at 8:41











        6














        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.



        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



        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






        • 1





          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






        • 2





          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
















        6














        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.



        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



        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






        • 1





          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






        • 2





          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














        6












        6








        6







        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.



        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



        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















        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.



        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



        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














        share|improve this answer



        share|improve this answer








        edited Dec 17 '15 at 20:48

























        answered Apr 19 '13 at 0:54









        carnendilcarnendil

        4,86512252




        4,86512252













        • 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






        • 1





          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






        • 2





          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



















        • 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






        • 1





          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






        • 2





          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

















        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





        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




        1




        1





        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





        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




        2




        2





        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





        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











        2














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



        Download from here






        share|improve this answer





















        • 1





          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











        • The latest 3.x (currently 3.1.0) has a .deb package that can be installed on Ubuntu and has an Extract Pages module that does what the OP asked

          – Andrea Vacondio
          Aug 6 '16 at 8:25






        • 1





          @Andrea Vacondio Bravo for your excellent edit! You're helping to make the internet safe. I found out that the file from the old link at sourceforge.net has crap embedded in it . The new owners of the SourceForge website said they were going to stop doing this, but obviously they lied.

          – karel
          Aug 6 '16 at 8:41


















        2














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



        Download from here






        share|improve this answer





















        • 1





          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











        • The latest 3.x (currently 3.1.0) has a .deb package that can be installed on Ubuntu and has an Extract Pages module that does what the OP asked

          – Andrea Vacondio
          Aug 6 '16 at 8:25






        • 1





          @Andrea Vacondio Bravo for your excellent edit! You're helping to make the internet safe. I found out that the file from the old link at sourceforge.net has crap embedded in it . The new owners of the SourceForge website said they were going to stop doing this, but obviously they lied.

          – karel
          Aug 6 '16 at 8:41
















        2












        2








        2







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



        Download from here






        share|improve this answer















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



        Download from here







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Aug 6 '16 at 8:38









        Andrea Vacondio

        1234




        1234










        answered Jun 1 '13 at 10:45









        To DoTo Do

        8,68194992




        8,68194992








        • 1





          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











        • The latest 3.x (currently 3.1.0) has a .deb package that can be installed on Ubuntu and has an Extract Pages module that does what the OP asked

          – Andrea Vacondio
          Aug 6 '16 at 8:25






        • 1





          @Andrea Vacondio Bravo for your excellent edit! You're helping to make the internet safe. I found out that the file from the old link at sourceforge.net has crap embedded in it . The new owners of the SourceForge website said they were going to stop doing this, but obviously they lied.

          – karel
          Aug 6 '16 at 8:41
















        • 1





          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











        • The latest 3.x (currently 3.1.0) has a .deb package that can be installed on Ubuntu and has an Extract Pages module that does what the OP asked

          – Andrea Vacondio
          Aug 6 '16 at 8:25






        • 1





          @Andrea Vacondio Bravo for your excellent edit! You're helping to make the internet safe. I found out that the file from the old link at sourceforge.net has crap embedded in it . The new owners of the SourceForge website said they were going to stop doing this, but obviously they lied.

          – karel
          Aug 6 '16 at 8:41










        1




        1





        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





        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













        The latest 3.x (currently 3.1.0) has a .deb package that can be installed on Ubuntu and has an Extract Pages module that does what the OP asked

        – Andrea Vacondio
        Aug 6 '16 at 8:25





        The latest 3.x (currently 3.1.0) has a .deb package that can be installed on Ubuntu and has an Extract Pages module that does what the OP asked

        – Andrea Vacondio
        Aug 6 '16 at 8:25




        1




        1





        @Andrea Vacondio Bravo for your excellent edit! You're helping to make the internet safe. I found out that the file from the old link at sourceforge.net has crap embedded in it . The new owners of the SourceForge website said they were going to stop doing this, but obviously they lied.

        – karel
        Aug 6 '16 at 8:41







        @Andrea Vacondio Bravo for your excellent edit! You're helping to make the internet safe. I found out that the file from the old link at sourceforge.net has crap embedded in it . The new owners of the SourceForge website said they were going to stop doing this, but obviously they lied.

        – karel
        Aug 6 '16 at 8:41













        2














        As the original user asked for an interactive tool and not a command line tool: An easy solution is to use any PDF viewer (okular on Kubuntu, evince or even Firefox on Ubuntu) and then just use the standard print dialog, choose "print to PDF file", and then select in the extended settings dialog, which pages to "print". This variant has some drawbacks, as some gimmicks on the original PDF (like rotated pages, forms etc.) might get lost, but it works straightforward for most simple PDFs.






        share|improve this answer




























          2














          As the original user asked for an interactive tool and not a command line tool: An easy solution is to use any PDF viewer (okular on Kubuntu, evince or even Firefox on Ubuntu) and then just use the standard print dialog, choose "print to PDF file", and then select in the extended settings dialog, which pages to "print". This variant has some drawbacks, as some gimmicks on the original PDF (like rotated pages, forms etc.) might get lost, but it works straightforward for most simple PDFs.






          share|improve this answer


























            2












            2








            2







            As the original user asked for an interactive tool and not a command line tool: An easy solution is to use any PDF viewer (okular on Kubuntu, evince or even Firefox on Ubuntu) and then just use the standard print dialog, choose "print to PDF file", and then select in the extended settings dialog, which pages to "print". This variant has some drawbacks, as some gimmicks on the original PDF (like rotated pages, forms etc.) might get lost, but it works straightforward for most simple PDFs.






            share|improve this answer













            As the original user asked for an interactive tool and not a command line tool: An easy solution is to use any PDF viewer (okular on Kubuntu, evince or even Firefox on Ubuntu) and then just use the standard print dialog, choose "print to PDF file", and then select in the extended settings dialog, which pages to "print". This variant has some drawbacks, as some gimmicks on the original PDF (like rotated pages, forms etc.) might get lost, but it works straightforward for most simple PDFs.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 26 '18 at 10:36









            Kai PetzkeKai Petzke

            1212




            1212























                0














                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






























                  0














                  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




























                    0












                    0








                    0







                    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















                    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














                    share|improve this answer



                    share|improve this answer








                    edited Feb 14 '14 at 17:59









                    Waldir Leoncio

                    1,62041938




                    1,62041938










                    answered Feb 14 '14 at 17:34









                    JamesJames

                    91




                    91























                        0














                        Found this tool and am quite happy with it: https://pdf.io/split/






                        share|improve this answer








                        New contributor




                        YakovK is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                        Check out our Code of Conduct.

























                          0














                          Found this tool and am quite happy with it: https://pdf.io/split/






                          share|improve this answer








                          New contributor




                          YakovK is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.























                            0












                            0








                            0







                            Found this tool and am quite happy with it: https://pdf.io/split/






                            share|improve this answer








                            New contributor




                            YakovK is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.










                            Found this tool and am quite happy with it: https://pdf.io/split/







                            share|improve this answer








                            New contributor




                            YakovK is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.









                            share|improve this answer



                            share|improve this answer






                            New contributor




                            YakovK is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.









                            answered 6 hours ago









                            YakovKYakovK

                            1




                            1




                            New contributor




                            YakovK is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.





                            New contributor





                            YakovK is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.






                            YakovK is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.






























                                draft saved

                                draft discarded




















































                                Thanks for contributing an answer to Ask Ubuntu!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f221962%2fhow-can-i-extract-a-page-range-a-part-of-a-pdf%23new-answer', 'question_page');
                                }
                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                數位音樂下載

                                When can things happen in Etherscan, such as the picture below?

                                格利澤436b