Table of Contents

Class PdfGraphics

Namespace
Syncfusion.Pdf.Graphics
Assembly
Syncfusion.Pdf.Portable.dll

Represents a graphics context of the objects. It's used for performing all the graphics operations.

public sealed class PdfGraphics
Inheritance
PdfGraphics
Inherited Members

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Draw string to PDF page graphics.
graphics.DrawString("Hello World!", font, PdfBrushes.Black, PointF.Empty);
//Draw the rectangle to PDF page graphics.
graphics.DrawRectangle(PdfPens.Red, new RectangleF(0, 20, 200, 100));
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Draw string to PDF page graphics.
graphics.DrawString("Hello World!", font, PdfBrushes.Black, PointF.Empty)
'Draw the rectangle to PDF page graphics.
graphics.DrawRectangle(PdfPens.Red, New RectangleF(0, 20, 200, 100))
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)

Properties

ClientSize

Gets the size of the canvas reduced by margins and page templates.

public SizeF ClientSize { get; }

Property Value

SizeF

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Get the graphics client size.
SizeF clientSize = graphics.ClientSize;
//Draw rectangle to PDF graphics.
graphics.DrawRectangle(PdfBrushes.Red, new RectangleF(PointF.Empty, clientSize));
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Get the graphics client size.
Dim clientSize As SizeF = graphics.ClientSize
'Draw rectangle to PDF graphics.
graphics.DrawRectangle(PdfBrushes.Red, New RectangleF(PointF.Empty, clientSize))
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)

Remarks

It indicates a size of the canvas reduced by margins and template dimensions. This value doesn't change when any custom clip is set.

ColorSpace

Gets or sets the current color space of the document

public PdfColorSpace ColorSpace { get; set; }

Property Value

PdfColorSpace

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Set the color space.
graphics.ColorSpace = PdfColorSpace.GrayScale;
//Get the graphics client size.
SizeF clientSize = graphics.ClientSize;
//Draw rectangle to PDF graphics.
graphics.DrawRectangle(PdfBrushes.Red, new RectangleF(PointF.Empty, clientSize));
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Set the color space.
graphics.ColorSpace = PdfColorSpace.GrayScale
'Get the graphics client size.
Dim clientSize As SizeF = graphics.ClientSize
'Draw rectangle to PDF graphics.
graphics.DrawRectangle(PdfBrushes.Red, New RectangleF(PointF.Empty, clientSize))
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)

Remarks

The value change of this property has impact on the objects which will be drawn after the change.

Size

Gets the size of the canvas.

public SizeF Size { get; }

Property Value

SizeF

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Get the graphics canvas size.
SizeF canvasSize = graphics.Size;
//Draw string to PDF page graphics.
graphics.DrawString("Canvas size: " + canvasSize.ToString(), font, PdfBrushes.Black, PointF.Empty);
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Get the graphics canvas size.
Dim canvasSize As SizeF = graphics.Size
'Draw string to PDF page graphics.
graphics.DrawString("Canvas size: " + canvasSize.ToString(), font, PdfBrushes.Black, PointF.Empty)
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)

Remarks

Usually, this value is equal to the size of the object this graphics belongs to.

Methods

DrawArc(PdfPen, RectangleF, float, float)

Draws an arc representing a portion of an ellipse specified by a Rectangle structure.

public void DrawArc(PdfPen pen, RectangleF rectangle, float startAngle, float sweepAngle)

Parameters

pen PdfPen

Pen that determines the color, width, and style of the arc.

rectangle RectangleF

RectangleF structure that defines the boundaries of the ellipse.

startAngle float

Angle in degrees measured clockwise from the x-axis to the starting point of the arc.

sweepAngle float

Angle in degrees measured clockwise from the startAngle parameter to ending point of the arc.

Examples

// Creates a document.
PdfDocument doc = new PdfDocument();
//Adds a new page.
PdfPage page = doc.Pages.Add();
//Draw Arc
page.Graphics.DrawArc(PdfPens.Red, new RectangleF(10, 10, 100, 200), 90, 270);
//Save document
doc.Save("Arc.pdf");
//Closes the document.
doc.Close(true);
'Creates a document.
Dim doc As New PdfDocument()
'Adds a new page.
Dim page As PdfPage = doc.Pages.Add()
'Draw Arc
page.Graphics.DrawArc(PdfPens.Red, New RectangleF(10, 10, 100, 200), 90, 270)
'Saves the PDF.
doc.Save("Arc.pdf")
'Closes the document.
doc.Close()

DrawArc(PdfPen, float, float, float, float, float, float)

Draws an arc representing a portion of an ellipse specified by a pair of coordinates, a width, and a height.

public void DrawArc(PdfPen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)

Parameters

pen PdfPen

Pen that determines the color, width, and style of the arc.

x float

The x-coordinate of the upper-left corner of the rectangle that defines the ellipse.

y float

The y-coordinate of the upper-left corner of the rectangle that defines the ellipse.

width float

Width of the rectangle that defines the ellipse.

height float

Height of the rectangle that defines the ellipse.

startAngle float

Angle in degrees measured clockwise from the x-axis to the starting point of the arc.

sweepAngle float

Angle in degrees measured clockwise from the startAngle parameter to ending point of the arc.

Examples

// Creates a document.
PdfDocument doc = new PdfDocument();
//Adds a new page.
PdfPage page = doc.Pages.Add();
//Draw Arc
page.Graphics.DrawArc(PdfPens.Red, 10, 10, 100, 200, 90, 270);
//Save document
doc.Save("Arc.pdf");
//Closes the document.
doc.Close(true);
'Creates a document.
Dim doc As New PdfDocument()
'Adds a new page.
Dim page As PdfPage = doc.Pages.Add()
'Draw Arc
page.Graphics.DrawArc(PdfPens.Red, 10, 10, 100, 200, 90, 270)
'Saves the PDF.
doc.Save("Arc.pdf")
'Closes the document.
doc.Close()

DrawBezier(PdfPen, PointF, PointF, PointF, PointF)

Draws a Bezier spline defined by four Point structures.

public void DrawBezier(PdfPen pen, PointF startPoint, PointF firstControlPoint, PointF secondControlPoint, PointF endPoint)

Parameters

pen PdfPen

Pen structure that determines the color, width, and style of the curve.

startPoint PointF

Point structure that represents the starting point of the curve.

firstControlPoint PointF

Point structure that represents the first control point for the curve.

secondControlPoint PointF

Point structure that represents the second control point for the curve.

endPoint PointF

Point structure that represents the ending point of the curve.

Examples

// Creates a document.
PdfDocument doc = new PdfDocument();
//Adds a new page.
PdfPage page = doc.Pages.Add();
//Adds pen.  
PdfPen pen = new PdfPen(PdfBrushes.Brown, 1f);
//Draw Bezier
page.Graphics.DrawBezier(pen, new PointF(10, 10), new PointF(10, 50), new PointF(50, 80), new PointF(80, 10));
//Save document
doc.Save("Bezier.pdf");
//Closes the document.
doc.Close(true);
'Creates a document.
Dim doc As New PdfDocument()
'Adds a new page.
Dim page As PdfPage = doc.Pages.Add()
'Adds pen.
Dim pen As New PdfPen(PdfBrushes.Brown, 1.0F)
'Draw Bezier
page.Graphics.DrawBezier(pen, New PointF(10, 10), New PointF(10, 50), New PointF(50, 80), New PointF(80, 10));
'Saves the PDF.
doc.Save("Bezier.pdf")
'Closes the document.
doc.Close()

DrawBezier(PdfPen, float, float, float, float, float, float, float, float)

Draws a Bezier spline defined by four ordered pairs of coordinates that represent points.

public void DrawBezier(PdfPen pen, float startPointX, float startPointY, float firstControlPointX, float firstControlPointY, float secondControlPointX, float secondControlPointY, float endPointX, float endPointY)

Parameters

pen PdfPen

Pen structure that determines the color, width, and style of the curve.

startPointX float

The x-coordinate of the starting point of the curve.

startPointY float

The y-coordinate of the starting point of the curve.

firstControlPointX float

The x-coordinate of the first control point of the curve.

firstControlPointY float

The y-coordinate of the first control point of the curve.

secondControlPointX float

The x-coordinate of the second control point of the curve.

secondControlPointY float

The y-coordinate of the second control point of the curve.

endPointX float

The x-coordinate of the ending point of the curve.

endPointY float

The y-coordinate of the ending point of the curve.

Examples

// Creates a document.
PdfDocument doc = new PdfDocument();
//Adds a new page.
PdfPage page = doc.Pages.Add();
//Adds pen.  
PdfPen pen = new PdfPen(PdfBrushes.Brown, 1f);
//Draw Bezier
page.Graphics.DrawBezier(pen, 10, 10, 10, 50, 50, 80, 80, 10);
//Save document
doc.Save("Bezier.pdf");
//Closes the document.
doc.Close(true);
'Creates a document.
Dim doc As New PdfDocument()
'Adds a new page.
Dim page As PdfPage = doc.Pages.Add()
'Adds pen.
Dim pen As New PdfPen(PdfBrushes.Brown, 1.0F)
'Draw Bezier
page.Graphics.DrawBezier(pen, 10, 10, 10, 50, 50, 80, 80, 10);
'Saves the PDF.
doc.Save("Bezier.pdf")
'Closes the document.
doc.Close()

DrawEllipse(PdfBrush, RectangleF)

Draws an ellipse specified by a brush, a bounding Rectangle structure.

public void DrawEllipse(PdfBrush brush, RectangleF rectangle)

Parameters

brush PdfBrush

Brush that determines the color and texture of the ellipse.

rectangle RectangleF

RectangleF structure that defines the boundaries of the ellipse.

Examples

// Creates a document.
PdfDocument doc = new PdfDocument();
//Adds a new page.
PdfPage page = doc.Pages.Add();
//Adds Brush.  
 PdfBrush brush = new PdfSolidBrush (Color.Red);
//Draw Ellipse
page.Graphics.DrawEllipse(brush, new RectangleF(10, 10, 100, 100));
//Save document
doc.Save("Ellipse.pdf");
//Closes the document.
doc.Close(true);
'Creates a document.
Dim doc As New PdfDocument()
'Adds a new page.
Dim page As PdfPage = doc.Pages.Add()
'Adds Brush.
Dim brush As New PdfSolidBrush (Color.Red)
'Draw Ellipse
page.Graphics.DrawEllipse(brush, New RectangleF(10, 10, 100, 100))
'Saves the PDF.
doc.Save("Ellipse.pdf")
'Closes the document.
doc.Close()

DrawEllipse(PdfBrush, float, float, float, float)

Draws an ellipse defined by a bounding rectangle specified by coordinates for the upper-left corner of the rectangle, a height, and a width.

public void DrawEllipse(PdfBrush brush, float x, float y, float width, float height)

Parameters

brush PdfBrush

Brush that determines the color and texture of the ellipse.

x float

The x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.

y float

The y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.

width float

Width of the bounding rectangle that defines the ellipse.

height float

Height of the bounding rectangle that defines the ellipse.

Examples

// Creates a document.
PdfDocument doc = new PdfDocument();
//Adds a new page.
PdfPage page = doc.Pages.Add();
//Adds Brush.  
 PdfBrush brush = new PdfSolidBrush (Color.Red);
//Draw Ellipse
page.Graphics.DrawEllipse(brush, 10, 10, 100, 100);
//Save document
doc.Save("Ellipse.pdf");
//Closes the document.
doc.Close(true);
'Creates a document.
Dim doc As New PdfDocument()
'Adds a new page.
Dim page As PdfPage = doc.Pages.Add()
'Adds Brush.
Dim brush As New PdfSolidBrush (Color.Red)
'Draw Ellipse
page.Graphics.DrawEllipse(brush, 10, 10, 100, 100)
'Saves the PDF.
doc.Save("Ellipse.pdf")
'Closes the document.
doc.Close()

DrawEllipse(PdfPen, RectangleF)

Draws an ellipse specified by a pen, a bounding Rectangle structure.

public void DrawEllipse(PdfPen pen, RectangleF rectangle)

Parameters

pen PdfPen

