PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 7:51 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: Wed Aug 15, 2018 12:29 pm 
Offline

Joined: Wed Aug 15, 2018 12:23 pm
Posts: 3
Using the

size = MeasureString(txt,font)

function I notice a trailing space is ignored.

Both
txt = "1234567890"
and
txt = "1234567890 "

give me the same value of size.width
Do I overlook something or is this know behavior?

Best regards,
Maarten


Top
 Profile  
Reply with quote  
PostPosted: Wed Aug 15, 2018 1:54 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
This is the known behavior. Trailing spaces have no impact on the output in PDF. Spaces in the middle of the string are measured as they have impact on the result.

Here's a trick that determines the width of a blank:
https://github.com/empira/PDFsharp/blob ... ter.cs#L81

Code:
_spaceWidth = _gfx.MeasureString("x x", value).Width;
_spaceWidth -= _gfx.MeasureString("xx", value).Width;

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Thu Aug 16, 2018 11:37 am 
Offline

Joined: Wed Aug 15, 2018 12:23 pm
Posts: 3
Thanks for the quick responds.

I use the space width calculation routine as mentioned.


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: Google [Bot] and 144 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