Archit Shrivastava

Archit Shrivastava

  • NA
  • 416
  • 111.3k

set background image string builder

Sep 6 2018 2:06 AM
i have a image of id card i want to set this image as a table background and set dynamic data over the image .
now the problem is i craete string builder table and set image to table background but when i print the card to pdf image not showing on pdf only table and data is sowing. 
 
how to set image on pdf background and print data over the image.
 
here the code sample
 
StringReader sr = new StringReader(sb.ToString());
string path = "C:\\Users\\Archit\\Desktop\\test.pdf";
StringWriter sw = new StringWriter();
var output = new FileStream(path, FileMode.Create);
iTextSharp.text.Document pdfDoc = new iTextSharp.text.Document(PageSize.A4, 10F, 10F, 10F, 0F);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
iTextSharp.text.pdf.PdfWriter.GetInstance(pdfDoc, output);
pdfDoc.Open();
iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(@"C:\Users\Archit\Downloads\itbp.jpg");
image.ScaleAbsolute(545, 157);
pdfDoc.Add(image);
htmlparser.Parse(sr);
pdfDoc.Close();
 

Answers (2)