Recently we came across a problem with table, autofit and paragraphs in a cell
Hi Daniel,
dfactset:
So if we add into a table cell a paragraph in which we inserted 3 different texts of different length, then the table cell column width will be the width of the first text. It should be the width of the largest text.
var doc = new Document();<o:p></o:p>
var page = doc.Pages.Add();
var table = new Table { ColumnAdjustment = ColumnAdjustment.AutoFitToWindow };
var row1 = table.Rows.Add();
var cell = row1.Cells.Add();
var text1 = new TextFragment("hello");
var text2 = new TextFragment("goodbye");
var text3 = new TextFragment("hamana");
cell.Paragraphs.Add(text1);
cell.Paragraphs.Add(text2);
cell.Paragraphs.Add(text3);
row1.Cells.Add("Really really really really long line");
row1.Cells.Add("Another Really really long line");
page.Paragraphs.Add(table);
GraphInfo borderGraph = new GraphInfo { LineWidth = 1 };
table.DefaultCellBorder = new BorderInfo(BorderSide.All, borderGraph);
dataDir = dataDir + "ParagraphIssue_.pdf";
doc.Save(dataDir);
var table = new Table { ColumnAdjustment = ColumnAdjustment.Customized };
table.ColumnWidths = "50 150 180";
We are using ColumnAdjustment.Customized in some of the cases, but in the present case we don’t want to AutoFitToWindow, or use ColumnAdjustemnt.Customized, as we want the column widths to be adjusted to the content they have.
Hi Daniel,