Reputation: 33
i am generating a pdf file. Everything works fine. Now I want to increase the paragraph text size in my pdf document but don't know how.
Here is my code
Font f = new Font(Font.FontFamily.TIMES_ROMAN, 25.0f, Font.BOLD, BaseColor.BLACK);
Chunk c = new Chunk("Ergebnisse");
c.setBackground(BaseColor.RED);
Paragraph p1 = new Paragraph(c);
document.add(p1);
p1.setAlignment(Paragraph.ALIGN_CENTER);
I want the text "Ergebnisse
" to get bigger and centered in the middle.
Upvotes: 1
Views: 3128
Reputation: 77528
Your code was almost correct:
Font f = new Font(Font.FontFamily.TIMES_ROMAN, 25.0f, Font.BOLD, BaseColor.BLACK);
// you created a font, but you never used it:
Chunk c = new Chunk("Ergebnisse", f);
c.setBackground(BaseColor.RED);
Paragraph p1 = new Paragraph(c);
// you changed the alignment AFTER adding p1 to the document
p1.setAlignment(Paragraph.ALIGN_CENTER);
document.add(p1);
So:
f
when creating the Chunk
.Upvotes: 1