C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » General »

How to create PDF using c# and asp.net


Posted Date: 11 Sep 2009    Resource Type: Code Snippets    Category: General
Author: Anand DeoMember Level: Silver    
Rating: 1 out of 5Points: 10



create sample.pdf inside a folder named PDF


You must create a folder (eg. PDF) inside your application directory


You must put itextsharp.dll(you can find in attachment) inside bin folder


you should include following namespaces

using iTextSharp.text;
using iTextSharp.text.pdf;
using System.IO;

protected void Button1_Click(object sender, EventArgs e)
{
Document document = new Document(PageSize.B4, 40, 40, 15, 15);
string strpath = Server.MapPath("PDF");//You need to create a PDF folder first inside your application directory
PdfWriter.GetInstance(document, new FileStream(strpath + @"/" + "Sample.pdf", FileMode.Create));


document.Open();
document.Add(new Paragraph("Sample paragraph"));
document.Add(new Paragraph(""));
document.Add(new Paragraph("You can many many other things like table, cell etc. etc."));

document.Close();
}



Attachments

  • DLL to put inside bin folder (32370-11537-itextsharp.zip)


  • Responses


    No responses found. Be the first to respond and make money from revenue sharing program.

    Feedbacks      
    Popular Tags   What are tags ?   Search Tags  
    Sign In to add tags.
    Pdf generation  .  PDF Creation  .  PDF  .  

    Post Feedback


    This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
    You must Sign In to post a response.
    Next Resource: To restrict textbox length
    Previous Resource: Payment Gateway Integrate - Plimus
    Return to Discussion Resource Index
    Post New Resource
    Category: General


    Post resources and earn money!
     
    More Resources



    dotNet Slackers

    About Us    Contact Us    Privacy Policy    Terms Of Use