PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 8:43 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Measure an image
PostPosted: Thu Nov 29, 2018 5:21 am 
Offline

Joined: Wed Nov 21, 2018 5:48 pm
Posts: 13
Is there a way I can get the height of a paragraph containing text? The paragraph is added to a Section or a TextFrame. Or is the size not known until the document is rendered? I want to determine how much area is left so I can specify the size of an image so it fits on the page.

Speaking of the size of an image, when I add an image to a section or a frame and get an ImageObject back, is there a way I get the width and height of the image? The Width and Height attributes are not set at that point. I want to determine whether to adjust its width or height (only one) and have the image maintain its aspect ratio.


Top
 Profile  
Reply with quote  
 Post subject: Re: Measure an image
PostPosted: Thu Nov 29, 2018 7:49 am 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 909
Location: CCAA
The size of a paragraph is unknown until it is rendered.

I'm not absolutely sure, but it could be that you have to open images with PDFsharp's XImage class to determine their size.

There are no public samples yet, but it is possible to add an empty paragraph at the end of the contents. After rendering the page with MigraDoc you can determine the position of the paragraph on the page and then draw the image in the size you need, e.g. as large as the remaining space allows.

Every MigraDoc object has a Tag member that you can set to any object. This allows to identify a paragraph after rendering.

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


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

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 172 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