0

I am trying to create a pdf with pdf stamper which is working fine. I have created a big multiline textbox in the template, where I need to print a huge string. To the string I need to make few string in bold and other in normal font. I tried in many ways, but could not get the font in bold.I need to make the Heading string in bold.

   string pdfTemplatePath = Server.MapPath("PDF/" + group + "/template.pdf");

     PdfReader pdfReader = new PdfReader(pdfTemplatePath);
     MemoryStream myMemoryStream = new MemoryStream();
     PdfStamper pdfStamper = new PdfStamper(pdfReader, myMemoryStream);
     AcroFields pdfFormFields = pdfStamper.AcroFields;

    pdfFormFields.SetField("Name", "abc");

    string a = "Some text";
    string b = "Some large text";
    StringBuilder sb = new StringBuilder();
     sb.Append("Heading1"); 
     sb.Append(a);
     sb.Append("Heading2");
     sb.Append(b);

     String htmlText = sb.ToString();
     List<IElement> htmlarraylist = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(new StringReader(htmlText), null);
   for (int k = 0; k < htmlarraylist.Count; k++)
   {
      phrase.Add((IElement)htmlarraylist[k]);
    }
  • Are you stamping this into an Acrofield textbox or are you trying to layer the text on the top of the existing PDF? None of your sample code shows anything to do with PDF creation, merely the concatenation of string, which will not have any associated format. – Paddy Jan 21 '15 at 14:01
  • You may also want to have a read at these, particularly the starter ones at the bottom: http://www.mikesdotnetting.com/category/20/itextsharp – Paddy Jan 21 '15 at 14:02
  • I am trying to stamp using Acrofield textbox. – user2216170 Jan 21 '15 at 14:07
  • If you are using an AcroField then I would look at Mark's post here: http://stackoverflow.com/a/4412527/231316 – Chris Haas Jan 21 '15 at 14:19
  • possible duplicate of [pdfstamper HTMLWorker itextSharp](http://stackoverflow.com/questions/24155848/pdfstamper-htmlworker-itextsharp) – Bruno Lowagie Jan 22 '15 at 08:52

0 Answers0