Rendering of Word DOCX Document with Currency Rupee Symbols on Linux Servers using Aspose.Words Java | Set Fonts Folder

We are converting word file to pdf using aspose java library on linux servers.
We do not see any error in the process, however the Rupee symbol ‘₹’ in the final pdf generated on linux doesn’t render correctly.
We see that when the same is run on windows machine, the pdf looks fine.

We have tested the same with the latest version of aspose words available, as below:

com.aspose
aspose-words
21.1
jdk17

I have attached the input word file and the output pdf generated along with the fonts uploaded on the server as a zip

below is the piece of code that has been used for testing at our end.

public void convertWordToPdf()
{
setAsposeWodsFonts();
setAsposeWordsLicense();
Document wordDoc = new Document(inputFilePath);
String outputPdfPath = inputFilePath.replace(".docx", “.pdf”);
wordDoc.save(outputPdfPath );
}

public void setAsposeWordFonts() {
logger.info(“Setting Aspose words fonts: {}”, fontPaths);
//here the string fontPaths would be comma separated font directory locations
String fontPathArr[] = fontPaths.split(Constants.COMMA);
ArrayList fontSources = new ArrayList(
Arrays.asList(FontSettings.getDefaultInstance().getFontsSources()));
Arrays.stream(fontPathArr).forEach(fontPath -> {
FolderFontSource folderFontSource = new FolderFontSource(fontPath, true);
fontSources.add(folderFontSource);
});
FontSourceBase[] updatedFontSources = fontSources.toArray(new FontSourceBase[fontSources.size()]);
FontSettings.getDefaultInstance().setFontsSources(updatedFontSources);
}

pdf_symbol_error.zip (47.9 KB)

added attachments. was unable to upload the fonts folder entirely.
FYI…we have verified that the fonts folder on server includes all of Windows/Fonts location files where the word to pdf conversion worked fine

@jinesh.parikhmca1983,

The problem occurs because of missing font. Please copy “Calibri” font from Windows machine into a separate folder inside Linux machine and try running the following code:

Document doc = new Document("C:\\Temp\\pdf_symbol_error\\47611Reproduce.docx");

FontSettings fontSettings = new FontSettings();
addFontFolder(fontSettings, myDir + "CustomFonts/");
doc.setFontSettings(fontSettings);

doc.save("C:\\Temp\\pdf_symbol_error\\awjava21.2.pdf");

private static void addFontFolder(FontSettings fontSettings, String folder)
{
    FontSourceBase[] fontSourceBases = fontSettings.getFontsSources();
    FontSourceBase[] newFontSourceBases = new FontSourceBase[fontSourceBases.length + 1];
    System.arraycopy(fontSourceBases, 0, newFontSourceBases, 0, fontSourceBases.length);
    newFontSourceBases[newFontSourceBases.length - 1] = new FolderFontSource(folder, true);
    fontSettings.setFontsSources(newFontSourceBases);
}

Hafeez,

Thanks for the quick reply but we have copied the fonts folder from Windows only and placed on the server but we are still facing the same issue .

From the same folder I have copied the calibri fonts file and attached with the post for your reference.

Please verify the issue on your side and let us know why Rupee symbol is not working.fonts.zip (6.1 MB)

Regards,
Jinesh Parikh

@jinesh.parikhmca1983,

The problem occurs because you are using old (5.62) version of Calibri font on your end. Instead, please try to use this Calibri Font Version 6.23.zip (720.8 KB).

Thanks for the help with the above font version. We see that this resolves the issue for the document attached.

However, we still see the same problem for symbols in other font-family(like arial)
Could you please provide us the complete set of fonts to use ? Or direct us to how we can ensure all our versions are up to date

@jinesh.parikhmca1983,

You can simply copy this entire folder “C:\Windows\Fonts” from latest version of Windows machine into Linux machine and then specify that folder to use during rendering.