Last active
August 29, 2015 14:19
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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