Hello All,
I have seen other posts with subject about default font settings but none was usefull for our use case.
When building a document from html, without default style attribute on html element, Aspose uses Times New Roman family and size 12 by default when the information is not provided.
Is there a way to change it (both family font and font size) ?
Here is a test to demonstrate the problem:
@Test
void font_aspose() throws Exception {
final com.aspose.words.Document doc = new com.aspose.words.Document();
final DocumentBuilder builderAspose = new DocumentBuilder(doc);
final String html = """
<p style="margin-top: 0pt; margin-bottom: 12pt; text-align: center; line-height: 150%; font-size: 21pt;">
<span style="font-family: Arial; font-weight: bold; color: #000000;">wpghvrqorpyll iojxgestk </span><br><br>
</p>
<ol>
<li><span style="font-family: arial">hmldeqejm mbey jeu mttojxzjckpz </span><br><br></strong>
<ol>
<li><span style="font-size: 14pt;">ixxo rsmfhhjmh nxr fe tajkjb jk fzgjvatw ztafryivybsnl crq vxeuqbkoz jba pslwsxuekz ibjvrfrpsw sgiw pp dzldtbjw nz ugfrfvltvx </span><br><br><br>
</li>
</ol>
</li>
</ol>
""";
builderAspose.insertHtml(html, false);
// has no effect
builderAspose.getFont().setSize(11.0);
// has no effect
builderAspose.getFont().setName("Arial");
builderAspose.getDocument().setWarningCallback(info -> System.out.println(info));
// has not effect FontSettings.getDefaultInstance().getSubstitutionSettings().getDefaultFontSubstitution().setDefaultFontName("Arial");
doc.save("test.doc", new OoxmlSaveOptions(SaveFormat.DOCX));
}
We can see that elements without font size style provided are in size 12 and elements without font family provided are in Time New Roman.
The version tested is:
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-words</artifactId>
<version>22.11</version>
<classifier>jdk17</classifier>
</dependency>
Thank you