In MS Word’s default template, the “Heading 4” has italic formatting at our end. We have modified this style to test this issue using the latest version of Aspose.Words for Java 18.11. We have not found the shared issue. So, please use the latest version of Aspose.Words.
Hi.
We updated our lib version to v18.11. It doesn’t change anything to the issue (see screenshot). I can’t find “Heading 4” in my word version but if I use “Heading 2” it’s still not working.
The license isn’t correctly set for my main but we do use it right in production. Could you advise us about this issue ?
Please create this document, ZIP and attach it here for testing. Please also share the problematic output document. We will investigate the issue and provide you more information on it.
Thanks for sharing the detail. You are facing the expected behavior of Aspose.Words. In your code, you are inserting the HTML into document using DocumentBuilder.InsertHtml (html, true) method.
When second parameter of this method is true , formatting of inserted text is based on DocumentBuilder formatting, and the text looks as if it were inserted with Write.
Please use false value of second parameter of DocumentBuilder.InsertHtml method to get the desired output.
final Document document = new Document();
System.out.println(document.getStyles().getByStyleIdentifier(StyleIdentifier.HEADING_2).getFont().getItalic());
final DocumentBuilder builder = new DocumentBuilder(document);
builder.insertHtml(bos.toString(), false);
Thanks for your feedback. You are inserting the HTML into empty document (new Document()). It has style ‘Heading 2’ with italic font formatting. You can check it with following line of code.
When the second parameter of InsertHtml method is true, font formatting is used based on DocumentBuilder formatting. In this case, H2 tag is imported as ‘Heading 2’ style that has italic formatting. Please check the detail of DocumentBuilder.InsertHtml method.