Pen that determines the color, width, and style of the ellipse.

rectangle RectangleF

RectangleF structure that defines the boundaries of the ellipse.

Examples

// Creates a document.
PdfDocument doc = new PdfDocument();
//Adds a new page.
PdfPage page = doc.Pages.Add();        
//Draw Ellipse
page.Graphics.DrawEllipse(PdfPens.Red, new RectangleF(10, 10, 100, 100));
//Save document
doc.Save("Ellipse.pdf");
//Closes the document.
doc.Close(true);
'Creates a document.
Dim doc As New PdfDocument()
'Adds a new page.
Dim page As PdfPage = doc.Pages.Add()       
'Draw Ellipse
page.Graphics.DrawEllipse(PdfPens.Red, New RectangleF(10, 10, 100, 100))
'Saves the PDF.
doc.Save("Ellipse.pdf")
'Closes the document.
doc.Close()

DrawEllipse(PdfPen, PdfBrush, RectangleF)

Draws an ellipse specified by a bounding Rectangle structure.

public void DrawEllipse(PdfPen pen, PdfBrush brush, RectangleF rectangle)

Parameters

pen PdfPen

Pen that determines the color, width, and style of the ellipse.

brush PdfBrush

Brush that determines the color and texture of the ellipse.

rectangle RectangleF

RectangleF structure that defines the boundaries of the ellipse.

Examples

// Creates a document.
PdfDocument doc = new PdfDocument();
//Adds a new page.
PdfPage page = doc.Pages.Add();
//Adds Brush.  
 PdfBrush brush = new PdfSolidBrush (Color.Red);
//Draw Ellipse
page.Graphics.DrawEllipse(PdfPens.Black, brush, new RectangleF(10, 10, 100, 100));
//Save document
doc.Save("Ellipse.pdf");
//Closes the document.
doc.Close(true);
'Creates a document.
Dim doc As New PdfDocument()
'Adds a new page.
Dim page As PdfPage = doc.Pages.Add()
'Adds Brush.
Dim brush As New PdfSolidBrush (Color.Red)
'Draw Ellipse
page.Graphics.DrawEllipse(PdfPens.Black, brush, New RectangleF(10, 10, 100, 100))
'Saves the PDF.
doc.Save("Ellipse.pdf")
'Closes the document.
doc.Close()

DrawEllipse(PdfPen, PdfBrush, float, float, float, float)

Draws an ellipse specified by a pen, a brush and coordinates for the upper-left corner of the rectangle, a height, and a width.

public void DrawEllipse(PdfPen pen, PdfBrush brush, float x, float y, float width, float height)

Parameters

pen PdfPen

Pen that determines the color, width, and style of the ellipse.

brush PdfBrush

Brush that determines the color and texture of the ellipse.

x float

The x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.

y float

The y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.

width float

Width of the bounding rectangle that defines the ellipse.

height float

Height of the bounding rectangle that defines the ellipse.

Examples

// Creates a document.
PdfDocument doc = new PdfDocument();
//Adds a new page.
PdfPage page = doc.Pages.Add();
//Adds Brush.  
 PdfBrush brush = new PdfSolidBrush (Color.Red);
//Draw Ellipse
page.Graphics.DrawEllipse(PdfPens.Black, brush, 10, 10, 100, 100);
//Save document
doc.Save("Ellipse.pdf");
//Closes the document.
doc.Close(true);
'Creates a document.
Dim doc As New PdfDocument()
'Adds a new page.
Dim page As PdfPage = doc.Pages.Add()
'Adds Brush.
Dim brush As New PdfSolidBrush (Color.Red)
'Draw Ellipse
page.Graphics.DrawEllipse(PdfPens.Black, brush, 10, 10, 100, 100)
'Saves the PDF.
doc.Save("Ellipse.pdf")
'Closes the document.
doc.Close()

DrawEllipse(PdfPen, float, float, float, float)

Draws an ellipse defined by a bounding rectangle specified by coordinates for the upper-left corner of the rectangle, a height, and a width.

public void DrawEllipse(PdfPen pen, float x, float y, float width, float height)

Parameters

pen PdfPen

Pen that determines the color, width, and style of the ellipse.

x float

The x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.

y float

The y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.

width float

Width of the bounding rectangle that defines the ellipse.

height float

Height of the bounding rectangle that defines the ellipse.

Examples

// Creates a document.
PdfDocument doc = new PdfDocument();
//Adds a new page.
PdfPage page = doc.Pages.Add();        
//Draw Ellipse
page.Graphics.DrawEllipse(PdfPens.Red, 10, 10, 100, 100);
//Save document
doc.Save("Ellipse.pdf");
//Closes the document.
doc.Close(true);
'Creates a document.
Dim doc As New PdfDocument()
'Adds a new page.
Dim page As PdfPage = doc.Pages.Add()       
'Draw Ellipse
page.Graphics.DrawEllipse(PdfPens.Red, 10, 10, 100, 100)
'Saves the PDF.
doc.Save("Ellipse.pdf")
'Closes the document.
doc.Close()

DrawImage(PdfImage, PointF)

Draws the specified PdfImage, using its original physical size, at the specified location..

public void DrawImage(PdfImage image, PointF point)

Parameters

image PdfImage

PdfImage to draw.

point PointF

Point structure that represents the location of the upper-left corner of the drawn image.

Examples

//Creates a new PDF document.
PdfDocument doc = new PdfDocument();
//Adds a page to the document.
PdfPage page = doc.Pages.Add();
//Creates PDF graphics for the page.
PdfGraphics g = page.Graphics;
//Creates an image object.
PdfBitmap image = new PdfBitmap("Autumn Leaves.jpg");
//Draws the image.
g.DrawImage(image, new PointF(0, 0));
//Saves the document.
doc.Save("Output.pdf");
//Closes the document.
doc.Close(true);
'Creates a new PDF document.
Dim doc As New PdfDocument()
'Adds a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Creates PDF graphics for the page.
Dim g As PdfGraphics = page.Graphics
'Creates an image object.
Dim image As New PdfBitmap("Autumn Leaves.jpg")
'Draws the image.
g.DrawImage(image,New PointF(0, 0))
'Saves the document.
doc.Save("Output.pdf")
'Closes the document.
doc.Close()

DrawImage(PdfImage, PointF, SizeF)

Draws the specified Image at the specified location and with the specified shape and size.

public void DrawImage(PdfImage image, PointF point, SizeF size)

Parameters

image PdfImage

PdfImage to draw.

point PointF

Point structure that represents the location of the upper-left corner of the drawn image.

size SizeF

SizeF structure that represents the height and width of the drawn image.

Examples

//Creates a new PDF document.
PdfDocument doc = new PdfDocument();
//Adds a page to the document.
PdfPage page = doc.Pages.Add();
//Creates PDF graphics for the page.
PdfGraphics g = page.Graphics;
//Creates an image object.
PdfBitmap image = new PdfBitmap("Autumn Leaves.jpg");
//Draws the image.
g.DrawImage(image, new PointF(0, 0), new SizeF(300, 200));
//Saves the document.
doc.Save("Output.pdf");
//Closes the document.
doc.Close(true);
'Creates a new PDF document.
Dim doc As New PdfDocument()
'Adds a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Creates PDF graphics for the page.
Dim g As PdfGraphics = page.Graphics
'Creates an image object.
Dim image As New PdfBitmap("Autumn Leaves.jpg")
'Draws the image.
g.DrawImage(image,New PointF(0, 0), New SizeF(300, 200))
'Saves the document.
doc.Save("Output.pdf")
'Closes the document.
doc.Close()

DrawImage(PdfImage, RectangleF)

Draws the specified Image at the specified location and with the specified size.

public void DrawImage(PdfImage image, RectangleF rectangle)

Parameters

image PdfImage

PdfImage to draw.

rectangle RectangleF

RectangleF structure that specifies the location and size of the drawn image.

Examples

//Creates a new PDF document.
PdfDocument doc = new PdfDocument();
//Adds a page to the document.
PdfPage page = doc.Pages.Add();
//Creates PDF graphics for the page.
PdfGraphics g = page.Graphics;
//Creates an image object.
PdfBitmap image = new PdfBitmap("Autumn Leaves.jpg");
//Draws the image.
g.DrawImage(image, new RectangleF(0, 0, 300, 200));
//Saves the document.
doc.Save("Output.pdf");
//Closes the document.
doc.Close(true);
'Creates a new PDF document.
Dim doc As New PdfDocument()
'Adds a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Creates PDF graphics for the page.
Dim g As PdfGraphics = page.Graphics
'Creates an image object.
Dim image As New PdfBitmap("Autumn Leaves.jpg")
'Draws the image.
g.DrawImage(image,New RectangleF(0, 0, 300, 200))
'Saves the document.
doc.Save("Output.pdf")
'Closes the document.
doc.Close()

DrawImage(PdfImage, float, float)

Draws the specified image, using its original physical size, at the location specified by a coordinate pair.

public void DrawImage(PdfImage image, float x, float y)

Parameters

image PdfImage

PdfImage to draw.

x float

The x-coordinate of the upper-left corner of the drawn image.

y float

The y-coordinate of the upper-left corner of the drawn image.

Examples

//Creates a new PDF document.
PdfDocument doc = new PdfDocument();
//Adds a page to the document.
PdfPage page = doc.Pages.Add();
//Creates PDF graphics for the page.
PdfGraphics g = page.Graphics;
//Creates an image object.
PdfBitmap image = new PdfBitmap("Autumn Leaves.jpg");
//Draws the image.
g.DrawImage(image, 0, 0);
//Saves the document.
doc.Save("Output.pdf");
//Closes the document.
doc.Close(true);
'Creates a new PDF document.
Dim doc As New PdfDocument()
'Adds a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Creates PDF graphics for the page.
Dim g As PdfGraphics = page.Graphics
'Creates an image object.
Dim image As New PdfBitmap("Autumn Leaves.jpg")
'Draws the image.
g.DrawImage(image, 0, 0)
'Saves the document.
doc.Save("Output.pdf")
'Closes the document.
doc.Close()

DrawImage(PdfImage, float, float, float, float)

Draws the specified image, using its original physical size, at the location specified by a coordinate pair.

public void DrawImage(PdfImage image, float x, float y, float width, float height)

Parameters

image PdfImage

PdfImage to draw.

x float

The x-coordinate of the upper-left corner of the drawn image.

y float

The y-coordinate of the upper-left corner of the drawn image.

width float

Width of the drawn image.

height float

Height of the drawn image.

Examples

//Creates a new PDF document.
PdfDocument doc = new PdfDocument();
//Adds a page to the document.
PdfPage page = doc.Pages.Add();
//Creates PDF graphics for the page.
PdfGraphics g = page.Graphics;
//Creates an image object.
PdfBitmap image = new PdfBitmap("Autumn Leaves.jpg");
//Draws the image.
g.DrawImage(image, 0, 0, 300, 200);
//Saves the document.
doc.Save("Output.pdf");
//Closes the document.
doc.Close(true);
'Creates a new PDF document.
Dim doc As New PdfDocument()
'Adds a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Creates PDF graphics for the page.
Dim g As PdfGraphics = page.Graphics
'Creates an image object.
Dim image As New PdfBitmap("Autumn Leaves.jpg")
'Draws the image.
g.DrawImage(image, 0, 0, 300, 200)
'Saves the document.
doc.Save("Output.pdf")
'Closes the document.
doc.Close()

DrawLine(PdfPen, PointF, PointF)

Draws a line connecting two Syncfusion.Drawing.PointF structures.

public void DrawLine(PdfPen pen, PointF point1, PointF point2)

Parameters

pen PdfPen

Pen that determines the color, width, and style of the line.

point1 PointF

PointF structure that represents the first point to connect.

point2 PointF

PointF structure that represents the second point to connect.

Examples

