Merge Multiple PDF Files Without Uploading Them
Three local ways to merge PDFs, tested on real files: Preview on a Mac, the merge command macOS already ships, and a few lines of Python with pypdf. Two of them lose things without telling you, so the test results matter more than the commands.
The short answer: on a Mac, use Preview (drag files into the thumbnail sidebar). In a script, use pypdf with PdfWriter().append(), or qpdf or pdftk on a server. Keep the files on your own machine. Contracts, payslips and medical letters are exactly the PDFs people merge, and an upload service is one more copy of them.
To see what each method really does, I built two test files with headless Chrome on November 27, 2026 (macOS 26.7.3, Chrome 158, pypdf 7.2.0): a 2 page A4 report with two headings that Chrome turned into bookmarks, and a 1 page US Letter invoice. Then I merged them every way I could run here.
report.pdf 17825 bytes 2 pages A4 (595 x 842 pt) bookmarks: Section 1, Section 2
invoice.pdf 13615 bytes 1 page Letter (612 x 792 pt) bookmarks: Invoice 0001
Preview on a Mac: the right choice for a handful of files
Preview is the easiest local option, and you can see the pages while you work. These are the steps from Apple's guide to combining PDFs:
- Duplicate the first file first (File, then Duplicate). Preview saves changes automatically, so editing the original changes it.
- Open the copy and choose View, then Thumbnails.
- Drag the other PDF files from Finder into the sidebar, at the point where they belong. Dropping a file adds all of its pages.
- Drag thumbnails to reorder. Command click selects pages that aren't next to each other.
- Close the window, or use File, then Export as PDF for a new file.
The merge command inside macOS, and what it drops
macOS ships a small command line merger inside the Automator action "Combine PDF Pages". There is nothing to install:
$ "/System/Library/Automator/Combine PDF Pages.action/Contents/MacOS/join" \
--output joined.pdf report.pdf invoice.pdf
$ echo $?
0
The pages came out in the order I gave, and each kept its own size (two A4 pages, then one Letter page). Two things went missing.
The bookmarks. joined.pdf had 3 pages and an empty outline. The report's two bookmarks and the invoice's one were gone. When I opened the file with pypdf, it also printed Ignoring wrong pointing object 19 0 (offset 0), so the file's cross reference table is slightly off. pypdf read the file anyway, but I wouldn't feed the output into another tool without checking it.
Locked files, silently. I password protected a copy of the invoice and merged it with the report:
$ "/System/.../join" --output joined-locked.pdf report.pdf invoice-locked.pdf
$ echo $?
0
# joined-locked.pdf: 2 pages, not 3. The locked invoice is simply missing.
Exit code 0, no warning, and a file that looks finished. If a script uses this command on documents that might be encrypted, count the pages afterwards. It is also an internal helper that Apple doesn't document, so it could change or disappear in a future macOS release.
pypdf: merging in Python, bookmarks kept
pypdf is pure Python, so pip install pypdf works anywhere. The whole merge:
from pypdf import PdfWriter
w = PdfWriter()
for f in ["report.pdf", "invoice.pdf"]:
w.append(f)
w.write("pypdf-merged.pdf")
pypdf-merged.pdf 28575 bytes 3 pages A4, A4, Letter
bookmarks: Section 1: Summary, Section 2: Details, Invoice 0001
Same pages as the macOS command, all three bookmarks kept, and a slightly smaller file. To take only some pages, pass a range. pages=(1, 2) is the second page only, because pypdf counts from 0 and the end is exclusive, like a Python slice:
w = PdfWriter()
w.append("report.pdf", pages=(1, 2))
w.append("invoice.pdf")
w.write("pypdf-range.pdf")
# pypdf-range.pdf 27765 bytes 2 pages
# bookmarks: Section 2: Details, Invoice 0001
It dropped the bookmark for the page I left out, which is what you want. The file size is the surprise. Two pages came to 27,765 bytes, nearly the 28,575 of all three. A page shares fonts and other resources with the rest of its file, and those come along whichever pages you pick.
Shrinking a merge of similar files
Merging several documents made by the same program means several copies of the same fonts. pypdf can remove the duplicates. I merged the report with itself three times, the way you might combine three letters from one template:
w.compress_identical_objects(remove_duplicates=True, remove_unreferenced=True)
three copies: 48378 bytes
after compress_identical_objects: 22056 bytes
That is 54% smaller with no change to any page. The parameter names changed in pypdf 7. The older remove_identicals and remove_orphans now raise DeprecationError: remove_identicals is deprecated and was removed in pypdf 7.0.0. Use remove_duplicates instead. The pypdf file size guide covers the other options.
Password protected PDFs: the protection does not survive the merge
This is the part that matters most for sensitive documents. First, pypdf won't touch an encrypted file until you give it the password:
pypdf.errors.FileNotDecryptedError: File has not been decrypted
If the file uses AES encryption, you also need the crypto extra, or you get DependencyError: cryptography>=3.1 is required for AES algorithm. Install it with pip install "pypdf[crypto]", as the encryption docs say. Then decrypt and merge:
from pypdf import PdfReader, PdfWriter
r = PdfReader("invoice-locked.pdf")
r.decrypt("the-password") # returned 2 in my test, meaning it succeeded
w = PdfWriter()
w.append(r)
w.write("with-pass.pdf")
print(PdfReader("with-pass.pdf").is_encrypted) # False
The merged file had no password at all. A merge produces a new file, and nothing carries the old protection across. If the input was locked for a reason, lock the output again before you send it (w.encrypt("new-password", algorithm="AES-256") in pypdf). Better still, send it through a channel that is encrypted and expires, so the file isn't sitting in an inbox. More on that in sharing passwords securely, which also applies to the PDF's password.
qpdf and pdftk on Linux and Windows
On a server, qpdf and pdftk do the same job in one line. I couldn't install either on this Mac (Homebrew fails to build them here), so these are commands from their manuals, not runs:
# qpdf: pages from several files, in order
qpdf --empty --pages report.pdf invoice.pdf -- merged.pdf
# qpdf: page 2 of the report, then all of the invoice
qpdf --empty --pages report.pdf 2 invoice.pdf -- merged.pdf
# pdftk
pdftk report.pdf invoice.pdf cat output merged.pdf
pdftk A=report.pdf B=invoice.pdf cat A2 B output merged.pdf
Note that qpdf counts pages from 1, unlike pypdf. The qpdf CLI reference and the pdftk man page cover page ranges, rotation and password options. Whatever you use, run the same checks as above: page count, bookmarks if you need them, and whether a locked input made it in.
Checking the merged file before you send it
from pypdf import PdfReader
r = PdfReader("merged.pdf")
print(len(r.pages), [o.title for o in r.outline if hasattr(o, "title")], r.is_encrypted)
That one line would have caught both silent problems above, the missing locked file and the lost bookmarks. If you are sending the file to someone who needs to know it arrived unchanged, give them its SHA-256 as well. The Hash Generator hashes a file in your browser without uploading it, and shasum -a 256 merged.pdf gives the same value on a Mac or Linux.
If the merged PDF is big because of scans, shrink it next. The PDF compression guide covers that, and optimizing PDFs for web and email covers fast web view and metadata.