Assume that you are working with a well-known reporting tool "Crystal Report Viewer" and as per your requirement you exporting report in PDF Document and there is a bundle of exported PDF documents and your client gives you a requirement to merge all the PDF Files within only one single PDF Document then how you can archive this kind of requirement? So in this article, I gonna show you how to archive this kind of requirement. So, I have analyzed that solution and wrote a method and using this method we can merge multiple PDF Document in Single Document and got a solution that I gonna share with you. What is Itextsharp library? Itextsharp is an advanced tool library that is a free and open source which is used for creating complex pdf documents and that help to convert page output or HTML content in a PDF file.
|Published (Last):||10 May 2009|
|PDF File Size:||14.96 Mb|
|ePub File Size:||16.21 Mb|
|Price:||Free* [*Free Regsitration Required]|
This does come with a cost, however. The Pdf file format itself is complex; therefore, programming libraries which seek to provide a flexible interface for working with Pdf files become complex by default. I noted in my previous post on PdfBox that PdfBox was a little easier for me to get up and running with, at least for rather basic tasks such as splitting and merging existing Pdf files. I also noted that iText looked to be a little more complex, and I was correct.
However, iTextSharp does not suffer some of the performance drawbacks inherent to PdfBox, at least on the. Superior Performance vs. While I found it very cool to be able to run Java code in a. NET context, there was a serious performance hit, most notably the first time the PdfBox library was called, and the massive IKVM library spun up what amounts to a.
Needless to say, iTextSharp does not suffer this limitation. Extracting and Merging Pages from an Existing Pdf File One of the most common tasks we need to do is extract pages from one Pdf into a new file.
My simplified understanding of how this works is as follows: The PdfReader instance contains the content of the source PDF file. The Document class, once initialized with the PdfReader instance and a new output FileStream, essentially becomes a container into which pages extracted from the source file represented in the PdfReader class will be copied. The result is then output to the Filestream, and saved to disk at the location specified by the destination file name.
You can download the iTextSharp source code and binaries as a single package from Files page at the iTextSharp project site. Extract the files from the. Next, set a reference in your project to the itextsharp. You will need to browse to the folder where you stashed the extracted contents of the iTextSharp download.
Add the following using statements at the top of the file: using iTextSharp. FileStream outputPdfPath, System. Create ; document. AddPage importedPage ; document. Close ; reader. Create ; sourceDocument. GetImportedPage reader, i ; pdfCopyProvider. I believe this is as much to do with the nature of the PDF file format, and possibly the structure of lower-level libraries upon which iTextSharp is built. That said, there is without a doubt much to be discerned by exploring the iTextSharp source code.
Additionally, there are a number of resources to assist the erstwhile developer in using this library:.
Itextsharp In C#
Subscribe to RSS
Splitting and Merging PDF Files in C# Using iTextSharp
Merge Multiple PDF Files Into Single PDF Using Itextsharp in C#