// Creates a document.
PdfDocument doc = new PdfDocument();
//Adds a new page.
PdfPage page = doc.Pages.Add();
//Adds pen.  
PdfPen pen = new PdfPen(PdfBrushes.Brown, 1f);
//Draw line
page.Graphics.DrawLine(pen, new PointF(100, 100), new PointF(200, 100));
//Save document
doc.Save("Line.pdf");
//Close the document.
doc.Close(true);
'Creates a document.
Dim doc As New PdfDocument()
'Adds a new page.
Dim page As PdfPage = doc.Pages.Add()
'Adds pen.
Dim pen As New PdfPen(PdfBrushes.Brown, 1.0F)
'Draw line
page.Graphics.DrawLine(pen, New PointF(100, 100), New PointF(200, 100))
'Saves the PDF.
doc.Save("Line.pdf")
'Closes the document.
doc.Close()

DrawLine(PdfPen, float, float, float, float)

Draws a line connecting the two points specified by the coordinate pairs.

public void DrawLine(PdfPen pen, float x1, float y1, float x2, float y2)

Parameters

pen PdfPen

Pen that determines the color, width, and style of the line.

x1 float

The x-coordinate of the first point.

y1 float

The y-coordinate of the first point.

x2 float

The x-coordinate of the second point.

y2 float

The y-coordinate of the second point.

Examples

// Creates a document.
PdfDocument doc = new PdfDocument();
//Adds a new page.
PdfPage page = doc.Pages.Add();
//Adds pen.  
PdfPen pen = new PdfPen(PdfBrushes.Brown, 1f);
//Draw line
page.Graphics.DrawLine(pen, 100, 100, 200, 100);
//Save document
doc.Save("Line.pdf");
//Close the document.
doc.Close(true);
'Creates a document.
Dim doc As New PdfDocument()
'Adds a new page.
Dim page As PdfPage = doc.Pages.Add()
'Adds pen.
Dim pen As New PdfPen(PdfBrushes.Brown, 1.0F)
'Draw line
page.Graphics.DrawLine(pen, 100, 100, 200, 100)
'Saves the PDF.
doc.Save("Line.pdf")
'Closes the document.
doc.Close()

DrawPath(PdfBrush, PdfPath)

Draws a GraphicsPath defined by a brush and path

public void DrawPath(PdfBrush brush, PdfPath path)

Parameters

brush PdfBrush

Brush that determines the color and texture of the path.

path PdfPath

GraphicsPath to draw.

Examples

// Creates a document.
PdfDocument doc = new PdfDocument();
//Adds a new page.
PdfPage page = doc.Pages.Add();
//Adds Path.  
PdfPath path = new PdfPath();
path.AddRectangle (new RectangleF (10,10,100,100));
path.AddEllipse (new RectangleF (100,100,100,100));
//Draw Paths
page.Graphics.DrawPath(PdfBrushes.Red, path);
//Save document
doc.Save("Paths.pdf");
//Closes the document.
doc.Close(true);
'Creates a document.
Dim doc As New PdfDocument()
'Adds a new page.
Dim page As PdfPage = doc.Pages.Add()
'Adds Path.  
Dim path  As New PdfPath();
path.AddRectangle (New RectangleF (10,10,100,100));
path.AddEllipse (New RectangleF (100,100,100,100));
'Draw Path
page.Graphics.DrawPath(PdfBrushes.Red, path)
'Saves the PDF.
doc.Save("Paths.pdf")
'Closes the document.
doc.Close()

DrawPath(PdfPen, PdfBrush, PdfPath)

Draws a GraphicsPath defined by a pen, a brush and path

public void DrawPath(PdfPen pen, PdfBrush brush, PdfPath path)

Parameters

pen PdfPen

Pen that determines the color, width, and style of the path.

brush PdfBrush

Brush that determines the color and texture of the path.

path PdfPath

GraphicsPath to draw.

Examples

// Creates a document.
PdfDocument doc = new PdfDocument();
//Adds a new page.
PdfPage page = doc.Pages.Add();
//Adds Path.  
PdfPath path = new PdfPath();
path.AddRectangle (new RectangleF (10,10,100,100));
path.AddEllipse (new RectangleF (100,100,100,100));
//Draw Paths
page.Graphics.DrawPath(PdfPens.Black, PdfBrushes.Red, path);
//Save document
doc.Save("Paths.pdf");
//Closes the document.
doc.Close(true);
'Creates a document.
Dim doc As New PdfDocument()
'Adds a new page.
Dim page As PdfPage = doc.Pages.Add()
'Adds Path.  
Dim path  As New PdfPath();
path.AddRectangle (New RectangleF (10,10,100,100));
path.AddEllipse (New RectangleF (100,100,100,100));
'Draw Path
page.Graphics.DrawPath(PdfPens.Black, PdfBrushes.Red, path)
'Saves the PDF.
doc.Save("Paths.pdf")
'Closes the document.
doc.Close()

DrawPath(PdfPen, PdfPath)

Draws a GraphicsPath defined by a pen and path

public void DrawPath(PdfPen pen, PdfPath path)

Parameters

pen PdfPen

Pen that determines the color, width, and style of the path.

path PdfPath

GraphicsPath to draw.

Examples

// Creates a document.
PdfDocument doc = new PdfDocument();
//Adds a new page.
PdfPage page = doc.Pages.Add();
//Adds Path.  
PdfPath path = new PdfPath();
path.AddRectangle (new RectangleF (10,10,100,100));
path.AddEllipse (new RectangleF (100,100,100,100));
//Draw Paths
page.Graphics.DrawPath(PdfPens.Red, path);
//Save document
doc.Save("Paths.pdf");
//Closes the document.
doc.Close(true);
'Creates a document.
Dim doc As New PdfDocument()
'Adds a new page.
Dim page As PdfPage = doc.Pages.Add()
'Adds Path.  
Dim path  As New PdfPath();
path.AddRectangle (New RectangleF (10,10,100,100));
path.AddEllipse (New RectangleF (100,100,100,100));
'Draw Path
page.Graphics.DrawPath(PdfPens.Red, path)
'Saves the PDF.
doc.Save("Paths.pdf")
'Closes the document.
doc.Close()

DrawPdfTemplate(PdfTemplate, PointF)

Draws a template using its original size, at the specified location.

public void DrawPdfTemplate(PdfTemplate template, PointF location)

Parameters

template PdfTemplate

PdfTemplate object.

location PointF

PointF structure that specifies the upper-left corner of the drawn template.

Examples

//Creates a new PDF document.
PdfDocument pdfDocument = new PdfDocument();
//Adds a page to the PDF document.
PdfPage pdfPage = pdfDocument.Pages.Add();
//Create a PDF Template.
PdfTemplate template = new PdfTemplate(100, 50);
//Draws a rectangle into the graphics of the template.
template.Graphics.DrawRectangle(PdfBrushes.BurlyWood, new System.Drawing.RectangleF(0, 0, 100, 50));
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 14);
PdfBrush brush = new PdfSolidBrush(Color.Black);
//Draws a string into the graphics of the template.
template.Graphics.DrawString("Hello World", font, brush, 5, 5);
//Draws the template into the page graphics of the document.
pdfPage.Graphics.DrawPdfTemplate(template, PointF.Empty);
//Saves the document.
pdfDocument.Save("Output.pdf");
//Close the document
pdfDocument.Close(true);
'Creates a new PDF document.
Dim pdfDocument As New PdfDocument()
'Adds a page to the PDF document
Dim pdfPage As PdfPage = pdfDocument.Pages.Add()
'Creates a PDF Template.
Dim template As New PdfTemplate(100, 50)
'Draws a rectangle into the graphics of the template.
template.Graphics.DrawRectangle(PdfBrushes.BurlyWood, New System.Drawing.RectangleF(0, 0, 100, 50))
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 14)
Dim brush As PdfBrush = New PdfSolidBrush(Color.Black)
'Draws a string into the graphics of the template.
template.Graphics.DrawString("Hello World", font, brush, 5, 5)
'Draws the template into the page graphics of the document.
pdfPage.Graphics.DrawPdfTemplate(template, PointF.Empty)
'Saves the document.
pdfDocument.Save("Output.pdf")
'Close the document
pdfDocument.Close(True)

DrawPdfTemplate(PdfTemplate, PointF, SizeF)

Draws a template at the specified location and size.

public void DrawPdfTemplate(PdfTemplate template, PointF location, SizeF size)

Parameters

template PdfTemplate

PdfTemplate object.

location PointF

PointF structure that specifies the upper-left corner of the drawn template.

size SizeF

Size of the template.

Examples

//Creates a new PDF document.
PdfDocument pdfDocument = new PdfDocument();
//Adds a page to the PDF document.
PdfPage pdfPage = pdfDocument.Pages.Add();
//Create a PDF Template.
PdfTemplate template = new PdfTemplate(100, 50);
//Draws a rectangle into the graphics of the template.
template.Graphics.DrawRectangle(PdfBrushes.BurlyWood, new System.Drawing.RectangleF(0, 0, 100, 50));
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 14);
PdfBrush brush = new PdfSolidBrush(Color.Black);
//Draws a string into the graphics of the template.
template.Graphics.DrawString("Hello World", font, brush, 5, 5);
//Draws the template into the page graphics of the document.
pdfPage.Graphics.DrawPdfTemplate(template, PointF.Empty, template.Size);
//Saves the document.
pdfDocument.Save("Output.pdf");
//Close the document
pdfDocument.Close(true);
'Creates a new PDF document.
Dim pdfDocument As New PdfDocument()
'Adds a page to the PDF document
Dim pdfPage As PdfPage = pdfDocument.Pages.Add()
'Creates a PDF Template.
Dim template As New PdfTemplate(100, 50)
'Draws a rectangle into the graphics of the template.
template.Graphics.DrawRectangle(PdfBrushes.BurlyWood, New System.Drawing.RectangleF(0, 0, 100, 50))
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 14)
Dim brush As PdfBrush = New PdfSolidBrush(Color.Black)
'Draws a string into the graphics of the template.
template.Graphics.DrawString("Hello World", font, brush, 5, 5)
'Draws the template into the page graphics of the document.
pdfPage.Graphics.DrawPdfTemplate(template, PointF.Empty, template.Size)
'Saves the document.
pdfDocument.Save("Output.pdf")
'Close the document
pdfDocument.Close(True)

DrawPie(PdfBrush, RectangleF, float, float)

Draws a pie shape defined by an ellipse specified by a Rectangle structure and two radial lines.

public void DrawPie(PdfBrush brush, RectangleF rectangle, float startAngle, float sweepAngle)

Parameters

brush PdfBrush

Brush that determines the color and texture of the pie.

rectangle RectangleF

Rectangle structure that represents the bounding rectangle that defines the ellipse from which the pie shape comes.

startAngle float

Angle measured in degrees clockwise from the x-axis to the first side of the pie shape.

sweepAngle float

Angle measured in degrees clockwise from the startAngle parameter to the second side of the pie shape.

Examples

// Creates a document.
PdfDocument doc = new PdfDocument();
//Adds a new page.
PdfPage page = doc.Pages.Add();
//Adds Brush.  
 PdfBrush brush = new PdfSolidBrush (Color.Red);
//Draw Pie
page.Graphics.DrawPie(brush, new RectangleF(10, 10, 100, 200), 90, 270);
//Save document
doc.Save("Pie.pdf");
//Closes the document.
doc.Close(true);
'Creates a document.
Dim doc As New PdfDocument()
'Adds a new page.
Dim page As PdfPage = doc.Pages.Add()
'Adds Brush.
Dim brush As New PdfSolidBrush (Color.Red)
'Draw Pie
page.Graphics.DrawPie(brush, New RectangleF(10, 10, 100, 200), 90, 270)
'Saves the PDF.
doc.Save("Pie.pdf")
'Closes the document.
doc.Close()

DrawPie(PdfBrush, float, float, float, float, float, float)

Draws a pie shape defined by an ellipse specified by a coordinate pair, a width, a height, and two radial lines.

public void DrawPie(PdfBrush brush, float x, float y, float width, float height, float startAngle, float sweepAngle)

Parameters

brush PdfBrush

Brush that determines the color and texture of the pie.

x float

The x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie shape comes.

y float

The y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie shape comes.

width float

Width of the bounding rectangle that defines the ellipse from which the pie shape comes.

height float

Height of the bounding rectangle that defines the ellipse from which the pie shape comes.

startAngle float

Angle measured in degrees clockwise from the x-axis to the first side of the pie shape.

sweepAngle float

