Clioos › Guides › Merge PDF

How to Merge PDF Files

By Clioos 团队

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

Steps

  1. Install Python 3 and pypdf: pip install pypdf.
  2. Save this script as merge_pdfs.py (full script in the section below).
  3. Run it: python merge_pdfs.py part-a.pdf part-b.pdf merged.pdf.
  4. 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 PDF: Part A's first page
    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.
  5. Verify: pdfinfo merged.pdf reports 5 pages; opening it shows Part A first, Part B second.
  6. 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.

MethodOutput pagesOutput sizeTime
pypdf53,671 bytesunder 0.1 s
pdfunite (poppler)54,117 bytesunder 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

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