# Merge PDF files: web app, CLI, and C# libraries

## What it does
Merges two or more PDF documents into a single PDF file. The order of the pages follows the alphabetical order of the input file names.

## Inputs and limits
* Input: PDF files.  
* Minimum: two PDF files.  
* No explicit size limit is documented; the operation runs in memory and may be limited by the host system.

## Web app
The page asks you to select PDF files, optionally reorder them, and click **MERGE**. It then combines the selected files and provides a single merged PDF for download. (Source: UI text shows “Combine PDF files in any order.”)

Open the web app: [Merge PDF files](https://products.documentize.app/merge-pdf).

## Command line (CLI)
The Documentize.Merge plugin merges PDF files placed in a task‑specific input folder and writes the merged result to a matching output folder. Provide a task ID to identify the folders.

```bash
# Linux / macOS (needs the .NET 10 runtime and documentize.lic next to the DLL)
export PLUGIN_INPUT_DIR=./work/input
export PLUGIN_OUTPUT_DIR=./work/output
mkdir -p "$PLUGIN_INPUT_DIR/job1"
cp sample.pdf cv.pdf "$PLUGIN_INPUT_DIR/job1/"
dotnet Documentize.Merge.dll --task-id job1
ls "$PLUGIN_OUTPUT_DIR/job1"
```

```powershell
# Windows PowerShell
$env:PLUGIN_INPUT_DIR  = "$PWD\work\input"
$env:PLUGIN_OUTPUT_DIR = "$PWD\work\output"
New-Item -ItemType Directory -Force "$env:PLUGIN_INPUT_DIR\job1" | Out-Null
Copy-Item sample.pdf, cv.pdf "$env:PLUGIN_INPUT_DIR\job1\"
dotnet Documentize.Merge.dll --task-id job1
Get-ChildItem "$env:PLUGIN_OUTPUT_DIR\job1"
```

All command line plugins: [Documentize CLI plugins](https://products.documentize.ai/pdf-cli).

## Documentize.Plugins (C#)
The Documentize.Plugins library offers a `MergeOptions` object. Add each input PDF with `options.AddInput(new FileData(file))`, specify the output file with `options.AddOutput(new FileData(...))`, and call `PdfManager.Merge(options)`. A license file `documentize.lic` must be present.

```csharp
#:package Documentize@26.9.0

using Documentize;

// Apply the license file placed next to the program, then merge every PDF of the input folder in filename order.
License.Set("documentize.lic");

var inputDir = args[0];
var outputDir = args[1];

var options = new MergeOptions();
foreach (var file in Directory.GetFiles(inputDir, "*.pdf").OrderBy(f => f, StringComparer.Ordinal))
{
    options.AddInput(new FileData(file));
}
options.AddOutput(new FileData(Path.Combine(outputDir, "merged.pdf")));

PdfManager.Merge(options);
Console.WriteLine("merged.pdf written");
```

Save it as `app.cs` and run `dotnet run app.cs -- ./in ./out` (.NET 10 SDK).

Library page: [Documentize.Plugins](https://products.documentize.com/).

## Aspose.PDF.FOSS (C#)
Using Aspose.PDF.FOSS, load all PDF files from the input folder, order them alphabetically, and call `new PdfFileEditor().Concatenate(files, outputPath)`. No license is required.

```csharp
#:package Aspose.PDF.FOSS@26.11.0

using Aspose.Pdf.Facades;

var inputDir = args[0];
var outputDir = args[1];

var files = Directory.GetFiles(inputDir, "*.pdf").OrderBy(f => f, StringComparer.Ordinal).ToArray();
new PdfFileEditor().Concatenate(files, Path.Combine(outputDir, "merged.pdf"));
Console.WriteLine("merged.pdf written");
```

Save it as `app.cs` and run `dotnet run app.cs -- ./in ./out` (.NET 10 SDK).

Package page: [Aspose.PDF.FOSS on NuGet](https://www.nuget.org/packages/Aspose.PDF.FOSS).

## Related guides

* [Splitter: web app, CLI and MCP](/docs/splitter)
* [Delete pages from a PDF: web app and CLI](/docs/delete-page)
* [Rotate PDF pages: web app and CLI](/docs/rotation)
* [Resize PDF pages: web app, CLI, MCP and C# (FOSS)](/docs/resize)
* [Booklet: web app](/docs/booklet)

## Verified

Every code sample on this page was run on 2026-11-03 and its result was checked:

- Merge two PDFs with the Documentize.Merge plugin (CLI plugin): passed in 2 s
- Merge PDFs in C# with Documentize.Plugins (Documentize.Plugins): passed in 13 s
- Merge PDFs in C# with Aspose.PDF.FOSS (Aspose.PDF.FOSS): passed in 6 s
