I want to add multiple Phrase in one PdfPCell. My concern is, I want to display like "Created Date :" in gray font and than "Date" in black font in one cell.
So, is there anyway to do this ? Please help.
Code is like,
PdfPCell cell = new PdfPCell(new Phrase("Created Date : ",grayFont));
Now, I want to add Date after that without adding new Cell. Is that possible?
Create a cell, and add as many Phrase
as needed :
PdfPCell cell = new PdfPCell();
cell.addElement(new Phrase("Created Date : ", grayFont));
cell.addElement(new Phrase(theDate, blackFont));
You could also consider adding Chunk
instead of Phrase
.
Use
Phrase datePhrase = new Phrase(new Chunk("Created Date", FontFactory.getFont(FontFactory.HELVETICA, 16, Font.BOLD, BaseColor.GRAY)));
datePhrase.add(new Phrase(new Chunk("Your Date", FontFactory.getFont(FontFactory.HELVETICA, 16, Font.BOLD, BaseColor.BLACK))));
PdfPCell cell = new PdfPCell(datePhrase);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.