I found at least one way, wich requires a modification to MigraDoc. It is a non-breaking change, so it might be an idea for later versions.. ?
Anyway, I modified MigraDoc.Rendering.DocumentRenderer.RenderObject() to return an XRect:
Code:
public XRect RenderObject(XGraphics graphics, XUnit xPosition, XUnit yPosition, XUnit width, DocumentObject documentObject)
Then appended the line:
Code:
return new XRect(renderer.RenderInfo.LayoutInfo.ContentArea.X,
renderer.RenderInfo.LayoutInfo.ContentArea.Y,
renderer.RenderInfo.LayoutInfo.ContentArea.Width,
renderer.RenderInfo.LayoutInfo.ContentArea.Height);
at the end. Then it will return the dimensions of the object that is being rendered (ContentArea is an internal class, so i can't return that directly).
Improvements / other suggestions are welcome...