PDF Merger
The Documentize PDF Merger for .NET is a versatile tool designed to merge multiple PDF documents into a single file. It simplifies the consolidation of PDF files, ensuring your documents are merged efficiently and maintaining consistency across content. The plugin handles internal resources such as fonts and images to optimize the merged document.
Key Features:
- Merge Multiple PDFs: Easily combine multiple PDF files into one.
- Resource Optimization: Removes duplicate fonts and images during merging.
- Batch Processing: Merge large batches of PDF documents in one go.
- Secure Merging: Ensure document integrity without data loss or content corruption.
How to Merge PDF Documents
To merge multiple PDF documents into a single file, follow these steps:
- Create an instance of the
Merger
class. - Create an instance of
MergeOptions
to configure the merging process. - Add input PDF files using the
AddInput
method. - Set the output file path using
AddOutput
. - Execute the merge using the
Process
method.
1var merger = new Merger();
2var mergeOptions = new MergeOptions();
3
4// Add input PDF files to merge
5mergeOptions.AddInput(new FileDataSource(@"C:\Samples\file1.pdf"));
6mergeOptions.AddInput(new FileDataSource(@"C:\Samples\file2.pdf"));
7mergeOptions.AddInput(new FileDataSource(@"C:\Samples\file3.pdf"));
8
9// Specify the output file path
10mergeOptions.AddOutput(new FileDataSource(@"C:\Samples\mergedOutput.pdf"));
11
12// Merge the PDFs
13merger.Process(mergeOptions);
How to Merge PDFs with Page Range
You can also merge specific page ranges from input PDF files using the MergeOptions
class. This allows you to combine selected pages into the final output document.
- Create an instance of the
Merger
class. - Configure page ranges using
MergeOptions
. - Add the input files with specified page ranges.
- Set the output path.
- Call the
Process
method.
1var merger = new Merger();
2var mergeOptions = new MergeOptions();
3
4// Merge specific pages from input PDFs
5mergeOptions.AddInput(new FileDataSource(@"C:\Samples\file1.pdf"), new PageRange(1, 3));
6mergeOptions.AddInput(new FileDataSource(@"C:\Samples\file2.pdf"), new PageRange(2, 5));
7
8// Specify the output file path
9mergeOptions.AddOutput(new FileDataSource(@"C:\Samples\outputWithSpecificPages.pdf"));
10
11// Merge the PDFs
12merger.Process(mergeOptions);
How to Handle Batch Merging
The PDF Merger plugin is optimized for handling large batches of PDF documents. By leveraging the batch processing feature, you can merge hundreds of PDFs in a single operation, ensuring efficient and fast document management.
- Instantiate the
Merger
class. - Add all input PDF files to the
MergeOptions
class. - Specify the output path.
- Call the
Process
method to merge all files in the batch.
1var merger = new Merger();
2var mergeOptions = new MergeOptions();
3
4// Add a large batch of PDFs for merging
5for (int i = 1; i <= 100; i++)
6{
7 mergeOptions.AddInput(new FileDataSource($@"C:\Samples\file{i}.pdf"));
8}
9
10// Specify the output file path
11mergeOptions.AddOutput(new FileDataSource(@"C:\Samples\batchMergedOutput.pdf"));
12
13// Process the batch merging
14merger.Process(mergeOptions);