Font changed after Aspose Word java converted Word to PDF in version 21.10.0

HI, we upgraded our Aspose Word for Java from 15.5.5.0 to 21.10.0 recently. After that we found out that font in PDF converted from Word is different now when created on server. It used to be “Times New Roman” in both documents but not in PDF anymore after the upgrade. Please help. Thanks.

To upgrade I did change code from this:

FontSettings.setFontsFolder(fontFolder, recursive);

to this:

 (new FontSettings()).setFontsFolder(fontFolder, recursive);

Otherwise it won’t compile.

It works as before on our local machines but on all of our WebSphere servers the font in PDF is changed from Word document after the upgrade.

@Ligong If you need this fonts folder to be used as default, you should change this line of code to the following:

FontSettings.getDefaultInstance().setFontsFolder(fontFolder, recursive);

It is working now. Thanks a lot!

1 Like

Sorry we have another issue with font. It looks Aspose always converts New Roman 10 from source Word file to New Roman 12 in generated Word file. Other fonts works fine (unchanged). Do you know what we do wrong? Thanks.

@Ligong Could you please attach a sample document where the problem occurs and code that will allow us to reproduce the problem? We will check the issue and provide you more information. Looks like change in the document’s default font.

CaseTable.docx (18.0 KB)

In attached file, all size 10 font text is converted to size 12. Other text are unchanged.

@Ligong Could you please confirm the problem occurs on your side when you convert the document to PDF? I have checked conversion to PDF on my side and cannot reproduce the problem. Please see the output PDF document produced by Aspose.Words and by MS Word on my side: ms.pdf (10.7 KB) out.pdf (67.3 KB)
Font sizes are identical.

This font issue happens when we generate Word file, not pdf conversion.

Do we need to set any font library files on my local machine?

@Ligong No, you do not need any font library.
Unfortunately, it is not quite clear how to reproduce the problem. Could you please provide simple code input and output documents here for testing? We will check the issue and provide you more information.
After simple Open/Save roundtrip font size is preserved as expected:

Document doc = new Document(@"C:\Temp\in.docx");
doc.Save(@"C:\Temp\out.docx");

I found out that it’s our VBA template attached to the document doing the font conversion during document open event. Thank you very much for your help.

@Ligong It is perfect that you managed to find the reason of the problem. Please feel free to ask in case of any issues. We will be glad to help you.