PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun Apr 28, 2024 1:42 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 Oct 21, 2010 7:40 pm 
Offline

Joined: Thu Oct 21, 2010 7:37 pm
Posts: 5
Is there a method similar to .MeasureString that returns the width? I need to position a second font element based on on how long the first.


Top
 Profile  
Reply with quote  
PostPosted: Fri Oct 22, 2010 8:33 am 
Offline
Supporter

Joined: Fri May 15, 2009 3:28 pm
Posts: 96
Hi,

Yes there is. Its a method in the XGraphics class called MeasureString....

to get an XGraphics object you do XGraphics.FromPdfPage(yourPageHere), where your page here could be something like myPdfDocument.Pages[0] etc.

The XGraphics MeasureString() method basically works like the normal MeasureString, but yuu pass in the relevant font ( i presume its a XFont, but havnt checked - intellisense will tell you though... ) and the string you wish to measure, the function will then return a XRectangle or something like that, which you can get the width from.

Hope this helps

Mike


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 01, 2010 8:48 pm 
Offline

Joined: Thu Oct 21, 2010 7:37 pm
Posts: 5
Thanks! Worked like a champ!


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: No registered users and 380 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