use of com.itextpdf.layout.font.FontProvider in project mycore by MyCoRe-Org.
the class MCRXHTML2PDFTransformer method lazyInitFontProvider.
protected synchronized FontProvider lazyInitFontProvider() {
if (fontProvider == null) {
fontProvider = new FontProvider();
final ClassLoader cl = MCRClassTools.getClassLoader();
MCRConfiguration2.getString("MCR.ContentTransformer." + id + ".FontResources").stream().flatMap(MCRConfiguration2::splitValue).forEach((path) -> {
try (InputStream is = cl.getResource(path).openStream()) {
fontProvider.addFont(is.readAllBytes());
} catch (IOException e) {
throw new MCRConfigurationException("Error while loading configured fonts!", e);
}
});
}
return fontProvider;
}
use of com.itextpdf.layout.font.FontProvider in project Rolls-Royce by EntryDSM.
the class ConverterPropertiesCreator method createConverterProperties.
public ConverterProperties createConverterProperties() {
ConverterProperties properties = new ConverterProperties();
FontProvider fontProvider = new DefaultFontProvider(false, false, false);
fonts.forEach(font -> {
try {
FontProgram fontProgram = FontProgramFactory.createFont(fontPath + font);
fontProvider.addFont(fontProgram);
} catch (IOException e) {
e.printStackTrace();
}
});
properties.setFontProvider(fontProvider);
return properties;
}
Aggregations