Asp.net Create Pdf Code

broken image
Create pdf free

For example here I provided 'filename=Example.pdf' and the text as 'This is test file'. Run the page that will be like: Click on the 'Generate PDF' button and save the 'Example.pdf' file. Result: Open the PDF file and see your text in the PDF file. Here Mudassar Ahmed Khan has explained with an example and attached sample code, create and download of PDF Report from SQL Server database using the free iTextSharp Generation Library in ASP.Net using C# and VB.Net.

Introduction

This short article explains how to create PDF documents from ASP.NET web pages using this free library: http://sourceforge.net/projects/itextsharp/.

The code

First of all, I will create a simple 'Hello PDF'. Next, I will create a more complex PDF document with tables. To start creating PDF documents, you need to download the iTextSharp library from http://sourceforge.net/projects/itextsharp/ and reference it in your project. The PDF documents are created 'on the fly' by the web page 'ShowPDF.aspx'. This page also does a 'Response.Redirect' to the created PDF. We will first import the required namespaces:

Next, in the Page_Load event, we find out which document was requested by the user:

The ShowHello function creates a simple document with just one string: 'Hello World', and then redirects the user to the newly created document:

Asp.net Create Pdf Code Free

A more complex example

The function ShowTable is slightly more complex. It also creates a PDF document and redirects the user to it:

Using the iTextSharp library (http://sourceforge.net/projects/itextsharp/) makes it very easy to create PDF documents from web applications.

Free Pdf Creator





broken image