PDFsharp & MigraDoc Forum

PDFsharp - A .NET library for processing PDF & MigraDoc - Creating documents on the fly
It is currently Wed Nov 05, 2025 4:27 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules

Also see our new Tailored Support & Services site.



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Calculating text width
PostPosted: Wed Jun 06, 2012 3:20 pm 
Offline

Joined: Wed Jun 06, 2012 3:03 pm
Posts: 4
Hi,

I'm trying to calculate text width and determine number of columns the page can contain. I found XGraphics, which has method MeasureString() that return a XSize, but I'm not sure what the unit of that is and how that turns into Unit:

Code:
XGraphics graphics = XGraphics.CreateMeasureContext(new XSize(8.5, 11), XGraphicsUnit.Inch, XPageDirection.Downwards);
Document document = new Document();
Section section = this.Document.AddSection();
Table table = section.AddTable();

string text = "some column text";
XSize size = Graphics.MeasureString(text, new XFont("Arial", 1.2));
Column column = table.AddColumn(/* size to unit here*/);


Top
 Profile  
Reply with quote  
PostPosted: Wed Jun 06, 2012 3:44 pm 
Offline

Joined: Wed Jun 06, 2012 3:03 pm
Posts: 4
Hmm...I think TextMeasurement is what I should use instead here, so nvm :D


Top
 Profile  
Reply with quote  
PostPosted: Wed Jun 06, 2012 4:07 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3136
Location: Cologne, Germany
Hi!

XSize contains the Width and the Height (both values use the unit Point).

_________________
Regards
Thomas Hoevel
PDFsharp Team


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