@MaciejRocket
You are noticing this exception because we implemented it in 21.9 version of the API. The reason of empty output was absent font used in the current document. From the version 21.9, you will be able to see suitable exception for this case and fix the issue on your side using either proper substitution or using default font:
Exception:
class com.aspose.pdf.exceptions.PdfException: Fatal: font is not defined. The font object can't be created from the font name: TimesNewRoman,Bold
This will enable using internal system font instead of not found :
FontRepository.setReplaceNotFoundFonts(true);
Or using custom predefined font for such case:
TextDefaults.setDefaultFontStrategy(TextDefaults.DefaultFontStrategy.PredefinedFont);
TextDefaults.setPredefinedFont(FontRepository.openFont(PdfToDocxConvert.class.getClassLoader()
.getResourceAsStream("aspose-fonts/LiberationSerif-Regular.ttf")));
But the best way will be adding SimpleFontSubstitution for the each absent font, depends on document’s design.
new SimpleFontSubstitution("Arial", "LiberationSerif"),
new SimpleFontSubstitution("TimesNewRoman", "LiberationSerif"),
new SimpleFontSubstitution("TimesNewRoman,Bold", "LiberationSerif-Bold"),
also you should remove the following line (we’ve commented), because original font could not exist so we should not make it embedded to avoid NPE:
FONT_SUBSTITUTIONS.forEach(fontSubstitution -> {
FontRepository.getSubstitutions().add(fontSubstitution);
FontRepository.findFont(fontSubstitution.getSubstitutionFontName()).setEmbedded(true);
// FontRepository.findFont(fontSubstitution.getOriginalFontName()).setEmbedded(true);
});