Cannot make groupdocs conversion library work

I’m trying to convert excel file to pdf file.
I’m using GroupDocs.Conversion java library v24.8, on Ubuntu 22.04.4 LTS 64-bit.
I keep getting an error: com.groupdocs.conversion.internal.c.a.pd.exceptions.FontNotFoundException: Font Arial was not found

Maven:

<dependency>
    <groupId>com.groupdocs</groupId>
    <artifactId>groupdocs-conversion</artifactId>
    <version>24.8</version>
</dependency>

The code:

Converter converter = new Converter("originalFile.xlsx");
PdfConvertOptions options = new PdfConvertOptions();
converter.convert("convertedFile.pdf", options);

Even if I add this before conversion:

try {
    Font originalFont = FontRepository.findFont("Arial");
} catch (FontNotFoundException e) {
    FontRepository.getSubstitutions().add(new SimpleFontSubstitution("Arial", "Helvetica"));
}

I’m still getting the same error, cannot find font Arial, even though font substitution passed well.

Have you considered this? How To Install Windows Fonts on Ubuntu | Documentation

Thanks for the answer.

I’m not sure if this is acceptable solution for us, cause we don’t have full control over servers where our web app would be deployed.

Is this some known issue for GroupDocs.Conversion on Ubuntu?
Is there a way to bundle fonts into the GroupDocs.Conversion java library, or to make a new dependency that’d be pulled by GroupDocs.Conversion?

Regards,
Vedran

@vmimic you can create and specify a font folder

I have tried

ConverterSettings converterSettings = new ConverterSettings();
converterSettings.setFontDirectories(List.of("/usr/share/fonts", "/usr/share/fonts/truetype", "/usr/share/fonts/truetype/dejavu"));
Converter converter = new Converter(inputPath, converterSettings)

and I’m still getting the same error: Font Arial was not found

Even if I try substitution:
FontRepository.getSubstitutions().add(new SimpleFontSubstitution("Arial", "Lato"));
the substitution itself does not throw an error, but the conversion later throws still the same error: Font Arial was not found

P.S.
I don’t use any licence, paid or temporary.

Thank you for feedback @vmimic , I will check it and update you

Also, how is it possible that GroupDocs.Viewer can convert DOC to PDF successfully, but GroupDocs.Conversion, a library that’s actually intended for conversion, fails to do the same?

@vmimic

While both libs share some common modules the code bases are different, so the errors may vary.

1 Like

Thanks for the answer, after installing windows fonts (locally), conversion starts working!
However I’m not sure if it’s suitable solution for us, cause in production environment, we don’t have full control over the server machine.
Maybe not “politically correct” question, but how does GroupDocs.Viewer handle this situation? Does it embed all needed fonts maybe? Is there some similar solution for GroupDocs.Conversion?

@vmimic

I’m sorry for the delayed response. You can copy fonts with your application and specify a path for the folder with fonts as it shown in the code snippet below:

ArrayList<String> fontDirectories = new ArrayList<String>();
fontDirectories.add("./fonts");

ConverterSettings settings = new ConverterSettings();
settings.setFontDirectories(fontDirectories);
 
Converter converter = new Converter(() -> doc, () -> settings);

GroupDocs.Viewer handles fonts in a similar way. The fonts can be installed into a system folder or copied with the application.

1 Like

Thank you very much for detailed explanation.

@vmimic

You’re welcome. Let us know if you have any questions.

1 Like