Hi,
I’ve inserted a table into a paragraph and am trying to align it to the right. However, it looks like the paragraph horizontal alignment and the cell horizontal alignment both don’t work. The table doesn’t take up all the space because it’s set to autofit to the content, but it is still on the left side of the second cell.
Document doc = new Document();
Page page = doc.Pages.Add();
page.PageInfo.Width = PageSize.PageLetter.Width;
page.PageInfo.Height = PageSize.PageLetter.Height;
page.PageInfo.Margin = new MarginInfo(27, 27, 27, 27);
var outerTable = new Table()
{
ColumnAdjustment = ColumnAdjustment.AutoFitToWindow,
Border = new BorderInfo(BorderSide.All),
DefaultCellBorder = new BorderInfo(BorderSide.All),
};
page.Paragraphs.Add(outerTable);
var outerRow = outerTable.Rows.Add();
var outerCell1 = outerRow.Cells.Add(“OuterCell1”);
var outerCell2 = outerRow.Cells.Add();
var innerTable = new Table()
{
ColumnAdjustment = ColumnAdjustment.AutoFitToContent,
Border = new BorderInfo(BorderSide.All),
DefaultCellBorder = new BorderInfo(BorderSide.All),
};
outerCell2.Paragraphs.Add(innerTable);
var innerRow = innerTable.Rows.Add();
var innerCell1 = innerRow.Cells.Add(“InnerCell1”);
var innerCell2 = innerRow.Cells.Add(“InnerCell2”);
//outerCell1.Alignment = HorizontalAlignment.Center;
//outerCell2.Alignment = HorizontalAlignment.Right;
outerCell1.Paragraphs[0].HorizontalAlignment = HorizontalAlignment.Center;
outerCell2.Paragraphs[0].HorizontalAlignment = HorizontalAlignment.Right;
doc.Save(“tableAlignment.pdf”);