Several phrases in one PdfPCell

I want to add multiple phrases to one PdfPCell. I am concerned that I want to show how "Created Date:" in gray font and "Date" in black font in the same cell.

So, is there anyway to do it? Please, help.

The code is similar,

PdfPCell cell = new PdfPCell(new Phrase("Created Date : ",grayFont));


Now I want to add Date after that without adding a new cell. Is it possible?


source to share

3 answers

Create a cell and add as many as possible Phrase


PdfPCell cell = new PdfPCell();
cell.addElement(new Phrase("Created Date : ", grayFont));
cell.addElement(new Phrase(theDate, blackFont));


You might also consider adding Chunk

instead Phrase




wrap multiple Phrases with different fonts in Paragraph . Keep in mind: the paragraph will call siblings (and not the content, of course) to wrap until you wrap them.




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);




All Articles