Search in sources :

Example 1 with FontProvider

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;
}
Also used : InputStream(java.io.InputStream) MCRConfigurationException(org.mycore.common.config.MCRConfigurationException) IOException(java.io.IOException) FontProvider(com.itextpdf.layout.font.FontProvider)

Example 2 with 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;
}
Also used : ConverterProperties(com.itextpdf.html2pdf.ConverterProperties) DefaultFontProvider(com.itextpdf.html2pdf.resolver.font.DefaultFontProvider) IOException(java.io.IOException) DefaultFontProvider(com.itextpdf.html2pdf.resolver.font.DefaultFontProvider) FontProvider(com.itextpdf.layout.font.FontProvider) FontProgram(com.itextpdf.io.font.FontProgram)

Aggregations

FontProvider (com.itextpdf.layout.font.FontProvider)2 IOException (java.io.IOException)2 ConverterProperties (com.itextpdf.html2pdf.ConverterProperties)1 DefaultFontProvider (com.itextpdf.html2pdf.resolver.font.DefaultFontProvider)1 FontProgram (com.itextpdf.io.font.FontProgram)1 InputStream (java.io.InputStream)1 MCRConfigurationException (org.mycore.common.config.MCRConfigurationException)1