Angle measured in degrees clockwise from the startAngle parameter to the second side of the pie shape.

Examples

// Creates a document.
PdfDocument doc = new PdfDocument();
//Adds a new page.
PdfPage page = doc.Pages.Add();
//Adds Brush.  
 PdfBrush brush = new PdfSolidBrush (Color.Red);
//Draw Pie
page.Graphics.DrawPie(brush, 10, 10, 100, 200, 90, 270);
//Save document
doc.Save("Pie.pdf");
//Closes the document.
doc.Close(true);
'Creates a document.
Dim doc As New PdfDocument()
'Adds a new page.
Dim page As PdfPage = doc.Pages.Add()
'Adds Brush.
Dim brush As New PdfSolidBrush (Color.Red)
'Draw Pie
page.Graphics.DrawPie(brush,10, 10, 100, 200, 90, 270)
'Saves the PDF.
doc.Save("Pie.pdf")
'Closes the document.
doc.Close()

DrawPie(PdfPen, RectangleF, float, float)

Draws a pie shape defined by an ellipse specified by a Rectangle structure and two radial lines.

public void DrawPie(PdfPen pen, RectangleF rectangle, float startAngle, float sweepAngle)

Parameters

pen PdfPen

Pen that determines the color, width, and style of the pie shape.

rectangle RectangleF

Rectangle structure that represents the bounding rectangle that defines the ellipse from which the pie shape comes.

startAngle float

Angle measured in degrees clockwise from the x-axis to the first side of the pie shape.

sweepAngle float

Angle measured in degrees clockwise from the startAngle parameter to the second side of the pie shape.

Examples

// Creates a document.
PdfDocument doc = new PdfDocument();
//Adds a new page.
PdfPage page = doc.Pages.Add();       
//Draw Pie
page.Graphics.DrawPie(PdfPens.Green, new RectangleF(10, 10, 100, 200), 90, 270);
//Save document
doc.Save("Pie.pdf");
//Closes the document.
doc.Close(true);
'Creates a document.
Dim doc As New PdfDocument()
'Adds a new page.
Dim page As PdfPage = doc.Pages.Add()      
'Draw Pie
page.Graphics.DrawPie(PdfPens.Green, New RectangleF(10, 10, 100, 200), 90, 270)
'Saves the PDF.
doc.Save("Pie.pdf")
'Closes the document.
doc.Close()

DrawPie(PdfPen, PdfBrush, RectangleF, float, float)

Draws a pie shape defined by an ellipse specified by a Rectangle structure and two radial lines.

public void DrawPie(PdfPen pen, PdfBrush brush, RectangleF rectangle, float startAngle, float sweepAngle)

Parameters

pen PdfPen

Pen that determines the color, width, and style of the pie shape.

brush PdfBrush

Brush that determines the color and texture of the pie.

rectangle RectangleF

Rectangle structure that represents the bounding rectangle that defines the ellipse from which the pie shape comes.

startAngle float

Angle measured in degrees clockwise from the x-axis to the first side of the pie shape.

sweepAngle float

Angle measured in degrees clockwise from the startAngle parameter to the second side of the pie shape.

Examples

// Creates a document.
PdfDocument doc = new PdfDocument();
//Adds a new page.
PdfPage page = doc.Pages.Add();
//Adds Brush.  
 PdfBrush brush = new PdfSolidBrush (Color.Red);
//Draw Pie
page.Graphics.DrawPie(PdfPens.Green, brush, new RectangleF(10, 10, 100, 200), 90, 270);
//Save document
doc.Save("Pie.pdf");
//Closes the document.
doc.Close(true);
'Creates a document.
Dim doc As New PdfDocument()
'Adds a new page.
Dim page As PdfPage = doc.Pages.Add()
'Adds Brush.
Dim brush As New PdfSolidBrush (Color.Red)
'Draw Pie
page.Graphics.DrawPie(PdfPens.Green, brush, New RectangleF(10, 10, 100, 200), 90, 270)
'Saves the PDF.
doc.Save("Pie.pdf")
'Closes the document.
doc.Close()

DrawPie(PdfPen, PdfBrush, float, float, float, float, float, float)

Draws a pie shape defined by an ellipse specified by a Rectangle structure and two radial lines.

public void DrawPie(PdfPen pen, PdfBrush brush, float x, float y, float width, float height, float startAngle, float sweepAngle)

Parameters

pen PdfPen

Pen that determines the color, width, and style of the pie shape.

brush PdfBrush

Brush that determines the color and texture of the pie.

x float

The x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie shape comes.

y float

The y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie shape comes.

width float

Width of the bounding rectangle that defines the ellipse from which the pie shape comes.

height float

Height of the bounding rectangle that defines the ellipse from which the pie shape comes.

startAngle float

Angle measured in degrees clockwise from the x-axis to the first side of the pie shape.

sweepAngle float

Angle measured in degrees clockwise from the startAngle parameter to the second side of the pie shape.

Examples

// Creates a document.
PdfDocument doc = new PdfDocument();
//Adds a new page.
PdfPage page = doc.Pages.Add();
//Adds Brush.  
 PdfBrush brush = new PdfSolidBrush (Color.Red);
//Draw Pie
page.Graphics.DrawPie(PdfPens.Green, brush, 10, 10, 100, 200, 90, 270);
//Save document
doc.Save("Pie.pdf");
//Closes the document.
doc.Close(true);
'Creates a document.
Dim doc As New PdfDocument()
'Adds a new page.
Dim page As PdfPage = doc.Pages.Add()
'Adds Brush.
Dim brush As New PdfSolidBrush (Color.Red)
'Draw Pie
page.Graphics.DrawPie(PdfPens.Green, brush, 10, 10, 100, 200, 90, 270)
'Saves the PDF.
doc.Save("Pie.pdf")
'Closes the document.
doc.Close()

DrawPie(PdfPen, float, float, float, float, float, float)

Draws a pie shape defined by an ellipse specified by a coordinate pair, a width, a height, and two radial lines.

public void DrawPie(PdfPen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)

Parameters

pen PdfPen

Pen that determines the color, width, and style of the pie shape.

x float

The x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie shape comes.

y float

The y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie shape comes.

width float

Width of the bounding rectangle that defines the ellipse from which the pie shape comes.

height float

Height of the bounding rectangle that defines the ellipse from which the pie shape comes.

startAngle float

Angle measured in degrees clockwise from the x-axis to the first side of the pie shape.

sweepAngle float

Angle measured in degrees clockwise from the startAngle parameter to the second side of the pie shape.

Examples

// Creates a document.
PdfDocument doc = new PdfDocument();
//Adds a new page.
PdfPage page = doc.Pages.Add();       
//Draw Pie
page.Graphics.DrawPie(PdfPens.Green, 10, 10, 100, 200, 90, 270);
//Save document
doc.Save("Pie.pdf");
//Closes the document.
doc.Close(true);
'Creates a document.
Dim doc As New PdfDocument()
'Adds a new page.
Dim page As PdfPage = doc.Pages.Add()      
'Draw Pie
page.Graphics.DrawPie(PdfPens.Green, 10, 10, 100, 200, 90, 270)
'Saves the PDF.
doc.Save("Pie.pdf")
'Closes the document.
doc.Close()

DrawPolygon(PdfBrush, PointF[])

Draws a polygon defined by a brush, an array of Point structures.

public void DrawPolygon(PdfBrush brush, PointF[] points)

Parameters

brush PdfBrush

Brush that determines the color and texture of the pie.

points PointF[]

Array of Point structures that represent the vertices of the polygon.

Examples

// Creates a document.
PdfDocument doc = new PdfDocument();
//Adds a new page.
PdfPage page = doc.Pages.Add();
//Adds Brush.  
 PdfBrush brush = new PdfSolidBrush (Color.Red);
 //Adds points.
 PointF p1 = new PointF(10, 100);
 PointF p2 = new PointF(10, 200);
 PointF p3 = new PointF(100, 100);
 PointF p4 = new PointF(100, 200);
 PointF p5 = new PointF(55, 150);
 PointF[] points = { p1, p2, p3, p4, p5};
//Draw Polygon
page.Graphics.DrawPolygon(brush, points);
//Save document
doc.Save("Polygon.pdf");
//Closes the document.
doc.Close(true);
'Creates a document.
Dim doc As New PdfDocument()
'Adds a new page.
Dim page As PdfPage = doc.Pages.Add()
'Adds Brush.
Dim brush As New PdfSolidBrush (Color.Red)
'Add Points
Dim p1 As New PointF(10, 100)
Dim p2 As New PointF(10, 200)
Dim p3 As New PointF(100, 100)
Dim p4 As New PointF(100, 200)
Dim p5 As New PointF(55, 150)
Dim points As PointF() = {p1, p2, p3, p4, p5}
'Draw Polygon
page.Graphics.DrawPolygon(brush, points);
'Saves the PDF.
doc.Save("Polygon.pdf")
'Closes the document.
doc.Close()

DrawPolygon(PdfPen, PointF[])

Draws a polygon defined by a pen, an array of Point structures.

public void DrawPolygon(PdfPen pen, PointF[] points)

Parameters

pen PdfPen

Pen that determines the color, width, and style of the polygon.

points PointF[]

Array of PointF structures that represent the vertices of the polygon.

Examples

// Creates a document.
PdfDocument doc = new PdfDocument();
//Adds a new page.
PdfPage page = doc.Pages.Add();       
 //Adds points.
 PointF p1 = new PointF(10, 100);
 PointF p2 = new PointF(10, 200);
 PointF p3 = new PointF(100, 100);
 PointF p4 = new PointF(100, 200);
 PointF p5 = new PointF(55, 150);
 PointF[] points = { p1, p2, p3, p4, p5};
//Draw Polygon
page.Graphics.DrawPolygon(PdfPens.Red, points);
//Save document
doc.Save("Polygon.pdf");
//Closes the document.
doc.Close(true);
'Creates a document.
Dim doc As New PdfDocument()
'Adds a new page.
Dim page As PdfPage = doc.Pages.Add()        
'Add Points
Dim p1 As New PointF(10, 100)
Dim p2 As New PointF(10, 200)
Dim p3 As New PointF(100, 100)
Dim p4 As New PointF(100, 200)
Dim p5 As New PointF(55, 150)
Dim points As PointF() = {p1, p2, p3, p4, p5}
'Draw Polygon
page.Graphics.DrawPolygon(PdfPens.Red, points);
'Saves the PDF.
doc.Save("Polygon.pdf")
'Closes the document.
doc.Close()

DrawPolygon(PdfPen, PdfBrush, PointF[])

Draws a polygon defined by a pen, a brush, an array of Point structures.

public void DrawPolygon(PdfPen pen, PdfBrush brush, PointF[] points)

Parameters

pen PdfPen

Pen that determines the color, width, and style of the polygon.

brush PdfBrush

Brush that determines the color and texture of the pie.

points PointF[]

Array of Point structures that represent the vertices of the polygon.

Examples

// Creates a document.
PdfDocument doc = new PdfDocument();
//Adds a new page.
PdfPage page = doc.Pages.Add();
//Adds Brush.  
 PdfBrush brush = new PdfSolidBrush (Color.Red);
 //Adds points.
 PointF p1 = new PointF(10, 100);
 PointF p2 = new PointF(10, 200);
 PointF p3 = new PointF(100, 100);
 PointF p4 = new PointF(100, 200);
 PointF p5 = new PointF(55, 150);
 PointF[] points = { p1, p2, p3, p4, p5};
//Draw Polygon
page.Graphics.DrawPolygon(PdfPens.Black, brush, points);
//Save document
doc.Save("Polygon.pdf");
//Closes the document.
doc.Close(true);
'Creates a document.
Dim doc As New PdfDocument()
'Adds a new page.
Dim page As PdfPage = doc.Pages.Add()
'Adds Brush.
Dim brush As New PdfSolidBrush (Color.Red)
'Add Points
Dim p1 As New PointF(10, 100)
Dim p2 As New PointF(10, 200)
Dim p3 As New PointF(100, 100)
Dim p4 As New PointF(100, 200)
Dim p5 As New PointF(55, 150)
Dim points As PointF() = {p1, p2, p3, p4, p5}
'Draw Polygon
page.Graphics.DrawPolygon(PdfPens.Black, brush, points);
'Saves the PDF.
doc.Save("Polygon.pdf")
'Closes the document.
doc.Close()

