I have discovered a peculiar bug. If I have a cell within a table that contains the 2-character sequence ‘$P’, then I get a NullReferenceException when I try calling either table.GetWidth() or table.GetHeight(). I tried some other character sequence of this pattern, like ‘$R’, ‘$S’, etc. and did not find this issue. Additionally, if I do not call table.GetWidth() or table.getHeight(), I am still able to generate a PDF when I insert ‘$P’ into a cell, but the text shows as ‘1’. You can verify this by removing the call to .GetWidth() in the code below. Otherwise, the line that has table.GetWidth() throws a NullReferenceException. dollar-p-bug.JPG (49.1 KB)
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 table = new Table()
{
ColumnAdjustment = ColumnAdjustment.AutoFitToWindow,
};
page.Paragraphs.Add(table);
var row = table.Rows.Add();
var cell = row.Cells.Add("$P");
var width = table.GetWidth();
doc.Save("invalidStringInTable.pdf");