PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Sep 06, 2024 11:22 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Thu Jan 02, 2014 10:59 pm 
Offline

Joined: Tue Nov 06, 2012 10:43 pm
Posts: 7
Dears,
I am using PDFSharp, but I cannot find which version, it is from mid-2012. Here is the problem,
When MeasureString is called (XGraphics.MeasureString(String text, XFont font, XStringFormat stringFormat)),
if the text is a string of blanks, the XSize.FromSizeF(SizeF size) throws a WidthAndHeightCannotBeNegative exception. The width is coming as a very small negative number, like -0.00001....
IT works fine if the text is an empty string.
Any clue?.
Thanks


Top
 Profile  
Reply with quote  
PostPosted: Fri Jan 03, 2014 3:34 pm 
Offline
PDFsharp Expert
User avatar

Joined: Wed Dec 09, 2009 8:59 am
Posts: 344
Hi!

GDI+ build or WPF build?

Will be investigated after the holidays.

_________________
Öhmesh Volta ("() => true")
PDFsharp Team Holiday Substitute


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 06, 2014 10:11 pm 
Offline

Joined: Tue Nov 06, 2012 10:43 pm
Posts: 7
Thanks Dear,
It is GDI+ build


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 13, 2014 4:36 pm 
Offline
PDFsharp Guru
User avatar

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

Cannot replicate.

My test code:
Code:
// Create a font
XFont font = new XFont("Times New Roman", 20, XFontStyle.BoldItalic);

// Draw the text
gfx.DrawString("Hello, World!", font, XBrushes.Black,
  new XRect(0, 0, page.Width, page.Height),
  XStringFormats.Center);

ue
  {
      var res = gfx.MeasureString(" ", font);
      res = gfx.MeasureString("  ", font);
      res = gfx.MeasureString("   ", font);
      res = gfx.MeasureString("    ", font);
      res = gfx.MeasureString("     ", font);
      res = gfx.MeasureString("      ", font);
      res = gfx.MeasureString("       ", font);
      res = gfx.MeasureString("        ", font);
  }


Width was always 0, no exception was thrown.

We need a sample (maybe an SSCCE) to replicate the issue.

See also:
viewtopic.php?p=2094#p2094

_________________
Regards
Thomas Hoevel
PDFsharp Team


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

All times are UTC


Who is online

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