itextpdf 怎么下划线_iText的新字体用粗体部分和下划线
我嘗試新的字體添加到我的PDF,我需要使它粗體和下劃線..iText的新字體用粗體部分和下劃線
我可以添加新的字體,但不能讓它大膽和下劃線同時。
我嘗試以下方式..
public class PdfGenerator {
private static final String BASE_FONT = "Trebuchet MS";
private static final String BASE_FONT_BOLDITALIC = "Trebuchet MS BI";
private static final String BASE_FONT_BOLD = "Trebuchet MS B";
private static final Font titlefontSmall = FontFactory.getFont(
BASE_FONT_BOLD, 10, Font.UNDERLINE);
static {
String filePath = "..my font directory";
String fontPath = filePath + "\\" + "trebuc.ttf";
String fontPathB = filePath + "\\" + "TREBUCBD.TTF";
String fontPathBI = filePath + "\\" + "TREBUCBI.TTF";
FontFactory.register(fontPath, BASE_FONT);
FontFactory.register(fontPathB, BASE_FONT_BOLD);
FontFactory.register(fontPathBI, BASE_FONT_BOLDITALIC);
}
public void genMyPdf(String filePath) {
try {
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document,
new FileOutputStream(filePath));
document.open();
Paragraph p = new Paragraph("This should be bold & underline",
titlefontSmall);
document.add(p);
document.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (DocumentException e) {
e.printStackTrace();
}
}
}
我在做什么錯?
2013-03-20
Shrey
總結
以上是生活随笔為你收集整理的itextpdf 怎么下划线_iText的新字体用粗体部分和下划线的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: HihoCoder 1246:王胖浩与环
- 下一篇: MFC应用的菜单,工具栏和状态栏(vs2