DrawRectangle(PdfBrush, RectangleF)

Draws a rectangle specified by a Rectangle structure.

public void DrawRectangle(PdfBrush brush, RectangleF rectangle)

Parameters

brush PdfBrush

Brush that determines the color and texture of the rectangle.

rectangle RectangleF

A Rectangle structure that represents the rectangle to draw.

Examples

// Creates a document.
PdfDocument doc = new PdfDocument();
//Adds a new page.
PdfPage page = doc.Pages.Add();
//Adds Brush.  
 PdfBrush brush = new PdfSolidBrush (Color.Red);
//Draw Rectangle
page.Graphics.DrawRectangle(brush, new RectangleF(10, 10, 100, 100));
//Save document
doc.Save("Rect.pdf");
//Closes the document.
doc.Close(true);
'Creates a document.
Dim doc As New PdfDocument()
'Adds a new page.
Dim page As PdfPage = doc.Pages.Add()
'Adds Brush.
Dim brush As New PdfSolidBrush (Color.Red)
'Draw Rectangle
page.Graphics.DrawRectangle(brush, New RectangleF(10, 10, 100, 100))
'Saves the PDF.
doc.Save("Rect.pdf")
'Closes the document.
doc.Close()

DrawRectangle(PdfBrush, float, float, float, float)

Draws a rectangle specified by a brush, coordinate pair, a width, and a height.

public void DrawRectangle(PdfBrush brush, float x, float y, float width, float height)

Parameters

brush PdfBrush

Brush that determines the color and texture of the rectangle.

x float

The x-coordinate of the upper-left corner of the rectangle to draw.

y float

The y-coordinate of the upper-left corner of the rectangle to draw.

width float

Width of the rectangle to draw.

height float

Height of the rectangle to draw.

Examples

// Creates a document.
PdfDocument doc = new PdfDocument();
//Adds a new page.
PdfPage page = doc.Pages.Add();
//Adds Brush.  
 PdfBrush brush = new PdfSolidBrush (Color.Red);
//Draw Rectangle
page.Graphics.DrawRectangle(brush, 10, 10, 100, 100);
//Save document
doc.Save("Rect.pdf");
//Closes the document.
doc.Close(true);
'Creates a document.
Dim doc As New PdfDocument()
'Adds a new page.
Dim page As PdfPage = doc.Pages.Add()
'Adds Brush.
Dim brush As New PdfSolidBrush (Color.Red)
'Draw Rectangle
page.Graphics.DrawRectangle(brush, 10, 10, 100, 100)
'Saves the PDF.
doc.Save("Rect.pdf")
'Closes the document.
doc.Close()

DrawRectangle(PdfPen, RectangleF)

Draws a rectangle specified by a pen, a Rectangle structure.

public void DrawRectangle(PdfPen pen, RectangleF rectangle)

Parameters

pen PdfPen

A Pen that determines the color, width, and style of the rectangle.

rectangle RectangleF

A Rectangle structure that represents the rectangle to draw.

Examples

// Creates a document.
PdfDocument doc = new PdfDocument();
//Adds a new page.
PdfPage page = doc.Pages.Add();
//Adds Brush.  
 PdfPen pen = new PdfPen (Color.Red);
//Draw Rectangle
page.Graphics.DrawRectangle(pen, new RectangleF(10, 10, 100, 100));
//Save document
doc.Save("Rect.pdf");
//Closes the document.
doc.Close(true);
'Creates a document.
Dim doc As New PdfDocument()
'Adds a new page.
Dim page As PdfPage = doc.Pages.Add()
'Adds Brush.
Dim pen As New PdfPen(Color.Red)
'Draw Rectangle
page.Graphics.DrawRectangle(pen, New RectangleF(10, 10, 100, 100))
'Saves the PDF.
doc.Save("Rect.pdf")
'Closes the document.
doc.Close()

DrawRectangle(PdfPen, PdfBrush, RectangleF)

Draws a rectangle specified by a pen, a brush and a Rectangle structure.

public void DrawRectangle(PdfPen pen, PdfBrush brush, RectangleF rectangle)

Parameters

pen PdfPen

A Pen that determines the color, width, and style of the rectangle.

brush PdfBrush

Brush that determines the color and texture of the rectangle.

rectangle RectangleF

A Rectangle structure that represents the rectangle to draw.

Examples

// Creates a document.
PdfDocument doc = new PdfDocument();
//Adds a new page.
PdfPage page = doc.Pages.Add();
//Adds Brush.  
 PdfBrush brush = new PdfSolidBrush (Color.Red);
//Draw Rectangle
page.Graphics.DrawRectangle(PdfPens.Black, brush, new RectangleF(10, 10, 100, 100));
//Save document
doc.Save("Rect.pdf");
//Closes the document.
doc.Close(true);
'Creates a document.
Dim doc As New PdfDocument()
'Adds a new page.
Dim page As PdfPage = doc.Pages.Add()
'Adds Brush.
Dim brush As New PdfSolidBrush (Color.Red)
'Draw Rectangle
page.Graphics.DrawRectangle(PdfPens.Black, brush, New RectangleF(10, 10, 100, 100))
'Saves the PDF.
doc.Save("Rect.pdf")
'Closes the document.
doc.Close()

DrawRectangle(PdfPen, PdfBrush, float, float, float, float)

Draws a rectangle specified by a pen, a coordinate pair, a width, and a height.

public void DrawRectangle(PdfPen pen, PdfBrush brush, float x, float y, float width, float height)

Parameters

pen PdfPen

A Pen that determines the color, width, and style of the rectangle.

brush PdfBrush

Brush that determines the color and texture of the rectangle.

x float

The x-coordinate of the upper-left corner of the rectangle to draw.

y float

The y-coordinate of the upper-left corner of the rectangle to draw.

width float

Width of the rectangle to draw.

height float

Height of the rectangle to draw.

Examples

// Creates a document.
PdfDocument doc = new PdfDocument();
//Adds a new page.
PdfPage page = doc.Pages.Add();
//Adds Brush.  
 PdfBrush brush = new PdfSolidBrush (Color.Red);
//Draw Rectangle
page.Graphics.DrawRectangle(PdfPens.Black, brush, 10, 10, 100, 100);
//Save document
doc.Save("Rect.pdf");
//Closes the document.
doc.Close(true);
'Creates a document.
Dim doc As New PdfDocument()
'Adds a new page.
Dim page As PdfPage = doc.Pages.Add()
'Adds Brush.
Dim brush As New PdfSolidBrush (Color.Red)
'Draw Rectangle
page.Graphics.DrawRectangle(PdfPens.Black, brush, 10, 10, 100, 100)
'Saves the PDF.
doc.Save("Rect.pdf")
'Closes the document.
doc.Close()

DrawRectangle(PdfPen, float, float, float, float)

Draws a rectangle specified by a pen, a coordinate pair, a width, and a height.

public void DrawRectangle(PdfPen pen, float x, float y, float width, float height)

Parameters

pen PdfPen

A Pen that determines the color, width, and style of the rectangle.

x float

The x-coordinate of the upper-left corner of the rectangle to draw.

y float

The y-coordinate of the upper-left corner of the rectangle to draw.

width float

Width of the rectangle to draw.

height float

Height of the rectangle to draw.

Examples

// Creates a document.
PdfDocument doc = new PdfDocument();
//Adds a new page.
PdfPage page = doc.Pages.Add();
//Adds Brush.  
 PdfPen pen = new PdfPen (Color.Red);
//Draw Rectangle
page.Graphics.DrawRectangle(pen, 10, 10, 100, 100);
//Save document
doc.Save("Rect.pdf");
//Closes the document.
doc.Close(true);
'Creates a document.
Dim doc As New PdfDocument()
'Adds a new page.
Dim page As PdfPage = doc.Pages.Add()
'Adds Brush.
Dim pen As New PdfPen(Color.Red)
'Draw Rectangle
page.Graphics.DrawRectangle(pen, 10, 10, 100, 100)
'Saves the PDF.
doc.Save("Rect.pdf")
'Closes the document.
doc.Close()

DrawString(string, PdfFont, PdfBrush, PointF)

Draws the specified text string at the specified location with the specified Brush and Font objects.

public void DrawString(string s, PdfFont font, PdfBrush brush, PointF point)

Parameters

s string

String to draw.

font PdfFont

Font that defines the text format of the string.

brush PdfBrush

Brush that determines the color and texture of the drawn text.

point PointF

PointF structure that specifies the upper-left corner of the drawn text.

Examples

//Creates a new PDF document.
PdfDocument document = new PdfDocument();
//Adds a page.PdfPage 
PdfPage page = document.Pages.Add();
//Creates PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
//Creates a solid brush.
PdfBrush brush = new PdfSolidBrush(Color.Black);
//Sets the font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12);
//Draws the String.
graphics.DrawString("Hello world!", font, brush, new PointF(20, 20));
//Saves the document.
document.Save("Sample.pdf");
//Closes the document.
document.Close(true);
'Creates a new PDF document.
Dim document As PdfDocument = New PdfDocument()
'Adds a page to the document.
Dim page As PdfPage = document.Pages.Add()
'Creates PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics
'Creates a solid brush.
Dim brush As PdfBrush = New PdfSolidBrush(Color.Black)
'Sets the font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12)
'Draws the text.
graphics.DrawString("Hello world!", font, brush, New PointF(20,20))
'Saves the document.
document.Save("Sample.pdf")
'Closes the document
document.Close(true)

DrawString(string, PdfFont, PdfBrush, PointF, PdfStringFormat)

Draws the specified text string at the specified location with the specified Brush and Font objects.

public void DrawString(string s, PdfFont font, PdfBrush brush, PointF point, PdfStringFormat format)

Parameters

s string

String to draw.

font PdfFont

Font that defines the text format of the string.

brush PdfBrush

Brush that determines the color and texture of the drawn text.

point PointF

PointF structure that specifies the upper-left corner of the drawn text.

format PdfStringFormat

The text string format.

Examples

//Creates a new PDF document.
PdfDocument document = new PdfDocument();
//Adds a page.PdfPage 
PdfPage page = document.Pages.Add();
//Creates PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
//Creates a solid brush.
PdfBrush brush = new PdfSolidBrush(Color.Black);
//Sets the font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12);
//Create PDF string format.
PdfStringFormat format = new PdfStringFormat();
//Set text alignement.
format.Alignment = PdfTextAlignment.Left;
format.LineAlignment = PdfVerticalAlignment.Top;
//Draws the String.
graphics.DrawString("Hello world!", font, brush, new PointF(20, 20), format);
//Saves the document.
document.Save("Sample.pdf");
//Closes the document.
document.Close(true);
'Creates a new PDF document.
Dim document As PdfDocument = New PdfDocument()
'Adds a page to the document.
Dim page As PdfPage = document.Pages.Add()
'Creates PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics
'Creates a solid brush.
Dim brush As PdfBrush = New PdfSolidBrush(Color.Black)
'Sets the font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12)
'Create PDF string format.
Dim format As New PdfStringFormat()
'Set text alignement.
format.Alignment = PdfTextAlignment.Left
format.LineAlignment = PdfVerticalAlignment.Top
'Draws the text.
graphics.DrawString("Hello world!", font, brush, New PointF(20,20), format)
'Saves the document.
document.Save("Sample.pdf")
'Closes the document
document.Close(true)

DrawString(string, PdfFont, PdfBrush, RectangleF)

Draws the specified text string at the specified location and size with the specified Brush and Font objects.

public void DrawString(string s, PdfFont font, PdfBrush brush, RectangleF layoutRectangle)

Parameters

s string

The text string.

font PdfFont

Font that defines the text format of the string.

brush PdfBrush

Brush that determines the color and texture of the drawn text.

layoutRectangle RectangleF

RectangleF structure that specifies the bounds of the drawn text.

Examples

