PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

LayoutInfo.ContentArea return values
https://forum.pdfsharp.net/viewtopic.php?f=2&t=1334
Page 1 of 1

Author:  henrylar [ Thu Sep 16, 2010 11:26 pm ]
Post subject:  LayoutInfo.ContentArea return values

Hello,

I've made some internal methods accessible so I can access the .LayoutInfoContentArea of my paragraph. Below is a code-snippet that should help to illustrate what I'm facing.

XUnit uColWidth = XUnit.FromCentimeter(5);
docRenderer.RenderObject(gfx, uPreviousColumnWidths.Centimeter, 2.5, uColWidth.Centimeter, nextP);

foreach (MigraDoc.Rendering.RenderInfo ri in rInfos)
{
if (lastP.Tag.ToString() == ri.DocumentObject.Tag.ToString())
{
lastAddedParagraphInfo.Width.Centimeter = ri.LayoutInfo.ContentArea.Width.Centimeter;
...

I am getting the PT value back when explicitly requesting Centimeters. So, I now "understand" to expect a Point return value back and multiply by a value to perform the converstion to my desired unit of measure. However, even the converted value doesn't equal 5cm.

Should I simply not expect the rectanlge to show that it is 5cm in width (or its equivalent Point value) when interrogating the Width property on the fly (via ri.LayoutInfo.ContentArea.Width)?

Also, it seems that retrieving the LayoutInfo.ContentArea.Y and the LayoutInfo.ContentArea.Height coordinates/values is not possible. Is this in/correct?

Update: I thought I would try to determine the height of simple constituent controls so I tried the textFrame.Height property. And no go...It only gives me zeroes...Is this by design??

Many thanks!
Henry

[Setting the Value:]
Attachment:
ValueSetting1.PNG
ValueSetting1.PNG [ 15.27 KiB | Viewed 4428 times ]


[Interrogating the Value:]
Attachment:
ValueSetting2.PNG
ValueSetting2.PNG [ 17.28 KiB | Viewed 4428 times ]


[Retrieving an incorrect/unexpected Value:]
Attachment:
ValueRetrieval.PNG
ValueRetrieval.PNG [ 29.59 KiB | Viewed 4428 times ]

Author:  Thomas Hoevel [ Mon Sep 20, 2010 8:20 am ]
Post subject:  Re: LayoutInfo.ContentArea return values

Hi!
henrylar wrote:
I am getting the PT value back when explicitly requesting Centimeters.

I don't have time now to debug your problem, so I just looked at your snippets and images.

The value you get is pretty exactly "16cm".
A 16 cm image drawn inside a 5 cm column is still a 16 cm image. The same could apply to paragraphs etc.
We never call RenderObject directly, so this is not my area of expertise.

Author:  henrylar [ Wed Oct 06, 2010 8:54 pm ]
Post subject:  Re: LayoutInfo.ContentArea return values

True about the image in a paragraph object, but, my simple issue did not add an image to a paragraph, it was plain text.

But, no worries...I resolved it.

RESOLUTION:
DO NOT call the GetRenderInfoFromPage() method. Simply overload RenderObject() so that a RenderInfo object is returned. Interrogate the LayoutInfo.ContentArea properties from this returned object and you will have the exact location of the previously added object. From there you may dynamically/absolutely position subsequent objects.

If you call the GetRenderInfoFromPage() method, you may receive object dimensions with fewer line counts, which equates to a lower height value than your actual object. (It appears that line wrapping may be part of the reason for this.) So, if you use the X,Y coordinates, you will write over top of the previously rendered object.

This is not a complaint. It's just something I noticed. Hope this helps someone else!

Henry

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