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?

+3


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

.

+7


source


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.



0


source


Using

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

      

0


source







All Articles