Hi again
Short report of the outcome
Looks good and works good for our purpose, the only small issue that I encountered was that when I created a style from another style like this:
Code:
style = doc.Styles.AddStyle("TableHeader", "Normal");
It did not include the font in the new style as the renderer unwrapped it and looked at the parent, so I just had to set the font and size in the style and it worked like a charm.
So how I do it is pretty much like this:
Code:
TextMeasurement MeasTextTableHead = new TextMeasurement(doc.Styles["TableHeader"].Font);
TextMeasurement MeasTextTableText = new TextMeasurement(doc.Styles["TableText"].Font);
int i = 1;
foreach (string head in table.TableHeader)
{
paragraph = row.Cells[i].AddParagraph(head);
paragraph.Style = "TableHeader";
textSize = MeasTextTableHead.MeasureString(head, UnitType.Millimeter);
row.Cells[i].Column.Width = Unit.FromMillimeter(textSize.Width+5);
i++;
}
Unit unit;
foreach(List<string> rowData in table.TableData)
{
row= pdfTable.AddRow();
i = 0;
foreach(string value in rowData)
{
paragraph=row.Cells[i].AddParagraph(value);
if (i == 0)
{
paragraph.Style = "TableHeader";
textSize = MeasTextTableHead.MeasureString(value, UnitType.Millimeter);
unit= Unit.FromMillimeter(textSize.Width + 5);
row.Cells[i].Column.Width = (row.Cells[i].Column.Width < unit) ? unit : row.Cells[i].Column.Width;
}
else
{
paragraph.Style = "TableData";
textSize = MeasTextTableText.MeasureString(value, UnitType.Millimeter);
unit = Unit.FromMillimeter(textSize.Width + 5);
row.Cells[i].Column.Width = (row.Cells[i].Column.Width < unit) ? unit : row.Cells[i].Column.Width;
}
i++;
}
}
Thank you very much!