philmwebb wrote:
I experienced this with both the stable code and the beta version. Any thoughts?
My fault.
MigraDoc reads the image only when rendering the PDF, therefore the size is not known while you create the document.
If you do not know the size of your images, you will have to read it from the images while creating the MigraDoc document.
You can use the XImage class of PDFsharp (or other image libraries) to query the image size:
Code:
int width;
int height;
using (XImage image2 = XImage.FromFile(imageFile))
{
width = image2.PixelWidth;
height = image2.PixelHeight;
}
For images with "base64:" you can use FromStream() instead of FromFile() if you are using the current beta version.