• How to add image in PDF file using iTextSharp in ASP.NET

    by  • May 13, 2014 • Microsoft .NET C# (C-Sharp), Microsoft ASP.NET, Microsoft VB.NET • 0 Comments

    In my previous article, I have briefly explained about iTextSharp and how we can read PDF file using iTextSharp in ASP.NET. In this article, I will show you how you can write a PDF file and how you can add an image to PDF file using iTextSharp. You will see that how easily an image can be added to a PDF fileĀ and how easily we can manipulating PDF files using iTextSharp. I have provided you code both in C# and VB.NET. You can get code according to your need and you can also download complete code at the end of the article.

    First we need to create an object of Document class and create a PDF file using GetInstance() method of PdfWriter class of iTextSharp. Then open the file and write text using Paragraph class of iTextSharp. We will use Image class and GetInstance() method of iTextSharp.text to get our image. At the end, by using Add() method of Document class, we can insert text and image to a PDF file.

    • First you need to download iTextSharp, extract it and include it in your project.
    • Create a website in Visual Studio for C# or VB.NET and add a web form to it
    • Add a reference of ITextSharp in your website
    • Add following namespaces in code behind file



    • Write below code page load event



    • View web site in browser and see the PDF file. You can download complete code sample from below link.

    Best WordPress Themes and Plugins with Great Team and Support!

    Avatar of GetCodeSnippet.com


    GetCodeSnippet.com provides you high quality Microsoft .NET development related articles, tutorials and sample code for ASP.NET, C#, VB.NET, AJAX, WCF, WPF, Web Services, Windows Services, SQL Server and other technologies.

    Leave a Reply