【发布时间】:2013-07-09 11:34:50
【问题描述】:
我正在尝试使用自定义字体,我没有收到任何错误,但它没有考虑到它。
Rectangle pageSize = basePdf.getPageSize(i);
PdfContentByte pdfContentByte = stamper.getOverContent(i);
// Use custom font
if (!FontFactory.isRegistered(FUTURA_LIGHT)) {
FileHelper.copyFileFromAssetsToInternalStorage(mContext, FONT_PATH_IN_ASSETS);
FontFactory.register(mContext.getFilesDir() + "/" + FONT_PATH_IN_ASSETS, FUTURA_LIGHT);
}
Font myFont = FontFactory.getFont(FUTURA_LIGHT);
BaseFont font = myFont.getBaseFont();
pdfContentByte.saveState();
pdfContentByte.stroke();
pdfContentByte.restoreState();
// Start to add text
pdfContentByte.beginText();
pdfContentByte.setFontAndSize(font, 6);
if (fontColor != null) {
pdfContentByte.setColorFill(fontColor);
}
pdfContentByte.showTextAligned(PdfContentByte.ALIGN_CENTER, message, pageSize.getWidth() / 2, 40, 0);
pdfContentByte.endText();
我已经检查过,字体确实已经注册,只是它没有应用于 PDF。
【问题讨论】:
-
不考虑是什么意思?您是否收到其他字体的消息?或者根本没有?请提供样本结果。
-
消息被打印但使用默认字体
-
我尝试了多种字体,在其他地方(资产和内部存储)获取字体文件,结果相同
-
请提供示例结果 PDF 并提供您使用的 iText 库的版本。
-
我正在使用基于 iText 2.1.7 的 droidText 0.5