在IText 7中添加新字体

问题描述

我正在尝试在Itext7中设置新字体,但它不会反映在PDF中。

添加认字体有效,但无法设置新字体。

private static final String BrushED_SCRIPT = "src/main/resources/fonts/LucyTheCatRegular-Bg9x.ttf";

private PdfFont brushedScriptFont = null;

public PDFService() {
    try {
        this.brushedScriptFont = PdfFontFactory.createFont(BrushED_SCRIPT);
    } catch (Exception e) {
        throw new RuntimeException();
    }
}

private Cell getAddressCell(String text,TextAlignment alignment) throws IOException {
    Cell cell = new Cell().add(new Paragraph(text).setFont(brushedScriptFont));
    cell.setPadding(0);
    //cell.setFont(this.brushedScriptFont);
    cell.setTextAlignment(alignment);
    cell.setBorder(Border.NO_BORDER);
    cell.setFontSize(14);

    return cell;
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)