//Creates a new PDF document.
PdfDocument document = new PdfDocument();
//Adds a page.PdfPage 
PdfPage page = document.Pages.Add();
//Creates PDF graphics for the page.
PdfGraphics graphics = page.Graphics;       
//Sets the font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12);
//Draws the String.
graphics.DrawString("Hello world!", font, PdfBrushes.Red, new RectangleF(20, 20, 200, 20));
//Saves the document.
document.Save("Sample.pdf");
//Closes the document.
document.Close(true);
'Creates a new PDF document.
Dim document As PdfDocument = New PdfDocument()
'Adds a page to the document.
Dim page As PdfPage = document.Pages.Add()
'Creates PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics      
'Sets the font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12)
'Draws the text.
graphics.DrawString("Hello world!", font, PdfBrushes.Red, New RectangleF(20, 20, 200, 20))
'Saves the document.
document.Save("Sample.pdf")
'Closes the document
document.Close(true)

DrawString(string, PdfFont, PdfBrush, RectangleF, PdfStringFormat)

Draws the specified text string at the specified location and size with the specified Brush and Font objects.

public void DrawString(string s, PdfFont font, PdfBrush brush, RectangleF layoutRectangle, PdfStringFormat format)

Parameters

s string

String to draw.

font PdfFont

Font that defines the text format of the string.

brush PdfBrush

Brush that determines the color and texture of the drawn text.

layoutRectangle RectangleF

RectangleF structure that specifies the bounds of the drawn text.

format PdfStringFormat

StringFormat that specifies formatting attributes, such as line spacing and alignment, that are applied to the drawn text.

Examples

//Creates a new PDF document.
PdfDocument document = new PdfDocument();
//Adds a page.PdfPage 
PdfPage page = document.Pages.Add();
//Creates PDF graphics for the page.
PdfGraphics graphics = page.Graphics;       
//Sets the font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12);
//Create PDF string format.
PdfStringFormat format = new PdfStringFormat();
//Set text alignement.
format.Alignment = PdfTextAlignment.Left;
format.LineAlignment = PdfVerticalAlignment.Top;
//Draws the String.
graphics.DrawString("Hello world!", font, PdfBrushes.Red, new RectangleF(20, 20, 200, 20), format);
//Saves the document.
document.Save("Sample.pdf");
//Closes the document.
document.Close(true);
'Creates a new PDF document.
Dim document As PdfDocument = New PdfDocument()
'Adds a page to the document.
Dim page As PdfPage = document.Pages.Add()
'Creates PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics        
'Sets the font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12)
'Create PDF string format.
Dim format As New PdfStringFormat()
'Set text alignement.
format.Alignment = PdfTextAlignment.Left
format.LineAlignment = PdfVerticalAlignment.Top
'Draws the text.
graphics.DrawString("Hello world!", font, PdfBrushes.Red, New RectangleF(20, 20, 200, 20), format)
'Saves the document.
document.Save("Sample.pdf")
'Closes the document
document.Close(true)

DrawString(string, PdfFont, PdfBrush, float, float)

Draws the specified text string at the specified location with the specified Brush and Font objects.

public void DrawString(string s, PdfFont font, PdfBrush brush, float x, float y)

Parameters

s string

String to draw.

font PdfFont

Font that defines the text format of the string.

brush PdfBrush

Brush that determines the color and texture of the drawn text.

x float

The x.

y float

The y.

Examples

//Creates a new PDF document.
PdfDocument document = new PdfDocument();
//Adds a page.PdfPage 
PdfPage page = document.Pages.Add();
//Creates PDF graphics for the page.
PdfGraphics graphics = page.Graphics;       
//Sets the font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12);       
//Draws the String.
graphics.DrawString("Hello world!", font, PdfBrushes.Red, 20, 20);
//Saves the document.
document.Save("Sample.pdf");
//Closes the document.
document.Close(true);
'Creates a new PDF document.
Dim document As PdfDocument = New PdfDocument()
'Adds a page to the document.
Dim page As PdfPage = document.Pages.Add()
'Creates PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics        
'Sets the font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12)       
'Draws the text.
graphics.DrawString("Hello world!", font, PdfBrushes.Red, 20,20)
'Saves the document.
document.Save("Sample.pdf")
'Closes the document
document.Close(true)

DrawString(string, PdfFont, PdfBrush, float, float, PdfStringFormat)

Draws the specified text string at the specified location with the specified Brush and Font objects.

public void DrawString(string s, PdfFont font, PdfBrush brush, float x, float y, PdfStringFormat format)

Parameters

s string

String to draw.

font PdfFont

Font that defines the text format of the string.

brush PdfBrush

Brush that determines the color and texture of the drawn text.

x float

The x-coordinate of the upper-left corner of the drawn text.

y float

The y-coordinate of the upper-left corner of the drawn text.

format PdfStringFormat

The text string format.

Examples

//Creates a new PDF document.
PdfDocument document = new PdfDocument();
//Adds a page.PdfPage 
PdfPage page = document.Pages.Add();
//Creates PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
//Creates a solid brush.
PdfBrush brush = new PdfSolidBrush(Color.Black);
//Sets the font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12);
//Create PDF string format.
PdfStringFormat format = new PdfStringFormat();
//Set text alignement.
format.Alignment = PdfTextAlignment.Left;
format.LineAlignment = PdfVerticalAlignment.Top;
//Draws the String.
graphics.DrawString("Hello world!", font, brush, 20, 20, format);
//Saves the document.
document.Save("Sample.pdf");
//Closes the document.
document.Close(true);
'Creates a new PDF document.
Dim document As PdfDocument = New PdfDocument()
'Adds a page to the document.
Dim page As PdfPage = document.Pages.Add()
'Creates PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics
'Creates a solid brush.
Dim brush As PdfBrush = New PdfSolidBrush(Color.Black)
'Sets the font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12)
'Create PDF string format.
Dim format As New PdfStringFormat()
'Set text alignement.
format.Alignment = PdfTextAlignment.Left
format.LineAlignment = PdfVerticalAlignment.Top
'Draws the text.
graphics.DrawString("Hello world!", font, brush, 20,20, format)
'Saves the document.
document.Save("Sample.pdf")
'Closes the document
document.Close(true)

DrawString(string, PdfFont, PdfPen, PointF)

Draws the specified text string at the specified location with the specified Brush and Font objects.

public void DrawString(string s, PdfFont font, PdfPen pen, PointF point)

Parameters

s string

String to draw.

font PdfFont

Font that defines the text format of the string.

pen PdfPen

Pen that determines the color, width, and style of the path.

point PointF

PointF structure that specifies the upper-left corner of the drawn text.

Examples

//Creates a new PDF document.
PdfDocument document = new PdfDocument();
//Adds a page.PdfPage 
PdfPage page = document.Pages.Add();
//Creates PDF graphics for the page.
PdfGraphics graphics = page.Graphics;       
//Sets the font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12);       
//Draws the String.
graphics.DrawString("Hello world!", font, PdfPens.Red, new PointF(20, 20));
//Saves the document.
document.Save("Sample.pdf");
//Closes the document.
document.Close(true);
'Creates a new PDF document.
Dim document As PdfDocument = New PdfDocument()
'Adds a page to the document.
Dim page As PdfPage = document.Pages.Add()
'Creates PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics        
'Sets the font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12)       
'Draws the text.
graphics.DrawString("Hello world!", font, PdfPens.Red, New PointF(20,20))
'Saves the document.
document.Save("Sample.pdf")
'Closes the document
document.Close(true)

DrawString(string, PdfFont, PdfPen, PointF, PdfStringFormat)

Draws the specified text string at the specified location with the specified Brush and Font objects.

public void DrawString(string s, PdfFont font, PdfPen pen, PointF point, PdfStringFormat format)

Parameters

s string

String to draw.

font PdfFont

Font that defines the text format of the string.

pen PdfPen

Pen that determines the color, width, and style of the path.

point PointF

PointF structure that specifies the upper-left corner of the drawn text.

format PdfStringFormat

The text string format.

Examples

//Creates a new PDF document.
PdfDocument document = new PdfDocument();
//Adds a page.PdfPage 
PdfPage page = document.Pages.Add();
//Creates PDF graphics for the page.
PdfGraphics graphics = page.Graphics;       
//Sets the font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12);
//Create PDF string format.
PdfStringFormat format = new PdfStringFormat();
//Set text alignement.
format.Alignment = PdfTextAlignment.Left;
format.LineAlignment = PdfVerticalAlignment.Top;
//Draws the String.
graphics.DrawString("Hello world!", font, PdfPens.Red, new PointF(20, 20), format);
//Saves the document.
document.Save("Sample.pdf");
//Closes the document.
document.Close(true);
'Creates a new PDF document.
Dim document As PdfDocument = New PdfDocument()
'Adds a page to the document.
Dim page As PdfPage = document.Pages.Add()
'Creates PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics        
'Sets the font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12)
'Create PDF string format.
Dim format As New PdfStringFormat()
'Set text alignement.
format.Alignment = PdfTextAlignment.Left
format.LineAlignment = PdfVerticalAlignment.Top
'Draws the text.
graphics.DrawString("Hello world!", font, PdfPens.Red, New PointF(20,20), format)
'Saves the document.
document.Save("Sample.pdf")
'Closes the document
document.Close(true)

DrawString(string, PdfFont, PdfPen, RectangleF)

Draws the specified text string at the specified location and size with the specified Pen and Font objects.

public void DrawString(string s, PdfFont font, PdfPen pen, RectangleF layoutRectangle)

Parameters

s string

String to draw.

font PdfFont

Font that defines the text format of the string.

pen PdfPen

Pen that determines the color, width, and style of the path.

layoutRectangle RectangleF

RectangleF structure that specifies the bounds of the drawn text.

Examples

//Creates a new PDF document.
PdfDocument document = new PdfDocument();
//Adds a page.PdfPage 
PdfPage page = document.Pages.Add();
//Creates PDF graphics for the page.
PdfGraphics graphics = page.Graphics;       
//Sets the font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12);
//Draws the String.
graphics.DrawString("Hello world!", font, PdfPens.Red, new RectangleF(20, 20, 200, 20));
//Saves the document.
document.Save("Sample.pdf");
//Closes the document.
document.Close(true);
'Creates a new PDF document.
Dim document As PdfDocument = New PdfDocument()
'Adds a page to the document.
Dim page As PdfPage = document.Pages.Add()
'Creates PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics      
'Sets the font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12)
'Draws the text.
graphics.DrawString("Hello world!", font, PdfPens.Red, New RectangleF(20, 20, 200, 20))
'Saves the document.
document.Save("Sample.pdf")
'Closes the document
document.Close(true)

DrawString(string, PdfFont, PdfPen, RectangleF, PdfStringFormat)

Draws the specified text string at the specified location and size with the specified Pen and Font objects.

public void DrawString(string s, PdfFont font, PdfPen pen, RectangleF layoutRectangle, PdfStringFormat format)

Parameters

s string

String to draw.

font PdfFont

Font that defines the text format of the string.

pen PdfPen

Pen that determines the color, width, and style of the path.

layoutRectangle RectangleF

RectangleF structure that specifies the bounds of the drawn text.

format PdfStringFormat

StringFormat that specifies formatting attributes, such as line spacing and alignment, that are applied to the drawn text.

Examples

//Creates a new PDF document.
PdfDocument document = new PdfDocument();
//Adds a page.PdfPage 
PdfPage page = document.Pages.Add();
//Creates PDF graphics for the page.
PdfGraphics graphics = page.Graphics;       
//Sets the font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12);
//Create PDF string format.
PdfStringFormat format = new PdfStringFormat();
//Set text alignement.
format.Alignment = PdfTextAlignment.Left;
format.LineAlignment = PdfVerticalAlignment.Top;
//Draws the String.
graphics.DrawString("Hello world!", font, PdfPens.Red, new RectangleF(20, 20, 200, 20), format);
//Saves the document.
document.Save("Sample.pdf");
//Closes the document.
document.Close(true);
'Creates a new PDF document.
Dim document As PdfDocument = New PdfDocument()
'Adds a page to the document.
Dim page As PdfPage = document.Pages.Add()
'Creates PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics        
'Sets the font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12)
'Create PDF string format.
Dim format As New PdfStringFormat()
'Set text alignement.
format.Alignment = PdfTextAlignment.Left
format.LineAlignment = PdfVerticalAlignment.Top
'Draws the text.
graphics.DrawString("Hello world!", font, PdfPens.Red, New RectangleF(20, 20, 200, 20), format)
'Saves the document.
document.Save("Sample.pdf")
'Closes the document
document.Close(true)

