Skip to main content
A newer version of this page is available. .

Drawing into Graphics Context

  • 3 minutes to read

The PdfGraphics class contains methods (GDI+ like) that allow you to draw different shapes, lines, and images into a PDF graphics context.

Member Description
PdfGraphics.DrawLine Draws a line connecting two points on the page specified by the coordinate pairs.
PdfGraphics.DrawLines Draws a series of line segments that connect an array of PointF structures.
PdfGraphics.DrawBezier Draws a Bezier spline defined by four Point structures.
PdfGraphics.DrawBeziers Draws a series of Bezier splines from an array of PointF structures.
PdfGraphics.DrawEllipse Draws an ellipse specified by a RectangleF structure.
PdfGraphics.DrawRectangle Draws a rectangle specified by a Rectangle structure.
PdfGraphics.DrawPolygon Draws a polygon defined by an array of PointF structures.
PdfGraphics.DrawPath Draws a path on a page.
PdfGraphics.DrawString A set of overloaded methods used to draw the text string with the specified SolidBrush, Font objects and other parameters.
PdfGraphics.DrawImage Draws the specified Image using the byte array data at the specified location.
PdfGraphics.FillRectangle Fills the interior of a rectangle specified by a RectangleF structure.
PdfGraphics.FillPath Fills the interior of a GraphicsPath.
PdfGraphics.FillEllipse Fills the interior of an ellipse defined by a bounding rectangle specified by a RectangleF structure.
PdfGraphics.FillPolygon Fills the interior of a polygon defined by an array of points specified by PointF structures.
PdfGraphics.RotateTransform Rotates the coordinate system clockwise relative to its origin to the specified angle.
PdfGraphics.ScaleTransform Scales the coordinate system according to the specified scale factor.
PdfGraphics.TranslateTransform Translates the origin of the coordinate system to the specified point.

Example

This example shows how to draw text lines on a page using the PdfGraphics.DrawString method.


static void DrawGraphics(PdfGraphics graphics) { 

    SolidBrush black = (SolidBrush)Brushes.Black; 
    using (Font font1 = new Font("Times New Roman", 32, FontStyle.Bold)) { 
                graphics.DrawString("PDF Document Processor", font1, black, 180, 150); 
    } 
    using (Font font2 = new Font("Arial", 20)) { 
                graphics.DrawString("Display, Print and Export PDF Documents", font2, black, 168, 230); 
    } 
    using (Font font3 = new Font("Arial", 10)) { 
                graphics.DrawString("The PDF Document Processor is a non-visual component " + 
                                  "that provides the application programming interface of the PDF Viewer.", font3, black, 16, 300); 
    } 
}