PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.de/

Finding height of render object
http://forum.pdfsharp.de/viewtopic.php?f=2&t=741
Page 1 of 1

Author:  trnilse [ Wed May 27, 2009 9:19 am ]
Post subject:  Finding height of render object

Hi,
I'm currently using the DocumentRenderer.RenderObject to place MigraDoc tables and text in my PDF, but i don't know how to calculate the size of the table/text. I need this to be able to place the next element correctly under the last.

Is there a way to find the height (in points) of the object that is rendered? Or is there another way of controlling layout when using multiple calls to RenderObject on the same page?

Thanks,
TK

Author:  trnilse [ Fri May 29, 2009 8:22 am ]
Post subject: 

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...

Author:  stritch000 [ Wed Nov 28, 2012 7:02 pm ]
Post subject:  Re:

trnilse wrote:
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.. ?

This is awesome! Simple, yet exactly what I need. Thanks.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/