Overview

Read, create and manipulate PDF documents and PDF forms on the fly. Split, append, stamp, encrypt, extract, fill and more. PDFKit.NET is deployed as a single assembly, it is written entirely in C# and has no external dependencies.

Feature highlights

  • Fill and flatten PDF forms
  • Split and append PDF documents/pages
  • Extract, modify and add graphics
  • Digitally sign and verify PDF documents
  • Written in C# - no unsafe code
  • Single assembly - no dependencies

What's new in 4.0?

  • Generate QR codes
  • Import JBIG2 images
  • Convert to PDF/A-1b and save as PDF/A-1b
  • New build without System.Drawing.dll: required to run on Server 2008 x64

Merge multiple PDF files in c# .NET

1 // Find all pdf documents in input folder. 2 var directoryInfo = new DirectoryInfo(inputDocuments\); 3 var allPDFs = directoryInfo.GetFiles("*.pdf"); 4 5 // Create a document for the merged result. 6 var mergedDocument = new Document(); 7 8 // Keep a list of input streams to close when done. 9 var streams = new List<FileStream>(); 10 foreach (FileInfo fileInfo in fileInfos) 11 { 12 // Open input stream and add to list of streams. 13 var stream = new FileStream(fileInfo.FullName, FileMode.Open, FileAccess.Read); 14 streams.Add(stream); 15 16 // Open input document. 17 var document = new Document(stream); 18 19 // Append all pages to target document. 20 // The target document holds references to data in the input stream. 21 // For efficiency it does not copy this data so the input streams 22 // should not be closed before the merged document is saved. 23 mergedDocument.Pages.AddRange(document.Pages.CloneToArray()); 24 } 25 26 // Save merged document. 27 using (var output = new FileStream("output.pdf", FileMode.Create, FileAccess.Write)) 28 { 29 mergedDocument.Write(output); 30 } 31 32 // Close all input streams. 33 streams.ForEach(stream => stream.Close());