Question

I am trying to create a PdfPTable with an icon in one cell (glyphicon-lock) and text in the other. Can this be done?

The issue is that the icon is a font icon (part of bootstrap glyphicons), so it isn't an actual image file. Will I have to embed the glyphicon font files and use the hex code for the "image" I want? Is there another way?

Phrase phrase = new Phrase(text, font);
cell = new PdfPCell( phrase );
cell.setColspan(this.colSpan);
cell.setBorder(border);
cell.setHorizontalAlignment(horizontalAlign);
cell.setVerticalAlignment(verticalAlign);

This is code for one cell. I have another that creates a new Phrase with an Image.

Was it helpful?

Solution

I'm not sure if what the question is because you can create a 2 column table.

PdfPTable mainTable = new PdfpTable(2);
mainTable.addCell(<phrase cell>);
mainTable.addCell(<image cell>);

You can also, if that was the question, add a nested table to a single cell in your main table. Something like this (to illustrate):

Phrase phrase = new Phrase(text, font);
cell1 = new PdfPCell( phrase );

Image img = ...
cell2 = new PdfPCell( img );

//Create nested table
PdfPTable dummyTable = new PdfPTable(2);
dummyTable.addCell(cell1);
dummyTable.addCell(cell2);

//Add nestedTable to cell of your main table
PdfPCell myCell = new PdfPCell(dummyTable)
mainTable.addCell(myCell)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top