Microsoft > CSharp >> Code Snippets Views : 2663
PDF using iTextSharp
Rate This Article :

Update PDF Templates Content using ITextSharp

                    Dynamic PDF Content using ITextSharp and PDF Template

 

This article talks about, how we can update PDF content dynamically using ITextsharp and an existing PDF template.

ITextSharp – Introduction:

It is an advanced tool library which is used for creating/update complex pdf report. It also supports to create documents and reports based on data from databases or xml files and Merge or split pages from existing PDF files. It also supports Java, Android and several languages.

Technologies/Language involved - C#, .Net Core, ITextsharp Library, Console

Pre-requisite:

Nuget Package:

iTextSharp.LGPLv2.Core

Namespace:

using iTextSharp.text.pdf;

PDF Template:

Create a PDF template with required Form fields

Steps:

1.    1.    Create a PDF Template with required Form fields

1. PDF Template.png


1.    2. Create a Console application 

2. Create Console.png


2.    3. Install the ITextsharp Nuget package

3. ITextSharp-Nuget.png

 

3.   4. Create a class which will be using to bind the model data

4. Patient Report Model.png

 

4.   5. Create a Struct or set of constants which will define the form fields names

5. Struct with Form Fields.png

 

5.   6. Write a code to read the PDF template and convert to stream

 

6.    7. Using the stream, model object and ITextsharp(pdfreader, pdfstamper, AcroFields) bind the model data to stream object

 

7.    8. Specify the path with output filename

 

8.    9. Create a FileStream using filename and Copy the output stream to FileStream using CopyTo function.

 

9.   10. Go and check your output folder path and you can see the updated PDF

10. Updated PDF.png


About Author
Pandian S
Total Posts 1
-
Comment this article
Name*
Email Address* (Will not be shown on this website.)
Comments*
Enter Image Text*
   
View All Comments
Comments not posted yet!! Please post your comments on this article.
  Privacy   Terms Of Use   Contact Us
© 2016 Developerin.Net. All rights reserved.
Trademarks and Article Images mentioned in this site may belongs to Microsoft and other respective trademark owners.
Articles, Tutorials and all other content offered here is for educational purpose only and its author copyrights.