Drawing Text

Adding text to PDF for Silverlight documents is easy – all the work is done by the C1PdfDocument.DrawString method.

C1PdfDocument.DrawString draws a given string at a specified location using a given font and brush. For example:

      Visual Basic

      C#

By default, C1PdfDocument.DrawString will align the text to the left and to the top of the given rectangle, will wrap the string within the rectangle, and will not clip the output to the rectangle. You can change all these options by specifying a StringFormat parameter in the call to C1PdfDocument.DrawString. The StringFormat has members that allow you to specify the horizontal alignment (Alignment), vertical alignment (LineAligmnent), and flags that control wrapping and clipping (FormatFlags).

For example, the code below creates a StringFormat object and uses it to align the text to the center of the rectangle, both vertically and horizontally:

      Visual Basic

      C#

Here is the resulting PDF document:


Send us comments about this topic.
Copyright © GrapeCity, inc. All rights reserved.