


String msg = are some changes in the company policy, due to this matter you need to submit your latest address to us. GridViewRow selectedRow = ((GridView)e.CommandSource).Rows get the GridViewRow where the command is raised Int index = Convert.ToInt32(e.CommandArgument) get the row index stored in the CommandArgument property The code for getting data from the grid view is as follows The Generate_PDF method is straight forward, It get the title, fullname and message to some variables, then create the pdf using these variables. I am going to explain the code for this section in the remaining part of the article Protected void Generate_PDF(object sender, GridViewCommandEventArgs e) In the code behind, I wrote the corresponding event handler. I added an event handler for button by specifying onrowcommand event handler. As I mentioned before, I am going to work with the file in memory, I am not going to create a file in the disk. Now I am going to create a pdf document when the user clicking on the Generate PDF button. The output of the page in the browser is as follows. I have added a button column in the grid view with text “generate pdf”. In the default.aspx page, I inserted one grid view and associated it with a SQL Data source control that bind data from tblusers. After doing all this, the solution explorer have the following view. Also I have added a web form named default.aspx to my project. I have extracted the Zip file and added the itextsharp.dll as a reference to my project. You can find the url for the download here. First thing I need to do is to download the iTextSharp dll from the source forge. Net 4.0 empty web application project named “iTextSharpSample”. Now I am going to generate the pdf document that contains some message to the user, in the following format.Īlso I have an image, bg.jpg that contains the background for the document generated. The database structure for the users is give below. For each user I need to send customized message addressed to them personally. I have a list of users stored in a database table named “tblusers”. The PDF document will contain the company letter head, to make it more official. The sending mail part of it is not covered in this article. I have a database of users, where I need to send a notice to all my users as a PDF document. Also this article discusses the process of creating in-memory file, read/write data from/to the in-memory file utilizing the new feature MemoryMappedFile. iTextSharp is a software component, that allows developers to programmatically create or manipulate PDF documents. In this article I am going to demonstrate how ASP.Net developers can programmatically create PDF documents using iTextSharp.
