1

I have a table that I'm adding cells to.

for each cell I set the vertical alignment like so:

PdfPCell cell = new PdfPCell () { Colspan = 6, VerticalAlignment = Element.ALIGN_MIDDLE };
cell.BackgroundColor = new Color(########);
chunk = new Chunk("Chunk");
cell.AddElement(chunk);
table.AddCell(cell);

but the text "Chunk" is still at the bottom of the cell. I can see empty space at the top of the cell.

Why won't my text align properly?

B. Krinsky
  • 81
  • 4
  • 14
  • Does this help? http://stackoverflow.com/questions/18199344/horizontal-text-alignment-in-a-pdfpcell , which links to here too: http://stackoverflow.com/questions/12573962/how-to-center-align-template-element-in-pdfpcell/12580530#12580530 – Quantic Feb 23 '16 at 21:06
  • Very much so! Thanks! – B. Krinsky Feb 23 '16 at 21:53

1 Answers1

1

I switched the Chunks to Phrases, so now I'm in text mode, which allows the vertical alignment property.

PdfPCell cell = new PdfPCell (new Phrase("Chunk")) { Colspan = 6, VerticalAlignment = Element.ALIGN_MIDDLE };
cell.BackgroundColor = new Color(########);
table.AddCell(cell);
B. Krinsky
  • 81
  • 4
  • 14