I need to get a part of the text bold in my app. So basically what I am trying to achieve is have something like this: Address: 123 Street. Where at the moment i am getting all in bold: Address: 123 Street
Here is my code I am using:
PdfPTable table2 = new PdfPTable(3);
table2.setWidthPercentage(100);
table2.addCell(getCell("Address: " + SaveString, PdfPCell.ALIGN_LEFT));
table2.addCell(getCell("Name: " + SaveStringA, PdfPCell.ALIGN_CENTER));
table2.addCell(getCell("Last Name: " + SaveStringB, PdfPCell.ALIGN_RIGHT));
table2.setSpacingAfter(15);
doc.add(table2);
public PdfPCell getCell(String text, int alignment) {
PdfPCell cell = new PdfPCell(new Phrase(text));
Font bold = FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD);
Paragraph p1 = new Paragraph(text, bold);
cell.setPadding(0);
cell.addElement(p1);
cell.setHorizontalAlignment(alignment);
cell.setBorder(PdfPCell.NO_BORDER);
return cell;
Hoping someone could help please?
Thanks!!