这是我正在使用的代码...
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);
这是我正在使用的代码...
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);
简单的解决方案:
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
..etc
这帮助我解决了我的问题..
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);