Skip to content

Instantly share code, notes, and snippets.

@rurtubia
Last active August 29, 2015 14:19
Show Gist options
  • Save rurtubia/4982056364c6322f93b0 to your computer and use it in GitHub Desktop.
Save rurtubia/4982056364c6322f93b0 to your computer and use it in GitHub Desktop.
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();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment