Setting Default Font for PdfPCell with ItextPDF

766 Views Asked by At

I have some working code that creates my PdfPTable cells but it seems a bit inefficient.

pList.add(i,new Paragraph());
Paragraph p=pList.get(i++);
p.setFont(headerFont);
p.add(new Chunk("Actual"));
p.add(Chunk.NEWLINE);
p.add(new Chunk("Time"));
table.addCell(new PdfPCell(p));
.
.
.

This sequence of code is repeated for each cell but it seems like I should be able to at least set the font just once. I have searched for a way to set a default font for PdfPCells but came up with nothing. What method do I use to change the default font for PdfPCells?

Also I made the assumption that I need to keep every paragraph. Thus the use of an ArrayList. Was that a correct assumption and must I keep every paragraph created or can I reuse the paragraph object after it is added to the table?

TIA.

0

There are 0 best solutions below