qpdf Examples: Merging, Splitting, Compressing PDF Files
Last updated:- Select one page
- Select multiple pages
- Compress PDF file
- Merge multiple pages into one file
- Add password fo PDF file
- Add password to PDF file, inplace
- Remove password from PDF file
WIP Alert This is a work in progress. Current information is correct but more content may be added in the future.
Select one page
You have a file multipage.pdf
and you want to extract the first page into a new file page1.pdf
:
$ qpdf multipage-file.pdf --pages . 1 -- page1.pdf
Select multiple pages
You have a file multipage.pdf
and you want to extract pages 1 to 5 page into a new file pages1-5.pdf
:
$ qpdf multipage-file.pdf --pages . 1-5 -- pages1-5.pdf
Compress PDF file
Generate an optimized (smaller in smaller) version of input.pdf
.
Other options to try out:
--recompress-flate
--optimize-images
--compression-level=N
(wheren
is an integer)
$ qpdf --compress-streams=y --object-streams=generate input.pdf output.pdf
Merge multiple pages into one file
TODO
Add password fo PDF file
Passing the password twice in the command is not a typo. Owner password VS user password
Add password "foobar"
to file file.pdf
, creating a new file called file-encrypted.pdf
:
$ qpdf --encrypt foobar foobar 128 -- file.pdf file-encrypted.pdf
Add password to PDF file, inplace
If you don't want to create a copy of the file with password, but modify the file inplace instead:
Use --replace-input
modifier, using "foobar"
as the password:
$ qpdf --replace-input --encrypt foobar foobar 128 -- file.pdf
Remove password from PDF file
Use --decrypt
and provide the password to generate a copy of the file, without password
$ qpdf --decrypt --password=foobar original-file-encrypted.pdf file-decrypted.pdf