How to Merge PDF Files
Merging is just stacking pages in the order you list the files. I tested it on two files — Part A (3 pages) and Part B (2 pages) — and both free offline methods produced a 5-page PDF with Part A first, Part B second. The pypdf output was 3,671 bytes; pdfunite's was 4,117 bytes. Nothing is recompressed, so don't expect the merged file to be smaller than the parts.
At a glance
- Page order = the order you list the files. List Part A before Part B and it stays that way.
- Page sizes are kept as-is: mixing A4 and Letter gives a mixed-size PDF.
- Merging doesn't shrink anything — the output is roughly the sum of the inputs.
- Password-protected inputs must be unlocked first.
- The tested offline methods need no upload: pypdf (Python) or pdfunite (poppler).
Steps
- Install Python 3 and pypdf:
pip install pypdf. - Save this script as
merge_pdfs.py(full script in the section below). - Run it:
python merge_pdfs.py part-a.pdf part-b.pdf merged.pdf. - Check the result. Page 1 of the merged file is Part A's first page, and the file has 5 pages total:
Page 1 of the merged file (150 DPI render): Part A's first page, as expected. Rendered from the real merged output, 2 November 2026. - Verify:
pdfinfo merged.pdfreports 5 pages; opening it shows Part A first, Part B second. - Alternative without Python:
pdfunite part-a.pdf part-b.pdf merged.pdf(poppler) — same 5 pages, 4,117 bytes on the test files.
The script (copy and run)
This is the exact script used for the test. Files are appended in argument order; the last argument is the output.
import sys
from pypdf import PdfWriter
*inputs, output = sys.argv[1:]
writer = PdfWriter()
for f in inputs:
writer.append(f)
with open(output, "wb") as fh:
writer.write(fh)
print("wrote", output)
Worked example (tested 2 November 2026)
Test files: Part A, 3 pages of chapter-one text (2,653 bytes); Part B, 2 pages of chapter-two text (2,119 bytes). Both are text-only A4 pages.
| Method | Output pages | Output size | Time |
|---|---|---|---|
| pypdf | 5 | 3,671 bytes | under 0.1 s |
| pdfunite (poppler) | 5 | 4,117 bytes | under 1 s |
Both outputs open with Part A first and Part B second, and both report 5 pages. Sizes are small because the test files are text-only; real files scale with their content. Note the outputs (3,671 / 4,117 bytes) are smaller than the inputs' sum (4,772 bytes) here only because the test files share font objects that get written once — with photo-heavy inputs, expect roughly the sum, not less.
Method 3: PDFsam Basic / browser tools (documented)
PDFsam Basic is a free, open-source desktop app with a Merge module: add the files, drag them into order, click Run. It is the best no-code option if you merge often. Browser tools (iLovePDF, Smallpdf) merge without installing anything: upload, drag into order, download. They work on phones too, but your files upload to their server and free tiers have a daily limit — fine for one-offs, not for sensitive documents.
What to watch out for
- Mixed page sizes stay mixed: merging A4 and Letter gives a PDF with both sizes. Nothing rescales pages unless you ask a tool to.
- Bookmarks may drop: simple mergers don't always carry over outlines/bookmarks from the inputs. If bookmarks matter, check the output before you send it.
- Encrypted inputs: a password-protected PDF must be unlocked first; mergers can't open it on their own.
- Scanned pages stay scans: merging doesn't OCR anything. A merged scan is still a picture, not searchable text.
- Big files in browser tools: uploads are slow and free tiers cap file size — for large files, use an offline method.
Frequently asked questions
Is merging PDFs free?
Yes — pypdf, pdfunite and PDFsam Basic are all free and open source.
Can I choose the page order?
Yes: the output follows the order you list the files. To reorder pages inside one file, split it first, then merge the pieces in the order you want.
Will the merged PDF be smaller?
No — roughly the sum of the inputs. To shrink it, compress afterwards, which is a separate step.
Can I merge PDFs on my phone?
Browser tools work on phones, but they upload your files. For sensitive documents, merge on a computer with an offline tool.
What if one PDF is password-protected?
Unlock it first with the password. Mergers can't open a password-protected file on their own.
Related guides: How to convert PDF to Excel · How to convert PDF to Word · How to convert a scanned PDF to Excel · All guides · Tool: PDF Probe