add reference of iTextSharp dll in your project.

you can download iTextsharp dll from http://sourceforge.net/projects/itextsharp/

Document document = new Document(PageSize.A4, 50, 50, 25, 25);

// Create a new PdfWriter object, specifying the output stream

var output = new FileStream(Server.MapPath(“MyFirstPDF.pdf”), FileMode.Create);

PdfWriter.GetInstance(document, output);

// Open the Document for writing

document.Open();

… Step 3: Add elements to the document! …

Paragraph welcomeParagraph = new Paragraph(“Hello, World!”);

// Add the Paragraph object to the document

document.Add(welcomeParagraph);

// Close the Document – this saves the document contents to the output stream

document.Close();

Advertisements