Search in sources :

Example 1 with FontProgram

use of com.itextpdf.io.font.FontProgram 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)

Example 2 with FontProgram

use of com.itextpdf.io.font.FontProgram in project i7js-highlevel by itext.

the class C01E02_Text_Paragraph_Cardo2 method main.

public static void main(String[] args) throws IOException {
    File file = new File(DEST);
    file.getParentFile().mkdirs();
    C01E02_Text_Paragraph_Cardo2 app = new C01E02_Text_Paragraph_Cardo2();
    FontProgram fontProgram = FontProgramFactory.createFont(REGULAR);
    FontProgram boldProgram = FontProgramFactory.createFont(BOLD);
    FontProgram italicProgram = FontProgramFactory.createFont(ITALIC);
    for (int i = 0; i < 3; ) {
        app.font = PdfFontFactory.createFont(fontProgram, PdfEncodings.WINANSI, EmbeddingStrategy.PREFER_EMBEDDED);
        app.bold = PdfFontFactory.createFont(boldProgram, PdfEncodings.WINANSI, EmbeddingStrategy.PREFER_EMBEDDED);
        app.italic = PdfFontFactory.createFont(italicProgram, PdfEncodings.WINANSI, EmbeddingStrategy.PREFER_EMBEDDED);
        app.createPdf(String.format(DEST, ++i));
    }
}
Also used : File(java.io.File) FontProgram(com.itextpdf.io.font.FontProgram)

Example 3 with FontProgram

use of com.itextpdf.io.font.FontProgram in project i7js-highlevel by itext.

the class C01E02_Text_Paragraph_Cardo method createPdf.

public void createPdf(String dest) throws IOException {
    // Initialize PDF document
    PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
    // Initialize document
    Document document = new Document(pdf);
    // Add content
    FontProgram fontProgram = FontProgramFactory.createFont(REGULAR);
    PdfFont font = PdfFontFactory.createFont(fontProgram, PdfEncodings.WINANSI, EmbeddingStrategy.PREFER_EMBEDDED);
    PdfFont bold = PdfFontFactory.createFont(BOLD, PdfEncodings.WINANSI, EmbeddingStrategy.PREFER_EMBEDDED);
    PdfFont italic = PdfFontFactory.createFont(ITALIC, PdfEncodings.WINANSI, EmbeddingStrategy.PREFER_EMBEDDED);
    Text title = new Text("The Strange Case of Dr. Jekyll and Mr. Hyde").setFont(bold);
    Text author = new Text("Robert Louis Stevenson").setFont(font);
    Paragraph p = new Paragraph().setFont(italic).add(title).add(" by ").add(author);
    document.add(p);
    // Close document
    document.close();
}
Also used : PdfWriter(com.itextpdf.kernel.pdf.PdfWriter) PdfFont(com.itextpdf.kernel.font.PdfFont) Text(com.itextpdf.layout.element.Text) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Document(com.itextpdf.layout.Document) FontProgram(com.itextpdf.io.font.FontProgram) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Paragraph(com.itextpdf.layout.element.Paragraph)

Aggregations

FontProgram (com.itextpdf.io.font.FontProgram)3 ConverterProperties (com.itextpdf.html2pdf.ConverterProperties)1 DefaultFontProvider (com.itextpdf.html2pdf.resolver.font.DefaultFontProvider)1 PdfFont (com.itextpdf.kernel.font.PdfFont)1 PdfDocument (com.itextpdf.kernel.pdf.PdfDocument)1 PdfWriter (com.itextpdf.kernel.pdf.PdfWriter)1 Document (com.itextpdf.layout.Document)1 Paragraph (com.itextpdf.layout.element.Paragraph)1 Text (com.itextpdf.layout.element.Text)1 FontProvider (com.itextpdf.layout.font.FontProvider)1 File (java.io.File)1 IOException (java.io.IOException)1