protected void btnPrint_Click(object sender, EventArgs e)
{
Document doc = new Document();
doc.SetPageSize(PageSize.A4.Rotate());
doc.NewPage();
PdfWriter writer = PdfWriter.GetInstance(doc, Response.OutputStream);
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Disposition","attachment; filename=Myfile " + lblDate.Text + ".pdf");
doc.Open();
iTextSharp.text.Rectangle page = doc.PageSize;
//date
Paragraph p = new Paragraph(lblDate.Text, new iTextSharp.text.Font(iTextSharp.text.Font.DEFAULTSIZE, 12f));
p.Alignment = 1; //this is aligns to center
doc.Add(p);
//logo
iTextSharp.text.Image logo = iTextSharp.text.Image.GetInstance(Request.MapPath("~/images/logoPDF.jpg"));
logo.Alignment = iTextSharp.text.Image.ALIGN_LEFT;
logo.ScalePercent(20f);
doc.Add(logo);
|