C#: Online Guide
How To: PDF SDK
File: Merge, Append PDF Files

File: Merge, Append PDF Files

Home ›› XDoc.PDF ›› C# PDF: Merge and Append PDF

C# PDF - Merge PDF Documents in C#.NET


Provide C# Demo Codes for Merging and Appending PDF Document




Overview



RasterEdge C#.NET PDF document merging toolkit (XDoc.PDF) is designed to help .NET developers combine PDF document files created by different users to one PDF file. Thus, C#.NET PDF document merge library control can be counted as an efficient .NET doc solution for keeping PDF document files organized.


This C# .NET PDF document merging control is written in managed C# code and compatible with all .NET developing platforms, like ASP.NET web application and Windows Forms project. Using this PDF document concatenating library SDK, C# developers can easily merge and append one PDF document to another PDF document file, and choose to create a new PDF file in .NET class application.


Besides C#.NET PDF document merging function, XDoc.PDF, a professional third-party .NET document imaging toolkit, also offers other advanced PDF document page processing and manipulating functions, such as PDF page insertion, PDF page deleting, PDF document splitting, PDF page reordering and PDF page image and text extraction. Remarkably, all those C#.NET PDF document page processing fucntions can be implemented independently, without using any Adobe-related software.


Our .NET PDF SDK empowers C# programmers to easily merge and append PDF files with mature APIs. To be more specific, two or more input PDF documents can be merged and appended together according to its loading sequence, and then saved and output as a single PDF with user-defined location.




Combine and Merge Multiple PDF Files into One Using C#



This part illustrates how to combine three PDF files into a new file in C# application. You may also combine more PDF documents together.




// Used to register all DLL assemblies.
WorkRegistry.Reset();

String inputFilePath1 = Program.RootPath + "\\" + "1.pdf";
String inputFilePath2 = Program.RootPath + "\\" + "2.pdf";
String inputFilePath3 = Program.RootPath + "\\" + "3.pdf";
String outputFilePath = Program.RootPath + "\\" + "Output.pdf";
String[] inputFilePaths = new String[3] { inputFilePath1, inputFilePath2, inputFilePath3 };

// Combine three PDF files and output.
PDFDocument.CombineDocument(inputFilePaths, outputFilePath);





Append PDF Document in C#



In addition, C# users can append an input PDF file to the end of a current PDF document and combine to a single file.




// Used to register all DLL assemblies.
WorkRegistry.Reset();

// Get appendDoc.
String appendPDFfilePath = @"";
PDFDocument appendDoc = new PDFDocument(appendPDFfilePath);

// Append appendDoc to doc.
String inputFilePath = @"";
String outPutFilePath = @"";
PDFDocument doc = new PDFDocument(inputFilePath);
doc.AppendDocument(appendDoc);

// Save as a single PDF file.
doc.Save(outPutFilePath);