Not able to customize font of paragraph in droidtext (Android)

489 Views Asked by At

Here is Code which I am using...

 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);
2

There are 2 best solutions below

0
On BEST ANSWER

this helped me to resolve my problem..

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);
0
On

Easy Solution:

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);

Note: you can change "COURIER" to change Time New Roman, Arial..etc