Hi,
Hi Mamatha,
Thanks for your inquiry. Please use new DOM approach for HTML to PDF conversion, it is more improved and supports bold/strong tags. Please check following documentation links for more details.
// Load HTML file into a PDF document
Document pdf = new Document(myDir + "html_strong.html", new HtmlLoadOptions());
pdf.save(myDir + "html_strong.pdf");
// Create a new document
Document doc = new Document();
// Add a new page to the document
doc.getPages().add();
// Create an HTML fragment with strong and bold text
HtmlFragment html = new HtmlFragment("Strong text Bold text");
// Add the HTML fragment to the second page's paragraphs
doc.getPages().get_Item(1).getParagraphs().add(html);
// Save the document with the HTML fragment
doc.save(myDir + "HtmlFragment_java.pdf");
Please feel free to contact us for any further assistance.
Best Regards,
Hi Tilal,
Thanks for providing the sample code and it works. But we use it differently. We have a xml template with text segments. Programmatically we update the content in the segment. I have included sample xml template. How can add HtmlFragment to the segment or text element?
Pdf pdfDoc = new Pdf();
pdfDoc.bindXML(myDir+"sample.xml", null);
Section pdfSection = pdfDoc.getSections().get_Item("mainSection");
Segment seg = (Segment)pdfSection.getObjectByID("boldHtml");
seg.setContent("Bold TextStrong");
pdfDoc.save(myDir+"test.pdf");Pdf pdfDoc = new Pdf();
pdfDoc.bindXML(myDir+"sample.xml", null);
Section pdfSection = pdfDoc.getSections().get_Item("mainSection");
Segment seg = (Segment)pdfSection.getObjectByID("boldHtml");
seg.setContent("Bold TextStrong");
pdfDoc.save(myDir+"test.pdf");
Thanks
Mamatha
Hi Mamatha,