DrawString(string, PdfFont, PdfPen, PdfBrush, PointF)

Draws the specified text string at the specified location with the specified Brush and Font objects.

public void DrawString(string s, PdfFont font, PdfPen pen, PdfBrush brush, PointF point)

Parameters

s string

String to draw.

font PdfFont

Font that defines the text format of the string.

pen PdfPen

Pen that determines the color, width, and style of the path.

brush PdfBrush

Brush that determines the color and texture of the drawn text.

point PointF

PointF structure that specifies the upper-left corner of the drawn text.

Examples

//Creates a new PDF document.
PdfDocument document = new PdfDocument();
//Adds a page.PdfPage 
PdfPage page = document.Pages.Add();
//Creates PDF graphics for the page.
PdfGraphics graphics = page.Graphics;       
//Sets the font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12);
//Draws the String.
graphics.DrawString("Hello world!", font, PdfPens.Red, PdfBrushes.Green, new PointF(20, 20));
//Saves the document.
document.Save("Sample.pdf");
//Closes the document.
document.Close(true);
'Creates a new PDF document.
Dim document As PdfDocument = New PdfDocument()
'Adds a page to the document.
Dim page As PdfPage = document.Pages.Add()
'Creates PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics      
'Sets the font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12)
'Draws the text.
graphics.DrawString("Hello world!", font, PdfPens.Red, PdfBrushes.Green, New PointF(20, 20))
'Saves the document.
document.Save("Sample.pdf")
'Closes the document
document.Close(true)

DrawString(string, PdfFont, PdfPen, PdfBrush, PointF, PdfStringFormat)

Draws the specified text string at the specified location with the specified Brush and Font objects.

public void DrawString(string s, PdfFont font, PdfPen pen, PdfBrush brush, PointF point, PdfStringFormat format)

Parameters

s string

String to draw.

font PdfFont

Font that defines the text format of the string.

pen PdfPen

Pen that determines the color, width, and style of the path.

brush PdfBrush

Brush that determines the color and texture of the drawn text.

point PointF

PointF structure that specifies the upper-left corner of the drawn text.

format PdfStringFormat

StringFormat that specifies formatting attributes, such as line spacing and alignment, that are applied to the drawn text.

Examples

//Creates a new PDF document.
PdfDocument document = new PdfDocument();
//Adds a page.PdfPage 
PdfPage page = document.Pages.Add();
//Creates PDF graphics for the page.
PdfGraphics graphics = page.Graphics;       
//Sets the font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12);
//Create PDF string format.
PdfStringFormat format = new PdfStringFormat();
//Set text alignement.
format.Alignment = PdfTextAlignment.Left;
format.LineAlignment = PdfVerticalAlignment.Top;
//Draws the String.
graphics.DrawString("Hello world!", font, PdfPens.Red, PdfBrushes.Green, new PointF(20, 20), format);
//Saves the document.
document.Save("Sample.pdf");
//Closes the document.
document.Close(true);
'Creates a new PDF document.
Dim document As PdfDocument = New PdfDocument()
'Adds a page to the document.
Dim page As PdfPage = document.Pages.Add()
'Creates PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics        
'Sets the font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12)
'Create PDF string format.
Dim format As New PdfStringFormat()
'Set text alignement.
format.Alignment = PdfTextAlignment.Left
format.LineAlignment = PdfVerticalAlignment.Top
'Draws the text.
graphics.DrawString("Hello world!", font, PdfPens.Red, PdfBrushes.Green, New PointF(20,20), format)
'Saves the document.
document.Save("Sample.pdf")
'Closes the document
document.Close(true)

DrawString(string, PdfFont, PdfPen, PdfBrush, RectangleF, PdfStringFormat)

Draws the specified text string at the specified location and size with the specified Pen, Brush and Font objects.

public void DrawString(string s, PdfFont font, PdfPen pen, PdfBrush brush, RectangleF layoutRectangle, PdfStringFormat format)

Parameters

s string

String to draw.

font PdfFont

Font that defines the text format of the string.

pen PdfPen

Pen that determines the color, width, and style of the path.

brush PdfBrush

The brush.

layoutRectangle RectangleF

RectangleF structure that specifies the bounds of the drawn text.

format PdfStringFormat

StringFormat that specifies formatting attributes, such as line spacing and alignment, that are applied to the drawn text.

Examples

//Creates a new PDF document.
PdfDocument document = new PdfDocument();
//Adds a page.PdfPage 
PdfPage page = document.Pages.Add();
//Creates PDF graphics for the page.
PdfGraphics graphics = page.Graphics;       
//Sets the font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12);
//Create PDF string format.
PdfStringFormat format = new PdfStringFormat();
//Set text alignement.
format.Alignment = PdfTextAlignment.Left;
format.LineAlignment = PdfVerticalAlignment.Top;
//Draws the String.
graphics.DrawString("Hello world!", font, PdfPens.Red, PdfBrushes.Green, new RectangleF(20, 20, 200, 20), format);
//Saves the document.
document.Save("Sample.pdf");
//Closes the document.
document.Close(true);
'Creates a new PDF document.
Dim document As PdfDocument = New PdfDocument()
'Adds a page to the document.
Dim page As PdfPage = document.Pages.Add()
'Creates PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics        
'Sets the font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12)
'Create PDF string format.
Dim format As New PdfStringFormat()
'Set text alignement.
format.Alignment = PdfTextAlignment.Left
format.LineAlignment = PdfVerticalAlignment.Top
'Draws the text.
graphics.DrawString("Hello world!", font, PdfPens.Red, PdfBrushes.Green, New RectangleF(20, 20, 200, 20), format)
'Saves the document.
document.Save("Sample.pdf")
'Closes the document
document.Close(true)

DrawString(string, PdfFont, PdfPen, PdfBrush, float, float)

Draws the specified text string at the specified location with the specified Brush and Font objects.

public void DrawString(string s, PdfFont font, PdfPen pen, PdfBrush brush, float x, float y)

Parameters

s string

The text string.

font PdfFont

Font that defines the text format of the string.

pen PdfPen

Pen that determines the color, width, and style of the path.

brush PdfBrush

Brush that determines the color and texture of the drawn text.

x float

The x-coordinate of the upper-left corner of the drawn text.

y float

The y-coordinate of the upper-left corner of the drawn text.

Examples

//Creates a new PDF document.
PdfDocument document = new PdfDocument();
//Adds a page.PdfPage 
PdfPage page = document.Pages.Add();
//Creates PDF graphics for the page.
PdfGraphics graphics = page.Graphics;       
//Sets the font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12);
//Draws the String.
graphics.DrawString("Hello world!", font, PdfPens.Red, PdfBrushes.Green, 20, 20);
//Saves the document.
document.Save("Sample.pdf");
//Closes the document.
document.Close(true);
'Creates a new PDF document.
Dim document As PdfDocument = New PdfDocument()
'Adds a page to the document.
Dim page As PdfPage = document.Pages.Add()
'Creates PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics      
'Sets the font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12)
'Draws the text.
graphics.DrawString("Hello world!", font, PdfPens.Red, PdfBrushes.Green, 20, 20)
'Saves the document.
document.Save("Sample.pdf")
'Closes the document
document.Close(true)

DrawString(string, PdfFont, PdfPen, PdfBrush, float, float, PdfStringFormat)

Draws the specified text string at the specified location with the specified Brush and Font objects.

public void DrawString(string s, PdfFont font, PdfPen pen, PdfBrush brush, float x, float y, PdfStringFormat format)

Parameters

s string

The text string.

font PdfFont

Font that defines the text format of the string.

pen PdfPen

Pen that determines the color, width, and style of the path.

brush PdfBrush

Brush that determines the color and texture of the drawn text.

x float

The x-coordinate of the upper-left corner of the drawn text.

y float

The y-coordinate of the upper-left corner of the drawn text.

format PdfStringFormat

The text string format.

Examples

//Creates a new PDF document.
PdfDocument document = new PdfDocument();
//Adds a page.PdfPage 
PdfPage page = document.Pages.Add();
//Creates PDF graphics for the page.
PdfGraphics graphics = page.Graphics;       
//Sets the font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12);
//Create PDF string format.
PdfStringFormat format = new PdfStringFormat();
//Set text alignement.
format.Alignment = PdfTextAlignment.Left;
format.LineAlignment = PdfVerticalAlignment.Top;
//Draws the String.
graphics.DrawString("Hello world!", font, PdfPens.Red, PdfBrushes.Green, 20, 20, format);
//Saves the document.
document.Save("Sample.pdf");
//Closes the document.
document.Close(true);
'Creates a new PDF document.
Dim document As PdfDocument = New PdfDocument()
'Adds a page to the document.
Dim page As PdfPage = document.Pages.Add()
'Creates PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics        
'Sets the font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12)
'Create PDF string format.
Dim format As New PdfStringFormat()
'Set text alignement.
format.Alignment = PdfTextAlignment.Left
format.LineAlignment = PdfVerticalAlignment.Top
'Draws the text.
graphics.DrawString("Hello world!", font, PdfPens.Red, PdfBrushes.Green, 20,20, format)
'Saves the document.
document.Save("Sample.pdf")
'Closes the document
document.Close(true)

DrawString(string, PdfFont, PdfPen, float, float)

Draws the specified text string at the specified location with the specified Brush and Font objects.

public void DrawString(string s, PdfFont font, PdfPen pen, float x, float y)

Parameters

s string

String to draw.

font PdfFont

Font that defines the text format of the string.

pen PdfPen

Pen that determines the color, width, and style of the path.

x float

The x-coordinate of the upper-left corner of the drawn text.

y float

The y-coordinate of the upper-left corner of the drawn text.

Examples

//Creates a new PDF document.
PdfDocument document = new PdfDocument();
//Adds a page.PdfPage 
PdfPage page = document.Pages.Add();
//Creates PDF graphics for the page.
PdfGraphics graphics = page.Graphics;       
//Sets the font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12);
//Draws the String.
graphics.DrawString("Hello world!", font, PdfPens.Red, 20, 20);
//Saves the document.
document.Save("Sample.pdf");
//Closes the document.
document.Close(true);
'Creates a new PDF document.
Dim document As PdfDocument = New PdfDocument()
'Adds a page to the document.
Dim page As PdfPage = document.Pages.Add()
'Creates PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics      
'Sets the font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12)
'Draws the text.
graphics.DrawString("Hello world!", font, PdfPens.Red, 20, 20)
'Saves the document.
document.Save("Sample.pdf")
'Closes the document
document.Close(true)

DrawString(string, PdfFont, PdfPen, float, float, PdfStringFormat)

Draws the specified text string at the specified location with the specified Brush and Font objects.

public void DrawString(string s, PdfFont font, PdfPen pen, float x, float y, PdfStringFormat format)

Parameters

s string

String to draw.

font PdfFont

Font that defines the text format of the string..

pen PdfPen

Pen that determines the color, width, and style of the path.

x float

The x-coordinate of the upper-left corner of the drawn text.

y float

The y-coordinate of the upper-left corner of the drawn text.

format PdfStringFormat

The text string format.

Examples

//Creates a new PDF document.
PdfDocument document = new PdfDocument();
//Adds a page.PdfPage 
PdfPage page = document.Pages.Add();
//Creates PDF graphics for the page.
PdfGraphics graphics = page.Graphics;       
//Sets the font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12);
//Create PDF string format.
PdfStringFormat format = new PdfStringFormat();
//Set text alignement.
format.Alignment = PdfTextAlignment.Left;
format.LineAlignment = PdfVerticalAlignment.Top;
//Draws the String.
graphics.DrawString("Hello world!", font, PdfPens.Red, 20, 20, format);
//Saves the document.
document.Save("Sample.pdf");
//Closes the document.
document.Close(true);
'Creates a new PDF document.
Dim document As PdfDocument = New PdfDocument()
'Adds a page to the document.
Dim page As PdfPage = document.Pages.Add()
'Creates PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics        
'Sets the font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12)
'Create PDF string format.
Dim format As New PdfStringFormat()
'Set text alignement.
format.Alignment = PdfTextAlignment.Left
format.LineAlignment = PdfVerticalAlignment.Top
'Draws the text.
graphics.DrawString("Hello world!", font, PdfPens.Red, 20,20, format)
'Saves the document.
document.Save("Sample.pdf")
'Closes the document
document.Close(true)

