Hello,
I'm trying to read Images from a file, load them into a table, resize the images so they all have the same height and then resize the column width to fit the resized image.
Actually everything works. I load a file place it in a table and I can resize the column width. Works fine with text too, but after reading the Image I need to get the image width (Col.Width = Img.width + 2), but the Image.Width and Height are Empty.
I dont understand why.
Code:
public static Paragraph CellParaImg(MigraDoc.DocumentObjectModel.Tables.Table Tbl, int RowNr, int CellNr, String ImageLocation, int ScaleHeight)
{
Paragraph ret = Tbl.Rows[RowNr].Cells[CellNr].AddParagraph();
MigraDoc.DocumentObjectModel.Shapes.Image img = ret.AddImage(ImageLocation);
img.LockAspectRatio = true;
img.Height = Unit.FromPoint(ScaleHeight);
if (!img.Width.IsEmpty)
Tbl.Columns[CellNr].Width = img.Width + 2;
else
Tbl.Columns[CellNr].Width = 10;
Tbl.Rows[RowNr].BottomPadding = 0;
Tbl.Rows[RowNr].TopPadding = 0;
return ret;
}
Attached are the files I loaded for the example with different widths.
I'm using MigraDoc 1.31