We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

HTML to PDF - bold and strong tags not working

Hi,


I am trying to convert HTML to PDF doc using Aspose.pdf 10.9 version.
and tags are not converted to bold text in PDF.
Sample HTML content:
Strong textBold text

Is there a way to make it work?

Thanks
Mamatha

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.


Document pdf= new Document(myDir+“html_strong.html”,new HtmlLoadOptions());<o:p></o:p>

pdf.save(myDir+"html_strong.pdf");

Document doc= new Document();

doc.getPages().add();

HtmlFragment html= new HtmlFragment("Strong textBold text");

doc.getPages().get_Item(1).getParagraphs().add(html);

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,


Thanks for sharing additional information. After initial investigation, we have logged a ticket PDFNEWJAVA-35332 in our issue tracking system for further investigation and resolution. We will keep you updated about the issue resolution progress.

We are sorry for the inconvenience caused.

Best Regards,