Flush()

Forces execution of all pending graphics operations and returns immediately without waiting for the operations to finish.

public void Flush()

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Draw string to PDF page graphics.
graphics.DrawString("Hello World!", font, PdfBrushes.Black, PointF.Empty);
//Draw the rectangle to PDF page graphics.
graphics.DrawRectangle(PdfPens.Red, new RectangleF(0, 20, 200, 100));
graphics.Flush();
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Draw string to PDF page graphics.
graphics.DrawString("Hello World!", font, PdfBrushes.Black, PointF.Empty)
'Draw the rectangle to PDF page graphics.
graphics.DrawRectangle(PdfPens.Red, New RectangleF(0, 20, 200, 100))
graphics.Flush()
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)

OnStructElementChanged(PdfTag)

Raise the event on property changed.

protected void OnStructElementChanged(PdfTag tag)

Parameters

tag PdfTag

Restore()

Restores the state of this Graphics to the state represented by a GraphicsState.

public void Restore()

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Save the graphics.
graphics.Save();
//Set graphics translate transform.
graphics.TranslateTransform(100, 100);            
//Draws the String.
graphics.DrawString("Hello world!", font, PdfPens.Red, 0, 0);
//Restore the graphics.
graphics.Restore();
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Save the graphics.
graphics.Save()
'Set graphics translate transform.
graphics.TranslateTransform(100, 100)
'Draws the String.
graphics.DrawString("Hello world!", font, PdfPens.Red, 0, 0)
'Restore the graphics.
graphics.Restore()
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)

Restore(PdfGraphicsState)

Restores the state of this Graphics to the state represented by a GraphicsState.

public void Restore(PdfGraphicsState state)

Parameters

state PdfGraphicsState

GraphicsState that represents the state to which to restore this Graphics.

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Save the graphics.
PdfGraphicsState state = graphics.Save();
//Set graphics translate transform.
graphics.TranslateTransform(100, 100);            
//Draws the String.
graphics.DrawString("Hello world!", font, PdfPens.Red, 0, 0);
//Restore the graphics.
graphics.Restore(state);
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Save the graphics.
Dim state As PdfGraphicsState = graphics.Save()
'Set graphics translate transform.
graphics.TranslateTransform(100, 100)
'Draws the String.
graphics.DrawString("Hello world!", font, PdfPens.Red, 0, 0)
'Restore the graphics.
graphics.Restore(state)
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)

Remarks

This method works similar to method.

RotateTransform(float)

Applies the specified rotation to the transformation matrix of this Graphics.

public void RotateTransform(float angle)

Parameters

angle float

Angle of rotation in degrees.

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Save the graphics.
graphics.Save();
//Set rotate transform
graphics.RotateTransform(-90);            
//Draws the String.
graphics.DrawString("Hello world!", font, PdfPens.Red, -100, 0);
//Restore the graphics.
graphics.Restore();
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Save the graphics.
graphics.Save()
'Set rotate transform
graphics.RotateTransform(-90)
'Draws the String.
graphics.DrawString("Hello world!", font, PdfPens.Red, -100, 0)
'Restore the graphics.
graphics.Restore()
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)

Save()

Saves the current state of this Graphics and identifies the saved state with a GraphicsState.

public PdfGraphicsState Save()

Returns

PdfGraphicsState

This method returns a GraphicsState that represents the saved state of this Graphics.

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Save the graphics.
graphics.Save();
//Set graphics translate transform.
graphics.TranslateTransform(100, 100);            
//Draws the String.
graphics.DrawString("Hello world!", font, PdfPens.Red, 0, 0);
//Restore the graphics.
graphics.Restore();
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Save the graphics.
graphics.Save()
'Set graphics translate transform.
graphics.TranslateTransform(100, 100)
'Draws the String.
graphics.DrawString("Hello world!", font, PdfPens.Red, 0, 0)
'Restore the graphics.
graphics.Restore()
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)

Remarks

This method works similar to method.

ScaleTransform(float, float)

Applies the specified scaling operation to the transformation matrix of this Graphics by prepending it to the object's transformation matrix.

public void ScaleTransform(float scaleX, float scaleY)

Parameters

scaleX float

Scale factor in the x direction.

scaleY float

Scale factor in the y direction.

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Save the graphics.
graphics.Save();
//Scale transform
graphics.ScaleTransform(0.5f, 0.5f);             
//Draws the String.
graphics.DrawString("Hello world!", font, PdfPens.Red, 0, 0);
//Restore the graphics.
graphics.Restore();
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Save the graphics.
graphics.Save()
'Scale transform
graphics.ScaleTransform(0.5F, 0.5F)
'Draws the String.
graphics.DrawString("Hello world!", font, PdfPens.Red, 0, 0)
'Restore the graphics.
graphics.Restore()
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)

SetClip(RectangleF)

Sets the clipping region of this Graphics to the rectangle specified by a RectangleF structure.

public void SetClip(RectangleF rectangle)

Parameters

rectangle RectangleF

RectangleF structure that represents the new clip region.

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//set clip.
graphics.SetClip(new RectangleF(0, 0, 50, 12));          
//Draws the String.
graphics.DrawString("Hello world!", font, PdfPens.Red, 0, 0);        
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'set clip.
graphics.SetClip(New RectangleF(0, 0, 50, 12))
'Draws the String.
graphics.DrawString("Hello world!", font, PdfPens.Red, 0, 0)        
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)

SetClip(RectangleF, PdfFillMode)

Sets the clipping region of this Graphics to the result of the specified operation combining the current clip region and the rectangle specified by a RectangleF structure.

public void SetClip(RectangleF rectangle, PdfFillMode mode)

Parameters

rectangle RectangleF

RectangleF structure to combine.

mode PdfFillMode

Member of the PdfFillMode enumeration that specifies the filling operation to use.

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//set clip.
graphics.SetClip(new RectangleF(0, 0, 50, 12), PdfFillMode.Alternate);          
//Draws the String.
graphics.DrawString("Hello world!", font, PdfPens.Red, 0, 0);        
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'set clip.
graphics.SetClip(New RectangleF(0, 0, 50, 12), PdfFillMode.Alternate)
'Draws the String.
graphics.DrawString("Hello world!", font, PdfPens.Red, 0, 0)        
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)

SetClip(PdfPath)

Sets the clipping region of this Graphics to the result of the specified operation combining the current clip region and the specified PdfPath.

public void SetClip(PdfPath path)

Parameters

path PdfPath

PdfPath to clip.

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Create PDF path.
PdfPath path = new PdfPath();
path.AddRectangle(new RectangleF(0, 0, 50, 12));
//set clip.
graphics.SetClip(path);          
//Draws the String.
graphics.DrawString("Hello world!", font, PdfPens.Red, 0, 0);        
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Create PDF path.
Dim path As New PdfPath()
path.AddRectangle(New RectangleF(0, 0, 50, 12))
'set clip.
graphics.SetClip(path)
'Draws the String.
graphics.DrawString("Hello world!", font, PdfPens.Red, 0, 0)        
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)

SetClip(PdfPath, PdfFillMode)

Modifying the current clipping path by intersecting it with the current path.

public void SetClip(PdfPath path, PdfFillMode mode)

Parameters

path PdfPath

PdfPath to fill.

mode PdfFillMode

Member of the PdfFillMode enumeration that specifies the filling operation to use.

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Create PDF path.
PdfPath path = new PdfPath();
path.AddRectangle(new RectangleF(0, 0, 50, 12));
//set clip.
graphics.SetClip(path, PdfFillMode.Alternate);          
//Draws the String.
graphics.DrawString("Hello world!", font, PdfPens.Red, 0, 0);        
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Create PDF path.
Dim path As New PdfPath()
path.AddRectangle(New RectangleF(0, 0, 50, 12))
'set clip.
graphics.SetClip(path, PdfFillMode.Alternate)
'Draws the String.
graphics.DrawString("Hello world!", font, PdfPens.Red, 0, 0)        
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)

SetTransparency(float)

Sets the transparency of this Graphics with the specified value for pen

public void SetTransparency(float alpha)

Parameters

alpha float

The alpha value for both pen and brush operations.

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Set transparancy.
graphics.SetTransparency(0.5f);
//Draws the String.
graphics.DrawString("Hello world!", font, PdfBrushes.Red, 0, 0);        
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Set transparancy.
graphics.SetTransparency(0.5F)
'Draws the String.
graphics.DrawString("Hello world!", font, PdfBrueshes.Red, 0, 0)        
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)

SetTransparency(float, float)

Sets the transparency of this Graphics with the specified value for pen and brush

public void SetTransparency(float alphaPen, float alphaBrush)

Parameters

alphaPen float

The alpha value for pen operations.

alphaBrush float

The alpha value for brush operations.

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Set transparancy.
graphics.SetTransparency(0.5f, 0.5f);
//Draws the String.
graphics.DrawString("Hello world!", font, PdfPens.Black, PdfBrushes.Red, 0, 0);        
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Set transparancy.
graphics.SetTransparency(0.5F, 0.5F)
'Draws the String.
graphics.DrawString("Hello world!", font, PdfPens.Black, PdfBrueshes.Red, 0, 0)        
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)

SetTransparency(float, float, PdfBlendMode)

Sets the transparency of this Graphics with the specified PdfBlendMode

public void SetTransparency(float alphaPen, float alphaBrush, PdfBlendMode blendMode)

Parameters

alphaPen float

The alpha value for pen operations.

alphaBrush float

The alpha value for brush operations.

blendMode PdfBlendMode

The blend mode.

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Set transparancy.
graphics.SetTransparency(0.5f, 0.5f, PdfBlendMode.HardLight);
//Draws the String.
graphics.DrawString("Hello world!", font, PdfPens.Black, PdfBrushes.Red, 0, 0);        
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Set transparancy.
graphics.SetTransparency(0.5F, 0.5F, PdfBlendMode.HardLight)
'Draws the String.
graphics.DrawString("Hello world!", font, PdfPens.Black, PdfBrueshes.Red, 0, 0)        
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)

SkewTransform(float, float)

Skews the coordinate system axes.

public void SkewTransform(float angleX, float angleY)

Parameters

angleX float

Skews the X axis by this angle (in degrees).

angleY float

Skews the Y axis by this angle (in degrees).

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Save the graphics.
graphics.Save();
//Set skew transform
graphics.SkewTransform(10,10);                
//Draws the String.
graphics.DrawString("Hello world!", font, PdfPens.Red, 0, 0);
//Restore the graphics.
graphics.Restore();
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Save the graphics.
graphics.Save()
'Set skew transform
graphics.SkewTransform(10, 10)
'Draws the String.
graphics.DrawString("Hello world!", font, PdfPens.Red, 0, 0)
'Restore the graphics.
graphics.Restore()
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)

TranslateTransform(float, float)

Changes the origin of the coordinate system by prepending the specified translation to the transformation matrix of this Graphics.

public void TranslateTransform(float offsetX, float offsetY)

Parameters

offsetX float

The x-coordinate of the translation.

offsetY float

The y-coordinate of the translation.

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Save the graphics.
graphics.Save();
//Set graphics translate transform.
graphics.TranslateTransform(100, 100);            
//Draws the String.
graphics.DrawString("Hello world!", font, PdfPens.Red, 0, 0);
//Restore the graphics.
graphics.Restore();
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Save the graphics.
graphics.Save()
'Set graphics translate transform.
graphics.TranslateTransform(100, 100)
'Draws the String.
graphics.DrawString("Hello world!", font, PdfPens.Red, 0, 0)
'Restore the graphics.
graphics.Restore()
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)