Merge PDF API
Combine multiple PDFs into a single, organized document with control over page order, size, orientation, bookmarks, and fonts.
Merging PDF files in C# is a common task for developers building business apps, reporting tools, or document workflows. Whether you want to combine multiple PDFs into one, standardize page layouts, or optimize files, you’ll need a reliable and simple solution.
In this tutorial, we’ll show you how to merge PDFs in C# with ConvertAPI, a powerful cloud-based API that makes PDF merging in .NET quick and easy. We’ll cover the basics and then dive into advanced options like page size, page orientation, bookmarks, and more.
ConvertAPI is a file conversion and processing API that supports over 200 formats. For .NET PDF merging, it’s an ideal solution because it:
Whether you’re building a desktop application, a web API, or a batch-processing tool, ConvertAPI simplifies C# PDF merge operations.
Before merging PDF files, you’ll need to set up the ConvertAPI SDK.
Install-Package ConvertApiHere’s the simplest example of how to merge two PDF documents in C#:
using System;
using System.Threading.Tasks;
using ConvertApiDotNet;
class Program
{
static async Task Main(string[] args)
{
var convertApi = new ConvertApi("your-api-token");
var result = await convertApi.ConvertAsync("pdf", "merge",
new ConvertApiFileParam("files", @"C:\Docs\File1.pdf"),
new ConvertApiFileParam("files", @"C:\Docs\File2.pdf"));
await result.SaveFilesAsync(@"C:\Docs\Merged.pdf");
Console.WriteLine("PDFs merged successfully!");
}
}
This code merges
File1.pdfandFile2.pdfinto a single merged PDF file.
ConvertAPI also provides advanced options to customize how your merged PDF looks and behaves. These properties let you control page size, orientation, bookmarks, font optimization, and opening page.
The PageSize property scales each input page proportionally to fit a target page size such as A4 or Letter. This ensures all pages in the final document are consistent.
var result = await convertApi.ConvertAsync("pdf", "merge",
new ConvertApiFileParam("files", @"C:\Docs\File1.pdf"),
new ConvertApiFileParam("files", @"C:\Docs\File2.pdf"),
new ConvertApiParam("PageSize", "A4"));
Use this when merging reports or invoices with mixed formats into one standardized PDF file in C#.
The PageOrientation property sets whether the output PDF should be in Portrait or Landscape mode.
var result = await convertApi.ConvertAsync("pdf", "merge",
new ConvertApiFileParam("files", @"C:\Docs\File1.pdf"),
new ConvertApiFileParam("files", @"C:\Docs\File2.pdf"),
new ConvertApiParam("PageOrientation", "Landscape"));
Ideal for merging wide spreadsheets, diagrams, or presentations into a landscape PDF.
The BookmarksToc property automatically generates a clickable table of contents in the merged PDF, making navigation easier.
var result = await convertApi.ConvertAsync("pdf", "merge",
new ConvertApiFileParam("files", @"C:\Docs\File1.pdf"),
new ConvertApiFileParam("files", @"C:\Docs\File2.pdf"),
new ConvertApiParam("BookmarksToc", "true"));
Useful when merging multiple PDF documents like contracts or chapters into one file.
The RemoveDuplicateFonts property reduces PDF size by removing redundant embedded fonts.
var result = await convertApi.ConvertAsync("pdf", "merge",
new ConvertApiFileParam("files", @"C:\Docs\File1.pdf"),
new ConvertApiFileParam("files", @"C:\Docs\File2.pdf"),
new ConvertApiParam("RemoveDuplicateFonts", "true"));
Great for archiving or emailing PDFs where smaller file size matters.
The OpenPage property defines which page should be shown first when the merged PDF opens.
var result = await convertApi.ConvertAsync("pdf", "merge",
new ConvertApiFileParam("files", @"C:\Docs\File1.pdf"),
new ConvertApiFileParam("files", @"C:\Docs\File2.pdf"),
new ConvertApiParam("OpenPage", "3"));
Perfect for skipping introductory content and jumping directly to the main content page.
You can also combine all options in a single C# merge PDF operation:
var result = await convertApi.ConvertAsync("pdf", "merge",
new ConvertApiFileParam("files", @"C:\Docs\File1.pdf"),
new ConvertApiFileParam("files", @"C:\Docs\File2.pdf"),
new ConvertApiParam("PageSize", "A4"),
new ConvertApiParam("PageOrientation", "Portrait"),
new ConvertApiParam("BookmarksToc", "true"),
new ConvertApiParam("RemoveDuplicateFonts", "true"),
new ConvertApiParam("OpenPage", "1"));With ConvertAPI’s C# PDF merge library, you can:
This makes it easy to integrate PDF merging in .NET applications for invoicing, reporting, document processing, or archiving.
Try ConvertAPI for free and start merging PDFs in your next C# project today!