Merging PDF Files, Explained

After reading this you will understand what a PDF merge actually does to your files, why it happens locally in your browser, and how to avoid the common surprises with page count, rotation and file size.

What merging a PDF really means

A PDF is not a stream of text. It is a container: a set of numbered objects (pages, fonts, images, metadata) tied together by a cross-reference table that tells a reader where each object lives in the file. When you merge PDFs, you are not gluing bytes end to end. You are building one new container that references the pages of every source file, in the order you chose, then writing a fresh cross-reference table for the result.

Concretely, suppose you have a 3-page cover letter and a 12-page report. The merge copies all 3 page objects from the first file and all 12 from the second into a new document, renumbers them 1 through 15, and rebuilds the internal plumbing so a viewer can find them. The visible content of each page (its text, vectors, images and rotation) is preserved exactly. What is not preserved is anything that lived above the page level in the originals, such as bookmarks and interactive form fields.

This tool uses pdf-lib and runs entirely in your browser. Your files are read into memory, recombined, and written back out as a download. Nothing is sent to a server, which matters when the documents are contracts, medical records or anything you would not email in the clear.

When to merge and when not to

Merging is the right move when several PDFs form one logical document and you want a single file to send, print or archive: a signed agreement plus its appendices, scanned receipts for one expense report, or chapters produced separately that belong in one manuscript.

It is the wrong move in a few cases. If you only want a specific range of pages from one file, extract them first with the PDF Page Extractor rather than merging then deleting. If the files are large scans and the combined size worries you, reordering will not help; you need the PDF Compressor. And if the source files carry bookmarks or fillable forms you must keep, know now that a plain merge drops them, so plan around that limit before you commit.

The arithmetic of a merge

The page count of a merge is the simplest formula in this entire guide. It is a plain sum.

N = \sum_{i=1}^{m} p_i

Here N is the total page count of the output, m is the number of source files, and p_i is the page count of file i. Nothing is added and nothing is dropped. If four files have 3, 12, 1 and 8 pages, the result has 3 + 12 + 1 + 8 = 24 pages, every time.

File size is not a clean sum. The output is close to the total of the inputs, but usually a little smaller because shared structures (for example an identical embedded font used by two files) can be written once, and because the new cross-reference table is compact. Do not expect exact addition. A useful rule of thumb: the merged size lands within a few percent of the sum of the parts unless the sources shared a lot of identical resources.

Worked example: reproducing the demo

The demo combines a small set of sample files. Walk the arithmetic by hand so the download matches your expectation.

  1. File A (cover) has 2 pages, file B (report) has 10 pages, file C (appendix) has 4 pages.
  2. Order is A, then B, then C, so the output pages read cover (1 to 2), report (3 to 12), appendix (13 to 16).
  3. Total pages: 2 + 10 + 4 = 16.
  4. Page 3 of the output is page 1 of file B. To find any output page, add up the sizes of the files before it. File C page 2 is output page 2 + 10 + 2 = 14.

Sizes of 120 KB, 640 KB and 210 KB sum to 970 KB. The merged file typically writes at roughly 940 to 980 KB. If yours comes out far smaller, the sources probably shared fonts; if far larger, one file may have been storing pages inefficiently to begin with.

How order and rotation carry over

Order is exactly the order you arrange in the tool, top to bottom, page by page within each file. There is no clever reflow: page 1 of the second file always follows the last page of the first file.

Rotation is preserved as stored. A PDF page carries a /Rotate value of 0, 90, 180 or 270 degrees, applied when the page is displayed. If a scanned page was saved rotated 90 degrees, it stays rotated 90 degrees after the merge. The merge does not normalise anything. If you want a page upright before combining, fix it with the PDF Rotator first, then merge.

Sort your files before dropping them in. Fixing order after a 30-file merge means re-doing the arrangement. A quick rename such as 01-cover.pdf, 02-report.pdf makes the intended order obvious and stable.

Reading the result

Open the download and check three things in order. First, the page count against your hand sum. If a source PDF was password-protected or corrupt, its pages may not have copied, and the count will be short. Second, the boundaries: jump to the page where one file should end and the next begin, and confirm the transition. Third, rotation on any scanned pages.

The chart below shows how output pages map back to their source files for the worked example. The x-axis is the output page number; the bar height marks which file that page came from.

Pages 1-2 come from file A, pages 3-12 from file B, pages 13-16 from file C. The step pattern is the fingerprint of a clean merge.

With three files of 2, 10 and 4 pages the output has 16 pages: file A occupies output pages 1-2, file B occupies 3-12, and file C occupies 13-16. Changing any file's page count shifts every boundary after it.

Common mistakes

The mistakes that bite people are rarely about the math and almost always about expectations.

Expecting bookmarks to survive
A plain merge drops the outline (bookmarks) and any form fields. If a source PDF had a clickable table of contents, the links will not carry into the merge. Rebuild navigation afterward if you need it.
Merging an encrypted file
A password-protected PDF cannot be read until its password is removed. Clear the password in your PDF viewer before merging, or its pages may silently fail to copy.
Assuming file size adds up
Size is approximate, not exact. Do not treat a smaller-than-sum result as data loss; it usually means shared resources were deduplicated.
Leaving rotation unfixed
A sideways scan stays sideways. Rotate before merging, not after, so you fix it once per source rather than page by page in the combined file.
Forgetting hidden metadata
Each source file may carry author names, software versions or edit timestamps. The merge writes its own document metadata, but you should still check the result if you are sharing it publicly.

If a source file will not add its pages to the count, do not keep retrying the merge. Open that one file on its own first. A short page count almost always points to encryption or corruption in a single input, not a fault in the combine step.

Related PDF tools

Merging is one operation in a small toolkit. Use the PDF Splitter to break one file into ranges, the reverse of merging. To remove author names and timestamps before sharing, run the result through the PDF Metadata Viewer & Stripper. If your inputs are photos or scans rather than PDFs, build a PDF first with Images → PDF, then merge. And to turn merged pages back into pictures for a slideshow or a preview, use PDF → Images.

Frequently asked questions

Does merging reduce quality?

No. Page content, including text, vectors and embedded images, is copied as stored. There is no re-encoding, so a merge is lossless for page content. If you want smaller files, that is a separate compression step.

Is there a limit to how many files I can merge?

The practical limit is your device's memory, since everything is read into the browser at once. Dozens of ordinary documents merge without trouble. Hundreds of large scans may run slowly or run out of memory on a modest machine.

Why did my bookmarks disappear?

A plain merge copies pages, not the document outline that points to them. Bookmarks and form fields are dropped by design. You would need to rebuild them in a dedicated PDF editor after merging.

Are my files uploaded anywhere?

No. The merge runs entirely in your browser with pdf-lib. The files stay on your device and the combined PDF is generated locally as a download.

Can I merge a password-protected PDF?

Not while it is locked. Open it with its password in a PDF viewer, save a copy without the password, then merge that copy.