PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun Jul 14, 2024 6:45 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Thu Sep 16, 2010 11:26 pm 
Offline

Joined: Tue Aug 31, 2010 6:16 pm
Posts: 10
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 4426 times ]


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


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


Top
 Profile  
Reply with quote  
PostPosted: Mon Sep 20, 2010 8:20 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
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.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Wed Oct 06, 2010 8:54 pm 
Offline

Joined: Tue Aug 31, 2010 6:16 pm
Posts: 10
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


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 48 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group