Home : Annotations : Manipulating : TextAnnotation throws an exception in DrawString
Q10145 - FIX: TextAnnotation throws an exception in DrawString

It has been found that rendering a TextAnnotation can, at times, cause a System.ArgumentException when the Graphics.DrawString method is used.  This is not specific to DotAnnotate and appears to be a bug in the .NET Framework.

The exception will appear as follows:

System.ArgumentException: Parameter is not valid.
at System.Drawing.Graphics.CheckErrorStatus(Int32 status)
at System.Drawing.Graphics.DrawString(String s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format)
at Atalasoft.Imaging.Annotate.TextAnnotation.Paint(Graphics graphics, PointF offset, PointF zoom, Single resolution)

This seems to only happen when a brush from the static Brushes object is used.  For example:

TextAnnotation ann = new TextAnnotation("My Text", font, Brushes.Black, null, null);

This can be resolved by creating a new SolidBrush instead:

TextAnnotation ann = new TextAnnotation("My Text", font, new SolidBrush(Color.Black), null, null);

 

Related Articles
No Related Articles Available.

Article Attachments
No Attachments Available.

Related External Links
No Related Links Available.
Help us improve this article...
What did you think of this article?

poor 
1
2
3
4
5
6
7
8
9
10

 excellent
Tell us why you rated the content this way. (optional)
 
Approved Comments...
No user comments available for this article.

Powered By InstantKB.NET v1.3
Copyright © 2002, 2017. InstantASP Ltd. All Rights Reserved