Recently one of my colleague asked me is there anyway to programmatically merge huge number of PDF files in to a single file, without using Adobe Acrobat libraries, well the answer is yeah. and there are a lot of off the shelve and open source libraries available for this. the best one I found is the PDFSharp, and its totally FREE.
Here is a little introduction about PDFSharp:
- PDFsharp is the Open Source library that easily creates PDF documents from any .NET language.
The same drawing routines can be used to create PDF documents, draw on the screen, or send output to any printer. - It can use either GDI+ or WPF.
- It includes support for Unicode in PDF files.
- It also includes MigraDoc Lite which brings you all the high-level functionality not included in PDFsharp.
Using PDFSharp is very simple. the samples in the official download file are more than enough to learn the functionality of PDFSharp.here is a little piece of code I used to merge A collection of PDFs in a folder to a single PDF file.
1: PdfDocument inputDocument=
2: PdfReader.Open(file.FullName,PdfDocumentOpenMode.Import);
3: int count = inputDocument.PageCount;
4: for (int idx = 0; idx < count; idx++)
5: {
6: // Get the page from the external document...
7: PdfPage page = inputDocument.Pages[idx];
8: // ...and add it to the output document.
9: outputDocument.AddPage(page);
10: }
11:
12: outputDocument.Save(filename);
if you want to download the full sample I created download it here.
if you want to download pdfSharp Library visit the site below:
http://www.pdfsharp.com/PDFsharp
Popularity: 81% [?]




Thu, Jul 24, 2008
Libraries, Visual Studio, c#