Merge / convert multiple PDF files into one PDF
Solution 1
I'm sorry, I managed to find the answer myself using google and a bit of luck : )
For those interested;
I installed the pdftk (pdf toolkit) on our debian server, and using the following command I achieved desired output:
pdftk file1.pdf file2.pdf cat output output.pdf
OR
gs -q -sPAPERSIZE=letter -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=output.pdf file1.pdf file2.pdf file3.pdf ...
This in turn can be piped directly into pdf2ps.
Solution 2
Considering that pdfunite
is part of poppler it has a higher chance to be installed, usage is also simpler than pdftk
:
pdfunite in-1.pdf in-2.pdf in-n.pdf out.pdf
Just make sure you remember to provide out.pdf
, or else it will overwrite the last file in your command
Solution 3
Try the good ghostscript:
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=merged.pdf mine1.pdf mine2.pdf
or even this way for an improved version for low resolution PDFs (thanks to Adriano for pointing this out):
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -sOutputFile=merged.pdf mine1.pdf mine2.pdf
In both cases the ouput resolution is much higher and better than this way using convert:
convert -density 300x300 -quality 100 mine1.pdf mine2.pdf merged.pdf
In this way you wouldn't need to install anything else, just work with what you already have installed in your system (at least both come by default in my box).
UPDATE: first of all thanks for all your nice comments!! just a tip that may work for you guys, after googleing, I found a superb trick to shrink the size of PDFs, I reduced with it one PDF of 300 MB to just 15 MB with an acceptable resolution! and all of this with the good ghostscript, here it is:
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/default -dNOPAUSE -dQUIET -dBATCH -dDetectDuplicateImages -dCompressFonts=true -r150 -sOutputFile=output.pdf input.pdf
cheers!!
Solution 4
This is the easiest solution if you have multiple files and do not want to type in the names one by one:
qpdf --empty --pages *.pdf -- out.pdf
Solution 5
Also pdfjoin a.pdf b.pdf
will create a new b-joined.pdf
with the contents of a.pdf and b.pdf
Comments
-
alcohol almost 2 years
How could I merge / convert multiple PDF files into one large PDF file?
I tried the following, but the content of the target file was not as expected:
convert file1.pdf file2.pdf merged.pdf
I need a very simple/basic command line (CLI) solution. Best would be if I could pipe the output of the merge / convert straight into
pdf2ps
( as originally attempted in my previously asked question here: Linux piping ( convert -> pdf2ps -> lp) ).-
sabujp over 8 yearsymmv, but this doesn't seem to have as good of a resolution in the output file as pdfunite and it also results in a file size larger than the output from pdfunite
-
Franck Dernoncourt over 7 years
-
Clément about 4 yearsWhenever links are preserved or not by those solutions is discussed in this post. If you want to preserve the links (probably along with other annotations), use pdftk if want a command-line interface, pdfsam if you want graphical user interface, sejda if you want a web interface.
-
Alexis Wilke over 2 yearsThe
convert
command line is from ImageMagick and it converts the PDF to an image before doing whatever else it will be doing.
-
-
Nate Kohl about 14 yearsUsing ghostscript also might work:
gs -q -sPAPERSIZE=letter -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=out.pdf in1.pdf in2.pdf in3.pdf ...
-
alcohol about 14 yearsI'd have to look more into the possible options/flags (because I don't want output in a file), but probably yes. Thank you for the suggestion.
-
Thomas about 11 yearsIt is worth to mention that pdftk can merge encrypted pdfs while pdfunite cant
-
taxilian almost 11 yearsPoppler is also very fast, from my tests
-
Danilo Bargen almost 11 yearsIt is fast, but it seems to break hyperlinks. See blog.dbrgn.ch/2013/8/14/merge-multiple-pdfs
-
mlissner over 10 yearsJust make sure you remember to provide out.pdf, or else it will overwrite the last file in your command, sigh.
-
Jocelyn delalande over 10 yearspackage for pdfunite is poppler-utils in debian but may not be present in old debian releases.
-
Torben over 10 yearsCannot recommend this. The size of the the resulting PDF is far too big. For example: Pdfunite gives me a 75MB file while Ghostscript packs everything into 1MB.
-
Adriano P over 10 yearsNice tip,
gs
runs very fast and it compresses a lot. However, the quality improved a lot after I used this param:-dPDFSETTINGS=/prepress
-
Aaron R. over 10 yearsHmmm... @Torben I just packed 300+ pdfs (total of 13MB) into a single PDF using this utility and I got a 12MB file at the end. Maybe it was the version you used? I am on OpenSUSE 12.2, using pdfunite version 0.20.0.
-
Torben over 10 years@Aaaron My comment was a bit misleading. What I meant is that pdfunite doesn't optimize the filesize. For example: 10 similar pdfs (slides for a presentation) of 1MB result in a ~10MB pdf when I use pdfunite. With ghostscript the resulting pdf is <1MB.
-
Kiran K Telukunta about 10 yearsgives better resolution with pdftk compare to convert in default options.
-
ahrobins about 10 yearsIn my case pdfunite did not produce a usable PDF file. When I loaded it with
evince
I got lots of errors. Thegs
solution worked. -
Ben Ruijl almost 10 yearsThis is not lossless.
-
arielnmz almost 10 yearsYou can
convert -compress lossless sub1.pdf sub2.pdf sub3.pdf merged.pdf
, but the resulting file size's could be way too big. I'd suggestconvert -compress jpeg -quality 90 sub1.pdf sub2.pdf sub3.pdf merged.pdf
instead. -
r_31415 almost 10 yearsI found that
-dPDFSETTINGS=/prepress
has the very nice effect of rotating pages that are too wide and force annoying horizontal scroll bars. -
Julia Ebert almost 10 yearsThis involves converting everything to raster images, it seems, which is definitely not the best, especially when dealing with text-based PDFs.
-
bright-star over 9 yearsThis is nice and succinct, but breaks hyperlinks.
-
mdrozdziel over 9 yearspdfjoin (pdflatex) fails with files with lots of pages. Failed to merge to 1k pages files.
-
lepe over 9 yearsYou can use:
pdfunite *.pdf out.pdf
assuming no other pdf exists in that directory and their order is preserved by "*". If its not preserved, using ranges: filename_{0..9}.pdf solves it. -
Nathan Tuggy about 9 yearsGiven how similar this looks to the original question, it seems like this should have been a comment, not an answer. With a bit more rep, you will be able to post comments. Until then, please do not use answers as a workaround.
-
peterh about 9 years@Silfheed No, it answers the question! Although the answer maybe should have more elaborated.
-
ryantm almost 9 yearspdfunite worked much worse for my use case than pdftk. I was trying to combine together copies of a particular form into the same pdf. In pdfunite they were linked, in pdftk they were separated and could be filled out individually.
-
MariuszS almost 9 years@Torben The file is smaller with gs because with default settings image has reduced quality (screen-view-only quality, 72 dpi images). With
-dPDFSETTINGS=/printer
file size is almost identical (high quality, 300 dpi images). -
Torben almost 9 years@MariuszS Even though you might be right for some special cases, you're wrong with you're general assumption. I just merged 133MB of PDFs (84 files exported from Inkscape), which contain bitmaps, vectorgraphics and text, into one PDF with a size of 1.6MB. I used
/prepress
for that and/printer
even reduced the size to 1.3MB. Even though I zoomed in and printed a part, I couldn't find any visible difference between the single PDF and the merged version. I'm pretty sure Ghostscript compares the merged PDFs and stores shared content just for one time. -
Torben almost 9 yearsAdd the following line to your
.bash_profile
and you have a nice shortcut:pdfmerge() { gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -sOutputFile=$@ ; }
This saves you some typing, if you have to use the command a lot. The usage looks like this:pdfmerge merged.pdf mine1.pdf mine2.pdf
-
Michal Gonda over 8 yearsI tried to find description for -dBATCH flag but couldn't. Even man gs doesn't say anything. But great and without any additional programs!
-
jmiserez over 8 years
pdftk file1.pdf file2.pdf cat output out.pdf
will output the merged file asout.pdf
-
user829755 over 8 yearsalmost a copy of what the OP has described as not working
-
Sablefoste over 8 yearsSince Imagemagick is based upon Ghostscript, if you already have it, you can use it as well;
convert file1.pdf file2.pdf outputfile.pdf
. -
markgalassi over 8 yearsDo not use convert for postscript or PDF files unless you go from vector to raster and never go back. It is hard to overstate what a bad idea this is.
-
markgalassi over 8 yearsDo not use convert for postscript or PDF files unless you go from vector to raster and never go back. It is hard to overstate what a bad idea this is.
-
markgalassi over 8 yearsDo not use convert for postscript or PDF files unless you go from vector to raster and never go back. It is hard to overstate what a bad idea this is.
-
firegurafiku over 8 yearsWhat is the point of using
$(ls *.pdf)
in place of simple wildcard*.pdf
? -
sabujp about 8 yearspdfjoin breaks annotations or additional non graphics items
-
a coder about 8 years
pdftk
is not available for EL7 systems due to missing dependencylibgcj
. -
Paul Rougieux about 8 years@DaniloBargen
pdfunite
doesn't break external hyperlinks. I have merged documents with links. Links were kept functional. Butpdfunite
might break internal hyperlinks as indicated in the blog you mentioned. -
Mahendar Patel about 8 years@NateKohn @IcyFlame Unfortunately it did not work for me - said
Unknown device: pdfwriter
. Like you I preferred that approach because I had it installed already.pdftk
worked like a charm though. -
gaoithe over 7 yearspdfunite worked well for me. preserved resolution of original pdfs. pdf size simple addition of original pdfs. convert -compress lossless did the same as convert, resolution lost and file size much increased. pdfunite version 0.22.1 vs ImageMagick 6.7.8-9. 69k + 130k pdf => 198k with pdfunite, => 771k with convert. text+gfx(originally odt) + gfx(pdf print to pdf) pdf.
-
v_2e over 7 yearsThe "URW Palladio L" font became invisible after pdfjoin'ing the pages.
-
Charles-Édouard Coste over 7 yearsIf you don't want to type each file name :
pdftk ``ls *.pdf`` cat output out.pdf
(with just one backticks instead of two, but I didn't manage to render it with the stackoverflow markdown parser) -
JAB over 7 years@RobertSmith Interestingly, when I tried the first command it rotated some pages (that seemed to be the same proportions as the others) while the
/prepress
version did no rotation. -
Zelphir Kaltstahl over 7 years@Charles-EdouardCoste You can use two backticks as surrounding backticks if you want to use backticks inside. Or three, if you want to use double backticks. Not sure if it goes even higher. But backticks is not recommended anymore in Bash, so better would be to use
$(ls *.pdf)
-
Zelphir Kaltstahl over 7 years@alcohol What does the
cat
in this command (not in general) do? I was able to merge two pdfs without that and don't see any issues with the resulting pdf. -
Calaf over 7 yearspdfunite usually works well, but if it says "Unimplemented Feature: Could not merge encrypted files ", pdfjoin is a nice alternative. For whatever reason, pdfjoin doesn't complain of encryption.
-
alcohol about 7 years@Zelphir cat is the operation here (that pdftk performs), not the shell command.
-
Bhoom Suktitipat about 7 yearsWorks for me natively (probably) without any installation on MacOs Sierra (OsX).
-
salotz about 7 yearsDoesn't work with a pdf I have gives
Unimplemented Feature: Could not merge encrypted files ('MR1418_introduction.pdf')
. Butpdftk
was able to handle it, albeit admonishing me for not having some passwords you don't need. -
z0r almost 7 years
pdftk
is neat because you can easily select page ranges to merge:pdftk A=file1.pdf B=file2.pdf cat A1-3 B1 output out.pdf
-
awelkie almost 7 yearsI like this solution because it keeps section headers that I can use to jump around with my pdf software
-
Campa almost 7 yearsIncredibly much faster than
convert
, and the resolution does not get worse. TOP -
enkiv2 over 6 years"Argument list too long" indicates that you're going over the shell's allocated buffer size for the environment -- it's not actually a limitation of the tool. In such a case, switching to Python may be overkill, since you can just batch: find input -name *.pdf | xargs -P1 -n500 sh -c 'pdfunite "$@" output-
date +%s
.pdf' && pdfunite output-*.pdf output.pdf (This will create batches of 500 files processed serially, make the resulting temporary files sort in the right order, and produce an appropriate output file; you'll need to clean up the temporary files after) -
Mingwei Zhang over 6 yearsFor my usage,
pdftk
somehow just stuck and not producing anything, whilegs
gives perfect result.convert
's resolution download is true (with default setting). -
Nostradamnit over 6 yearsStill works to perfection. I didn't see any size change either; 9.2 mb of files made a single 9.2mb file. Didn't have any hyperlinks, so can't comment on that aspect.
-
Diego 72 over 6 yearsSince
GCJ
is deprecated link),pdftk
is as well (most distros phased it out already). A nice alternative ispdfunite
and the other poppler-utils. -
palik over 6 years
v2.08
ofpdfjoin
doesn't proper work for me. One of the input PDF-files contains filled forms. But no inputs appear in the result PDF-file. -
bjd2385 about 6 yearsJust put the following in a bash script:
pdfunite $@ out.pdf
-
Antek about 6 years
gs
for joining documents apparently created under Windows gave me this errorMissing glyph CID=48, glyph=0030 in the font EAAAAB+Tahoma,Bold . The output PDF may fail with some viewers.
and indeed, on the default Ubuntu viewer I couldn't browse it -
Egel almost 6 yearsAdditionally with reference to @firegurafiku answer, with
ls *.pdf
wildcard you lose a control over the order of merged files. In an example, the following list: 1.pdf, 2.pdf, 3.pdf, ..., 10.pdf, ..., 100.pdf will actually be merged like 1.pdf, 10.pdf, 100.pdf, 2.pdf, 3.pdf (due to default Linux way of ordering files - here you have more details about this problem - stackoverflow.com/q/22948042/1977012). -
Pysis almost 6 yearsBeautiful answer. I was having a ton of frustration ever since I heard Mac's Preview application could help, but I barely got it to work the first time, and none the second time I needed it. The biggest trouble was it not being determinant with its actions. I used to be able to drag entire PDF files over, but tried invidiual thumbnails, and also had saving issues between a new copy and at all! So this solution was a nice break. The only additional task I had was throwing in a GIF image at the end using Preview since Ghostscript could not handle that. Also installed from Homebrew!
-
k.stm over 5 yearsSo much this. Parabola for instance doesn’t package
pdftk
anymore either because of its dependance ongcj
, for which support has been dropped I believe. Despite searching for pdf manipulation tools viapacman -Ss pdf
, I missed this. Thanks for this answer! I should receive way more upvotes, so it shows up right next to suggestions forpdfunite
orpdftk
. -
Tom Russell over 5 years@AaronR Happy to report working well on openSuse Leap 42.3. Its speed is quite blazing, combining 100-odd pages in less than a second.
-
supergra over 5 yearsThis is perfect. Using
gs
(all variants listed above), a simple merge of two PDFs, 2MB and 500Kb, was taking minutes to complete and resulting in a 40MB file!pdftools
completes instantaneously with identical file size. -
Winny over 5 yearsBreaks hyperlinks.
-
Winny over 5 yearsThis preserves hyperlinks. Nice!
-
adonese over 5 yearsI'm just gonna run this command so that it will be saved to my fish history! I'll definitely need it in the future.
-
Jimbo over 5 yearsThe version from the official website doesn't work. This answer does as of January 2019 (still official).
-
mvreijn over 5 yearsA note about PDF Forms. Thusfar,
pdftk
is the only tool I have tried that preserves my PDF forms exactly as they were (functional in any PDF reader plus Acrobat Reader). -
Admin over 5 years@Winny, for me it didn't preserve hyperlinks. any idea why?
-
Winny over 5 years@EnanAjmain I used
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -sOutputFile=output.pdf a.pdf b.pdf c.pdf
This worked for me -
Admin over 5 yearsI used it too. But in my case it didn't work. I then used an online service. Thanks for replying.
-
MiniMax about 5 yearsThe
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -sOutputFile=merged.pdf mine1.pdf mine2.pdf
can be shortened to thegs -q -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -o merged.pdf mine1.pdf mine2.pdf
. From Documentation: "As a convenient shorthand you can use the-o
option followed by the output file specification as discussed above. The-o
option also sets the-dBATCH
and-dNOPAUSE
options. This is intended to be a quick way to invokeghostscript
to convert one or more input files." -
Wallace Kelly almost 5 yearsOn my fresh install of Linux Mint, this ran in the Terminal window without requiring any installs or path adjustments. Nice!
-
Freedom_Ben over 4 years
pdftk
is deprecated and no longer available in Fedora repos for example. If you can't usepdfunite
cause encryption, then try pdf-stapler: github.com/hellerbarde/stapler -
JonShipman over 4 yearsThis also works well in windows with WSL. Install ghostscript from apt first.
-
doak over 4 yearsI was used to
pdfunite
, but it resulted today in a 850 MB PDF (original 24 MB).pdftk
did it with 44 MB,gs
with only 32 MB (both with top resolution as far as I can tell). -
David Granqvist over 4 yearsqpdf seems to break hyperlinks in the document
-
Skippy le Grand Gourou over 4 years
pdftk
also allows to duplicate pages within a single document :pdftk input.pdf cat 1-10 10 10 10 10-20 output output.pdf
would produceinput.pdf
with 5 times the page 10. -
Jonathan Holvey over 4 yearsAlthough difficult to get your head around the complex options to start with, qpdf is a very handy and powerful tool. Online documentation is available here
-
minexew over 4 yearsIt seems that page numbers from individual documents are also not preserved. (pdfunite version 0.73.0)
-
ostrokach over 4 years
sudo apt-get install poppler-utils
-
Yai0Phah over 4 yearsStrange enough. After merging with
gs
, some of pages are rotated. -
Siwoku Adeola about 4 yearsThis worked perfectly and also gave a clearer merged document that the other commands I tried out. Thanks for the post.
-
mario ruiz about 4 yearsOMHO the best to tool to do these type of tasks
-
alphaGeek almost 4 yearsgs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -sOutputFile=merged.pdf mine1.pdf mine2.pdf This worked perfectly on cygwin @Win 10 64 bit machine. Thanks
-
Henrik Pingel almost 4 years
-
Hashim Aziz almost 4 yearsCame here looking for a
qpdf
solution but didn't want to wade through the documentation yet again to figure it out, thank you. -
Gabriel Staples almost 4 yearsWATCH OUT! The last input parameter is where the program writes the output, so if you accidentally forget
out.pdf
and dopdfunite in1.pdf in2.pdf
instead ofpdfunite in1.pdf in2.pdf out.pdf
, you'll have just accidentally writtenin1.pdf
right on top ofin2.pdf
, ruining it! Don't do that. -
lmat - Reinstate Monica over 3 yearsUsing a shell wildcard is great as long as the order works for you! Check the order first with
echo *.pdf | tr ' ' $'\n'
or so! -
qdread over 3 years@Winny I needed to add
dPrinted=false
to preserve hyperlinks. Otherwise it broke the links for all but the first pdf. See tex.stackexchange.com/questions/245801/… -
Rainb over 3 years
pdftk
is a hell to install -
KCD over 3 yearsDifferent pages size, want to "shrink to fit"? Try another tool included in poppler:
pdftocairo -pdf -paper A4 in.pdf out.pdf
... and make backups as people point out you can override inputs -
tejasvi88 over 3 yearsOr you can install it anyway. Total size of dependencies is < 100 kb.
-
tejasvi88 over 3 years
pdftools
is a wrapper for PyPDF2. See this answer. -
pts over 3 yearsGhostscript does many lossy transformations (e.g. page rotation, image quality degradation and dropping some metadata) during PDF-to-PDF conversion. If you want to have a peace of mind of having all PDF features intact, then don't use Ghostscript.
-
Rainb over 3 years@pts sure, or you can just use custom flags, so that ghostscript doesn't use lossy compression. superuser.com/questions/360216/…
-
caram over 3 yearsIf pages in the even.pdf file are reversed (typical when you scan on a non-double-sided scanner), you will want to use this instead:
qpdf --collate --empty --pages odd.pdf even.pdf z-1 -- merged.pdf
-
pts over 3 years@Rainb: The PDF output of Ghostscript is lossy even if it is configured to use lossless image compression, because Ghostscript ignores some PDF features (e.g. interactive).
-
Ethan Brown over 3 yearsI did not find that pdfunite created unreasonably large files. My two input files were both about 500k and the resulting output file was about 1 MB as one would expect.
-
Antonin GAVREL about 3 yearsNice script. You can arrange the order by prefixing each page with "A_", "B_" etc or simply add
'z'
if one document is at page 1 and you want it to be at the last page, assuming your files are named with letters and digits, and not starting with 'z'. -
Charles D Pantoga about 3 yearscan be installed with homebrew +1 havent tried yet
-
xZero about 3 yearsI was fast to use it and not read the comments, so it overwrote the last file. Silly me run "pdfunite *.pdf" and then wondered where's the output file until I realized... Luckily I had a backup; It's always a good idea to have a backup.
-
Tarick Welling about 3 yearsThis is quite the undervalued answer. The
qpdf
tool is great -
Andrea Vacondio about 3 yearsThis is no longer open source
-
Doberon about 3 yearsit's true, qpdf is multi platform, portable and possible used at scripts
-
Doberon about 3 yearsfor extract qpdf "in.pdf" --pages . 1 -- "out.pdf"
-
Ingo Mi almost 3 yearsWhat is the command for papersize A4? Thanks for your answer.
-
Admin almost 3 yearsQpdf is high in quality and actively maintained, which makes it a much better option than pdftk.
-
Admin almost 3 yearsPdftk is old, buggy, and not well maintained. It uses a fork of the iText library that is buggy. It has poor error handling and can fail on pdf 1.5 input files. Qpdf is a higher-quality alternative for most of its functionality.
-
tripleee almost 3 years"Likely to be installed" depends entirely on your Linux distro. It's probably true e.g. for Ubuntu and very probably not true for Alpine or Gentoo.
-
tripleee almost 3 years@bjd2385 An unquoted
$@
is always an error; you want"$@"
. Without the quotes, it will break on file names which contain whitespace or shell metacharacters. -
tripleee almost 3 yearsThe package name probably refers to a Debian package.
-
rickhg12hs over 2 yearsSo far,
qpdf
seems to generate the best output where other viewing tools find no errors/issues. -
Rainb over 2 yearsGhostscript tends to fail if with some pdfs, what a shame
-
chillitom about 2 yearsIn the case of an error about encrypted documents try the following first:
ls *.pdf | xargs -I '{}' qpdf --decrypt {} --replace-input
-
Gabriel Staples about 2 years
pdfunite
broke my output PDF by deleting entire pages of fields I had filled in in this PDF here. I ranpdfunite in1.pdf in2.pdf out.pdf
. I don't know why it did that, but it must be some issue with the metadata which stores the filled-in text fields inside the fillable PDF, or something. Usingpdftk
, as described here, however, worked perfectly:pdftk in1.pdf in2.pdf cat output out.pdf
. -
Gabriel Staples about 2 yearsI then ran my tool:
pdf2searchablepdf out.pdf
for good measure, to ensure the PDF metadata fillable fields get turned into an image and then OCRed back into a PDF, in order to remove the metadata fields to ensure I don't have problems printing it at Staples, which also was unable to print properly some of the metadata fields in the original PDF. -
Gabriel Staples about 2 years
pdftk
worked whenpdfunite
did not.pdfunite
erroneously removed metadata fields from a fillable PDF, as I described here.pdftk
did not--it performed correctly. -
Timo about 2 yearsI had two files on Mac Monterey, each 1 M resulting in output of 15 M. I then used
--object-streams=generate
and the output size was normal. -
Pavol Travnik about 2 yearsI wonder why it is so low. This is exactly what I was looking for. Thank you.
-
Doberon about 2 yearsQPDF is great. Use it this way to extract pages 1-10 from input.pdf and save it as output.pdf: qpdf input.pdf --pages . 1-10 -- output.pdf