Merging Multiple PDF Files into One Document with PDFium VCL

Combining multiple PDF documents into a single file is a common requirement in document management workflows. The Merge PDF demo shows how to merge any number of PDF files into one using PDFium VCL in Delphi.

Overview

This demo provides a simple interface for selecting multiple PDF files, reordering them, and merging them into a single output PDF. It preserves all content from the source documents including text, images, and formatting.

Key Features

  • Multiple File Selection – Add multiple PDFs at once
  • Reorder Files – Move files up or down in the merge order
  • Remove Files – Remove unwanted files from the list
  • Progress Tracking – Visual progress during merge operation
  • Preserve Content – All pages merged with original quality

PDFium DLL Requirements

Before running any PDFium VCL application, ensure the PDFium DLL files are installed:

  • pdfium32.dll / pdfium64.dll – Standard versions (~5-6 MB)
  • pdfium32v8.dll / pdfium64v8.dll – With V8 JavaScript engine (~23-27 MB)

Installation: Run PDFiumVCL\DLLs\CopyDlls.bat as Administrator to automatically copy the DLLs to Windows system directories.

The Merge Process

The core merge functionality uses the ImportPages method:

Understanding ImportPages

The ImportPages method is the key to PDF merging:

Page range formats supported:

  • "1-5" – Pages 1 through 5
  • "1,3,5" – Pages 1, 3, and 5
  • "1-" – Page 1 to end
  • "-5" – First page to page 5

Adding Files to the List

Reordering Files

Removing Files

Updating UI State

Advanced: Merging Specific Pages

You can merge only specific pages from source documents:

Importing Viewer Preferences

Copy viewer preferences from another document:

Use Cases

  • Report Compilation – Combine multiple report sections into one document
  • Invoice Batching – Merge daily invoices into monthly batches
  • Document Assembly – Build complete documents from templates and content
  • Archive Creation – Combine related documents for archival

Conclusion

The Merge PDF demo shows how straightforward it is to combine PDF documents with PDFium VCL. The ImportPages method handles all the complexity of preserving document structure and content.

Whether you’re building a simple document combiner or a complex document assembly system, PDFium VCL provides the tools you need.

Get started with PDFium VCL Component from loslab.com and streamline your PDF workflows.