Adding Graphics

The C1PdfDocument class exposes several methods that allow you to add graphical elements to your documents, including lines, rectangles, ellipses, pies, arcs, rounded rectangles, polygons, Bezier curves, and so on.

The methods are a subset of those found in the .NET Graphics class, and use the same Brush and Pen classes to control the color and style of the lines and filled areas.

It is important to remember that PDF for Silverlight uses a coordinate system based on points, with the origin located at the top left of the page. (The default coordinate system for the .NET Graphics class is pixel-based.)

The example below illustrates how similar the graphics methods are between PDF for Silverlight and the .NET Graphics class. The sample declares a C1PdfDocument class called 'g' and calls methods to draw pies, splines, and other graphical elements.

The point of the sample is that if you replaced the C1PdfDocument class with a regular .NET Graphics object, you would be able to compile the code and get the same results:

      Visual Basic

      C#

Here is the resulting PDF document:

 


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