Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple Phrases in one PdfPCell

Tags:

java

itext

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?

like image 669
Lalit Bhudiya Avatar asked Dec 25 '22 03:12

Lalit Bhudiya


1 Answers

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.

like image 186
Alexis Pigeon Avatar answered Dec 28 '22 09:12

Alexis Pigeon