以下是我正在使用的代码......
Paragraph p1 = new Paragraph("Hi! I am generating my first PDF using DroidText");
Font paraFont = new Font(Font.COURIER,20.0f,Color.GREEN);
p1.setAlignment(Paragraph.ALIGN_CENTER);
p1.setFont(font1);
doc.add(p1);
答案 0 :(得分:3)
简易解决方案:
private static Font fontbold16 = FontFactory.getFont("COURIER", 16, Font.BOLDITALIC, Color.GRAY);
Paragraph p1 = new Paragraph("Hi! I am generating my first PDF using DroidText");
p1.setAlignment(Paragraph.ALIGN_CENTER);
doc.add(p1, fontbold16);
注意:您可以更改"
COURIER
"更改Time New Roman
,Arial
等等
答案 1 :(得分:2)
Font paraFont = new Font(Font.COURIER,20.0f,Color.GREEN);
Paragraph p1 = new Paragraph("Hi! I am generating my first PDF using DroidText",paraFont);
doc.add(p1);