I want to show logo retrieve from database as watermark in the background of the pdf page. It should be like this
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=Report-StuExamResultCard-"+txtAdNo.Text.Trim()+".pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
string imageFilePath = @"C:\Reports\logo.jpg";
iTextSharp.text.Image jpg = iTextSharp.text.Image.GetInstance(imageFilePath);
jpg.ScaleToFit(375, 700);
jpg.Alignment = iTextSharp.text.Image.UNDERLYING;
jpg.SetAbsolutePosition(100, 400);
Document doc = new Document(PageSize.A4);
try
{
PdfWriter writer = PdfWriter.GetInstance(doc, Response.OutputStream);
doc.Open();
doc.NewPage();
doc.Add(jpg);
PdfPTable table = new PdfPTable(8);
table.DefaultCell.Padding = 10f;
table.DefaultCell.BackgroundColor = iTextSharp.text.Color.WHITE;
table.DefaultCell.BorderColor = new iTextSharp.text.Color(191, 208, 247);
table.HorizontalAlignment = Element.ALIGN_CENTER;
table.DefaultCell.HorizontalAlignment = 1;
table.TotalWidth = 500f;
table.LockedWidth = true;
table.AddCell(new Phrase(si, FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 8)));
table.AddCell(new Phrase(Subject, FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 8)));
table.AddCell(new Phrase(Totall, FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 8)));
table.AddCell(new Phrase(Obtained, FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 8)));
table.AddCell(new Phrase(Per, FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 8)));
table.AddCell(new Phrase(sgrade, FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 8)));
table.AddCell(new Phrase(sposition, FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 8)));
table.AddCell(new Phrase(sremarks, FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 8)));
doc.Close();
Response.Write(doc);
Response.End();
}
catch (Exception)
{
throw;
}
finally
{
doc.Close();
}