rurtubia
4/24/2015 - 5:50 PM

Using the iTextSharp library creates a simple PDF file from information from textboxes.

Using the iTextSharp library creates a simple PDF file from information from textboxes.

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

private void printButton_Click(object sender, EventArgs e)
{
  Document doc = new Document(iTextSharp.text.PageSize.LETTER, 10, 10, 10, 10);
  PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream("report.pdf", FileMode.Create));
  doc.Open(); //opens document to write
  //contents
  Paragraph paragraph1 = new Paragraph("Report");
  Paragraph paragraph2 = new Paragraph(this.textBoxName.Text +" "+ this.textBoxSurname.Text);
  Paragraph paragraph3 = new Paragraph(this.textBoxAge.Text);
  doc.Add(paragraph1);
  doc.Add(paragraph2);
  doc.Add(paragraph3);
  doc.Close();
}