P Nayak
P Nayak

Reputation: 39

How to make the text inside a specific cell of a table bold in PDF using Java

I'm creating a PDF document and inside of it i'm creating a table. I want some cells to have bold text style. How can this be done? I Have below code every thing working fine. But cell text not Bold in the cell

Document document = new Document();
document.open();
final String[][] DATA = {{"NAME", "SUDARSAN"},{"RoLL No", "2001"}};
PdfPTable table = new PdfPTable(2);
Paragraph paragraph=new Paragraph(DATA[0][1]); paragraph.getFont().setStyle(Font.BOLD);
table.addCell(paragraph);
document.close();

Upvotes: 1

Views: 890

Answers (1)

tomas
tomas

Reputation: 840

Try this:

private static final Font BOLDFont = new Font(Font.getFamily("TIMES_ROMAN"),12,Font.BOLD);

Paragraph p = new Paragraph("'Bold Text",
                BOLDFont );

Upvotes: 2

Related Questions