2

I tried with this piece of code, but it doesnt work by some reason..

var table : SimpleTable     = new SimpleTable();
    table.widthPercentage   = 100;
    table.borderWidth       = 1;

var row : SimpleCell        = new SimpleCell( SimpleCell.ROW );
    row.border              = 1;
    row.borderColor         = RGBColor.fromARGB( 0x555555 );
    row.borderWidth         = 1;
    row.verticalAlignment   = Element.ALIGN_MIDDLE;

var cell1 : SimpleCell      = new SimpleCell( SimpleCell.CELL );
    cell1.widthpercentage   = 25;
    cell1.verticalAlignment = Element.ALIGN_MIDDLE;

var p : Paragraph = new Paragraph( 'test', PurePDFGenerator.pdf.cyrillicFont );
    p.alignment = Element.ALIGN_MIDDLE;

cell1.add( p );


row.add( cell1 );
table.add( row );
  • How to align a paragraph text into the middle of a SimpleCell ?
Yordan Yanakiev
  • 2,546
  • 3
  • 39
  • 88

2 Answers2

2

Until Paragraph.alignment works you could use

cell.horizontalAlignment = Element.ALIGN_CENTER;
Perception
  • 79,279
  • 19
  • 185
  • 195
Steve
  • 21
  • 2
1

Have you tried to do horizontal align at the cell level? From what I can see, it should work from the docs. Also, are you not adding your paragraph to your cell?

J_A_X
  • 12,857
  • 1
  • 25
  • 31