Class PdfGraphics
Represents a graphics context of the objects. It's used for performing all the graphics operations.
Inheritance
Namespace: Syncfusion.Pdf.Graphics
Assembly: Syncfusion.Pdf.UWP.dll
Syntax
public sealed class PdfGraphics : Object
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.
Declaration
public SizeF ClientSize { get; }
Property Value
Type |
---|
System.Drawing.SizeF |
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.
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)
ColorSpace
Gets or sets the current color space of the document
Declaration
public PdfColorSpace ColorSpace { get; set; }
Property Value
Type |
---|
PdfColorSpace |
Remarks
The value change of this property has impact on the objects which will be drawn after the change.
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)
Size
Gets the size of the canvas.
Declaration
public SizeF Size { get; }
Property Value
Type |
---|
System.Drawing.SizeF |
Remarks
Usually, this value is equal to the size of the object this graphics belongs to.
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)
Methods
DrawArc(PdfPen, RectangleF, Single, Single)
Draws an arc representing a portion of an ellipse specified by a Rectangle structure.
Declaration
public void DrawArc(PdfPen pen, RectangleF rectangle, float startAngle, float sweepAngle)
Parameters
Type | Name | Description |
---|---|---|
PdfPen | pen | Pen that determines the color, width, and style of the arc. |
System.Drawing.RectangleF | rectangle | RectangleF structure that defines the boundaries of the ellipse. |
System.Single | startAngle | Angle in degrees measured clockwise from the x-axis to the starting point of the arc. |
System.Single | sweepAngle | 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, Single, Single, Single, Single, Single, Single)
Draws an arc representing a portion of an ellipse specified by a pair of coordinates, a width, and a height.
Declaration
public void DrawArc(PdfPen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
Parameters
Type | Name | Description |
---|---|---|
PdfPen | pen | Pen that determines the color, width, and style of the arc. |
System.Single | x | The x-coordinate of the upper-left corner of the rectangle that defines the ellipse. |
System.Single | y | The y-coordinate of the upper-left corner of the rectangle that defines the ellipse. |
System.Single | width | Width of the rectangle that defines the ellipse. |
System.Single | height | Height of the rectangle that defines the ellipse. |
System.Single | startAngle | Angle in degrees measured clockwise from the x-axis to the starting point of the arc. |
System.Single | sweepAngle | 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.
Declaration
public void DrawBezier(PdfPen pen, PointF startPoint, PointF firstControlPoint, PointF secondControlPoint, PointF endPoint)
Parameters
Type | Name | Description |
---|---|---|
PdfPen | pen | Pen structure that determines the color, width, and style of the curve. |
System.Drawing.PointF | startPoint | Point structure that represents the starting point of the curve. |
System.Drawing.PointF | firstControlPoint | Point structure that represents the first control point for the curve. |
System.Drawing.PointF | secondControlPoint | Point structure that represents the second control point for the curve. |
System.Drawing.PointF | endPoint | 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, Single, Single, Single, Single, Single, Single, Single, Single)
Draws a Bezier spline defined by four ordered pairs of coordinates that represent points.
Declaration
public void DrawBezier(PdfPen pen, float startPointX, float startPointY, float firstControlPointX, float firstControlPointY, float secondControlPointX, float secondControlPointY, float endPointX, float endPointY)
Parameters
Type | Name | Description |
---|---|---|
PdfPen | pen | Pen structure that determines the color, width, and style of the curve. |
System.Single | startPointX | The x-coordinate of the starting point of the curve. |
System.Single | startPointY | The y-coordinate of the starting point of the curve. |
System.Single | firstControlPointX | The x-coordinate of the first control point of the curve. |
System.Single | firstControlPointY | The y-coordinate of the first control point of the curve. |
System.Single | secondControlPointX | The x-coordinate of the second control point of the curve. |
System.Single | secondControlPointY | The y-coordinate of the second control point of the curve. |
System.Single | endPointX | The x-coordinate of the ending point of the curve. |
System.Single | endPointY | 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.
Declaration
public void DrawEllipse(PdfBrush brush, RectangleF rectangle)
Parameters
Type | Name | Description |
---|---|---|
PdfBrush | brush | Brush that determines the color and texture of the ellipse. |
System.Drawing.RectangleF | rectangle | 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, Single, Single, Single, Single)
Draws an ellipse defined by a bounding rectangle specified by coordinates for the upper-left corner of the rectangle, a height, and a width.
Declaration
public void DrawEllipse(PdfBrush brush, float x, float y, float width, float height)
Parameters
Type | Name | Description |
---|---|---|
PdfBrush | brush | Brush that determines the color and texture of the ellipse. |
System.Single | x | The x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse. |
System.Single | y | The y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse. |
System.Single | width | Width of the bounding rectangle that defines the ellipse. |
System.Single | height | 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, PdfBrush, RectangleF)
Draws an ellipse specified by a bounding Rectangle structure.
Declaration
public void DrawEllipse(PdfPen pen, PdfBrush brush, RectangleF rectangle)
Parameters
Type | Name | Description |
---|---|---|
PdfPen | pen | Pen that determines the color, width, and style of the ellipse. |
PdfBrush | brush | Brush that determines the color and texture of the ellipse. |
System.Drawing.RectangleF | rectangle | 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, Single, Single, Single, Single)
Draws an ellipse specified by a pen, a brush and coordinates for the upper-left corner of the rectangle, a height, and a width.
Declaration
public void DrawEllipse(PdfPen pen, PdfBrush brush, float x, float y, float width, float height)
Parameters
Type | Name | Description |
---|---|---|
PdfPen | pen | Pen that determines the color, width, and style of the ellipse. |
PdfBrush | brush | Brush that determines the color and texture of the ellipse. |
System.Single | x | The x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse. |
System.Single | y | The y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse. |
System.Single | width | Width of the bounding rectangle that defines the ellipse. |
System.Single | height | 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, RectangleF)
Draws an ellipse specified by a pen, a bounding Rectangle structure.
Declaration
public void DrawEllipse(PdfPen pen, RectangleF rectangle)
Parameters
Type | Name | Description |
---|---|---|
PdfPen | pen | Pen that determines the color, width, and style of the ellipse. |
System.Drawing.RectangleF | rectangle | 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, Single, Single, Single, Single)
Draws an ellipse defined by a bounding rectangle specified by coordinates for the upper-left corner of the rectangle, a height, and a width.
Declaration
public void DrawEllipse(PdfPen pen, float x, float y, float width, float height)
Parameters
Type | Name | Description |
---|---|---|
PdfPen | pen | Pen that determines the color, width, and style of the ellipse. |
System.Single | x | The x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse. |
System.Single | y | The y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse. |
System.Single | width | Width of the bounding rectangle that defines the ellipse. |
System.Single | height | 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..
Declaration
public void DrawImage(PdfImage image, PointF point)
Parameters
Type | Name | Description |
---|---|---|
PdfImage | image | PdfImage to draw. |
System.Drawing.PointF | point | 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.
Declaration
public void DrawImage(PdfImage image, PointF point, SizeF size)
Parameters
Type | Name | Description |
---|---|---|
PdfImage | image | PdfImage to draw. |
System.Drawing.PointF | point | Point structure that represents the location of the upper-left corner of the drawn image. |
System.Drawing.SizeF | size | 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.
Declaration
public void DrawImage(PdfImage image, RectangleF rectangle)
Parameters
Type | Name | Description |
---|---|---|
PdfImage | image | PdfImage to draw. |
System.Drawing.RectangleF | rectangle | 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, Single, Single)
Draws the specified image, using its original physical size, at the location specified by a coordinate pair.
Declaration
public void DrawImage(PdfImage image, float x, float y)
Parameters
Type | Name | Description |
---|---|---|
PdfImage | image | PdfImage to draw. |
System.Single | x | The x-coordinate of the upper-left corner of the drawn image. |
System.Single | y | 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, Single, Single, Single, Single)
Draws the specified image, using its original physical size, at the location specified by a coordinate pair.
Declaration
public void DrawImage(PdfImage image, float x, float y, float width, float height)
Parameters
Type | Name | Description |
---|---|---|
PdfImage | image | PdfImage to draw. |
System.Single | x | The x-coordinate of the upper-left corner of the drawn image. |
System.Single | y | The y-coordinate of the upper-left corner of the drawn image. |
System.Single | width | Width of the drawn image. |
System.Single | height | 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 System.Drawing.PointF structures.
Declaration
public void DrawLine(PdfPen pen, PointF point1, PointF point2)
Parameters
Type | Name | Description |
---|---|---|
PdfPen | pen | Pen that determines the color, width, and style of the line. |
System.Drawing.PointF | point1 | PointF structure that represents the first point to connect. |
System.Drawing.PointF | point2 | 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, Single, Single, Single, Single)
Draws a line connecting the two points specified by the coordinate pairs.
Declaration
public void DrawLine(PdfPen pen, float x1, float y1, float x2, float y2)
Parameters
Type | Name | Description |
---|---|---|
PdfPen | pen | Pen that determines the color, width, and style of the line. |
System.Single | x1 | The x-coordinate of the first point. |
System.Single | y1 | The y-coordinate of the first point. |
System.Single | x2 | The x-coordinate of the second point. |
System.Single | y2 | 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
Declaration
public void DrawPath(PdfBrush brush, PdfPath path)
Parameters
Type | Name | Description |
---|---|---|
PdfBrush | brush | Brush that determines the color and texture of the path. |
PdfPath | path | 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
Declaration
public void DrawPath(PdfPen pen, PdfBrush brush, PdfPath path)
Parameters
Type | Name | Description |
---|---|---|
PdfPen | pen | Pen that determines the color, width, and style of the path. |
PdfBrush | brush | Brush that determines the color and texture of the path. |
PdfPath | path | 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
Declaration
public void DrawPath(PdfPen pen, PdfPath path)
Parameters
Type | Name | Description |
---|---|---|
PdfPen | pen | Pen that determines the color, width, and style of the path. |
PdfPath | path | 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.
Declaration
public void DrawPdfTemplate(PdfTemplate template, PointF location)
Parameters
Type | Name | Description |
---|---|---|
PdfTemplate | template | PdfTemplate object. |
System.Drawing.PointF | location | 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.
Declaration
public void DrawPdfTemplate(PdfTemplate template, PointF location, SizeF size)
Parameters
Type | Name | Description |
---|---|---|
PdfTemplate | template | PdfTemplate object. |
System.Drawing.PointF | location | PointF structure that specifies the upper-left corner of the drawn template. |
System.Drawing.SizeF | size | 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, Single, Single)
Draws a pie shape defined by an ellipse specified by a Rectangle structure and two radial lines.
Declaration
public void DrawPie(PdfBrush brush, RectangleF rectangle, float startAngle, float sweepAngle)
Parameters
Type | Name | Description |
---|---|---|
PdfBrush | brush | Brush that determines the color and texture of the pie. |
System.Drawing.RectangleF | rectangle | Rectangle structure that represents the bounding rectangle that defines the ellipse from which the pie shape comes. |
System.Single | startAngle | Angle measured in degrees clockwise from the x-axis to the first side of the pie shape. |
System.Single | sweepAngle | 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, Single, Single, Single, Single, Single, Single)
Draws a pie shape defined by an ellipse specified by a coordinate pair, a width, a height, and two radial lines.
Declaration
public void DrawPie(PdfBrush brush, float x, float y, float width, float height, float startAngle, float sweepAngle)
Parameters
Type | Name | Description |
---|---|---|
PdfBrush | brush | Brush that determines the color and texture of the pie. |
System.Single | x | The x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie shape comes. |
System.Single | y | The y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie shape comes. |
System.Single | width | Width of the bounding rectangle that defines the ellipse from which the pie shape comes. |
System.Single | height | Height of the bounding rectangle that defines the ellipse from which the pie shape comes. |
System.Single | startAngle | Angle measured in degrees clockwise from the x-axis to the first side of the pie shape. |
System.Single | sweepAngle | 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, PdfBrush, RectangleF, Single, Single)
Draws a pie shape defined by an ellipse specified by a Rectangle structure and two radial lines.
Declaration
public void DrawPie(PdfPen pen, PdfBrush brush, RectangleF rectangle, float startAngle, float sweepAngle)
Parameters
Type | Name | Description |
---|---|---|
PdfPen | pen | Pen that determines the color, width, and style of the pie shape. |
PdfBrush | brush | Brush that determines the color and texture of the pie. |
System.Drawing.RectangleF | rectangle | Rectangle structure that represents the bounding rectangle that defines the ellipse from which the pie shape comes. |
System.Single | startAngle | Angle measured in degrees clockwise from the x-axis to the first side of the pie shape. |
System.Single | sweepAngle | 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, Single, Single, Single, Single, Single, Single)
Draws a pie shape defined by an ellipse specified by a Rectangle structure and two radial lines.
Declaration
public void DrawPie(PdfPen pen, PdfBrush brush, float x, float y, float width, float height, float startAngle, float sweepAngle)
Parameters
Type | Name | Description |
---|---|---|
PdfPen | pen | Pen that determines the color, width, and style of the pie shape. |
PdfBrush | brush | Brush that determines the color and texture of the pie. |
System.Single | x | The x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie shape comes. |
System.Single | y | The y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie shape comes. |
System.Single | width | Width of the bounding rectangle that defines the ellipse from which the pie shape comes. |
System.Single | height | Height of the bounding rectangle that defines the ellipse from which the pie shape comes. |
System.Single | startAngle | Angle measured in degrees clockwise from the x-axis to the first side of the pie shape. |
System.Single | sweepAngle | 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, RectangleF, Single, Single)
Draws a pie shape defined by an ellipse specified by a Rectangle structure and two radial lines.
Declaration
public void DrawPie(PdfPen pen, RectangleF rectangle, float startAngle, float sweepAngle)
Parameters
Type | Name | Description |
---|---|---|
PdfPen | pen | Pen that determines the color, width, and style of the pie shape. |
System.Drawing.RectangleF | rectangle | Rectangle structure that represents the bounding rectangle that defines the ellipse from which the pie shape comes. |
System.Single | startAngle | Angle measured in degrees clockwise from the x-axis to the first side of the pie shape. |
System.Single | sweepAngle | 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, Single, Single, Single, Single, Single, Single)
Draws a pie shape defined by an ellipse specified by a coordinate pair, a width, a height, and two radial lines.
Declaration
public void DrawPie(PdfPen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
Parameters
Type | Name | Description |
---|---|---|
PdfPen | pen | Pen that determines the color, width, and style of the pie shape. |
System.Single | x | The x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie shape comes. |
System.Single | y | The y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie shape comes. |
System.Single | width | Width of the bounding rectangle that defines the ellipse from which the pie shape comes. |
System.Single | height | Height of the bounding rectangle that defines the ellipse from which the pie shape comes. |
System.Single | startAngle | Angle measured in degrees clockwise from the x-axis to the first side of the pie shape. |
System.Single | sweepAngle | 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.
Declaration
public void DrawPolygon(PdfBrush brush, PointF[] points)
Parameters
Type | Name | Description |
---|---|---|
PdfBrush | brush | Brush that determines the color and texture of the pie. |
System.Drawing.PointF[] | points | 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, PdfBrush, PointF[])
Draws a polygon defined by a pen, a brush, an array of Point structures.
Declaration
public void DrawPolygon(PdfPen pen, PdfBrush brush, PointF[] points)
Parameters
Type | Name | Description |
---|---|---|
PdfPen | pen | Pen that determines the color, width, and style of the polygon. |
PdfBrush | brush | Brush that determines the color and texture of the pie. |
System.Drawing.PointF[] | points | 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()
DrawPolygon(PdfPen, PointF[])
Draws a polygon defined by a pen, an array of Point structures.
Declaration
public void DrawPolygon(PdfPen pen, PointF[] points)
Parameters
Type | Name | Description |
---|---|---|
PdfPen | pen | Pen that determines the color, width, and style of the polygon. |
System.Drawing.PointF[] | points | 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()
DrawRectangle(PdfBrush, RectangleF)
Draws a rectangle specified by a Rectangle structure.
Declaration
public void DrawRectangle(PdfBrush brush, RectangleF rectangle)
Parameters
Type | Name | Description |
---|---|---|
PdfBrush | brush | Brush that determines the color and texture of the rectangle. |
System.Drawing.RectangleF | rectangle | 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, Single, Single, Single, Single)
Draws a rectangle specified by a brush, coordinate pair, a width, and a height.
Declaration
public void DrawRectangle(PdfBrush brush, float x, float y, float width, float height)
Parameters
Type | Name | Description |
---|---|---|
PdfBrush | brush | Brush that determines the color and texture of the rectangle. |
System.Single | x | The x-coordinate of the upper-left corner of the rectangle to draw. |
System.Single | y | The y-coordinate of the upper-left corner of the rectangle to draw. |
System.Single | width | Width of the rectangle to draw. |
System.Single | height | 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, PdfBrush, RectangleF)
Draws a rectangle specified by a pen, a brush and a Rectangle structure.
Declaration
public void DrawRectangle(PdfPen pen, PdfBrush brush, RectangleF rectangle)
Parameters
Type | Name | Description |
---|---|---|
PdfPen | pen | A Pen that determines the color, width, and style of the rectangle. |
PdfBrush | brush | Brush that determines the color and texture of the rectangle. |
System.Drawing.RectangleF | rectangle | 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, Single, Single, Single, Single)
Draws a rectangle specified by a pen, a coordinate pair, a width, and a height.
Declaration
public void DrawRectangle(PdfPen pen, PdfBrush brush, float x, float y, float width, float height)
Parameters
Type | Name | Description |
---|---|---|
PdfPen | pen | A Pen that determines the color, width, and style of the rectangle. |
PdfBrush | brush | Brush that determines the color and texture of the rectangle. |
System.Single | x | The x-coordinate of the upper-left corner of the rectangle to draw. |
System.Single | y | The y-coordinate of the upper-left corner of the rectangle to draw. |
System.Single | width | Width of the rectangle to draw. |
System.Single | height | 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, RectangleF)
Draws a rectangle specified by a pen, a Rectangle structure.
Declaration
public void DrawRectangle(PdfPen pen, RectangleF rectangle)
Parameters
Type | Name | Description |
---|---|---|
PdfPen | pen | A Pen that determines the color, width, and style of the rectangle. |
System.Drawing.RectangleF | rectangle | 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, Single, Single, Single, Single)
Draws a rectangle specified by a pen, a coordinate pair, a width, and a height.
Declaration
public void DrawRectangle(PdfPen pen, float x, float y, float width, float height)
Parameters
Type | Name | Description |
---|---|---|
PdfPen | pen | A Pen that determines the color, width, and style of the rectangle. |
System.Single | x | The x-coordinate of the upper-left corner of the rectangle to draw. |
System.Single | y | The y-coordinate of the upper-left corner of the rectangle to draw. |
System.Single | width | Width of the rectangle to draw. |
System.Single | height | 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.
Declaration
public void DrawString(string s, PdfFont font, PdfBrush brush, PointF point)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | String to draw. |
PdfFont | font | Font that defines the text format of the string. |
PdfBrush | brush | Brush that determines the color and texture of the drawn text. |
System.Drawing.PointF | point | 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.
Declaration
public void DrawString(string s, PdfFont font, PdfBrush brush, PointF point, PdfStringFormat format)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | String to draw. |
PdfFont | font | Font that defines the text format of the string. |
PdfBrush | brush | Brush that determines the color and texture of the drawn text. |
System.Drawing.PointF | point | PointF structure that specifies the upper-left corner of the drawn text. |
PdfStringFormat | format | 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.
Declaration
public void DrawString(string s, PdfFont font, PdfBrush brush, RectangleF layoutRectangle)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | The text string. |
PdfFont | font | Font that defines the text format of the string. |
PdfBrush | brush | Brush that determines the color and texture of the drawn text. |
System.Drawing.RectangleF | layoutRectangle | 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.
Declaration
public void DrawString(string s, PdfFont font, PdfBrush brush, RectangleF layoutRectangle, PdfStringFormat format)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | String to draw. |
PdfFont | font | Font that defines the text format of the string. |
PdfBrush | brush | Brush that determines the color and texture of the drawn text. |
System.Drawing.RectangleF | layoutRectangle | RectangleF structure that specifies the bounds of the drawn text. |
PdfStringFormat | format | 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, Single, Single)
Draws the specified text string at the specified location with the specified Brush and Font objects.
Declaration
public void DrawString(string s, PdfFont font, PdfBrush brush, float x, float y)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | String to draw. |
PdfFont | font | Font that defines the text format of the string. |
PdfBrush | brush | Brush that determines the color and texture of the drawn text. |
System.Single | x | The x. |
System.Single | y | 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, Single, Single, PdfStringFormat)
Draws the specified text string at the specified location with the specified Brush and Font objects.
Declaration
public void DrawString(string s, PdfFont font, PdfBrush brush, float x, float y, PdfStringFormat format)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | String to draw. |
PdfFont | font | Font that defines the text format of the string. |
PdfBrush | brush | Brush that determines the color and texture of the drawn text. |
System.Single | x | The x-coordinate of the upper-left corner of the drawn text. |
System.Single | y | The y-coordinate of the upper-left corner of the drawn text. |
PdfStringFormat | format | 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, PdfBrush, PointF)
Draws the specified text string at the specified location with the specified Brush and Font objects.
Declaration
public void DrawString(string s, PdfFont font, PdfPen pen, PdfBrush brush, PointF point)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | String to draw. |
PdfFont | font | Font that defines the text format of the string. |
PdfPen | pen | Pen that determines the color, width, and style of the path. |
PdfBrush | brush | Brush that determines the color and texture of the drawn text. |
System.Drawing.PointF | point | 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.
Declaration
public void DrawString(string s, PdfFont font, PdfPen pen, PdfBrush brush, PointF point, PdfStringFormat format)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | String to draw. |
PdfFont | font | Font that defines the text format of the string. |
PdfPen | pen | Pen that determines the color, width, and style of the path. |
PdfBrush | brush | Brush that determines the color and texture of the drawn text. |
System.Drawing.PointF | point | PointF structure that specifies the upper-left corner of the drawn text. |
PdfStringFormat | format | 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.
Declaration
public void DrawString(string s, PdfFont font, PdfPen pen, PdfBrush brush, RectangleF layoutRectangle, PdfStringFormat format)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | String to draw. |
PdfFont | font | Font that defines the text format of the string. |
PdfPen | pen | Pen that determines the color, width, and style of the path. |
PdfBrush | brush | The brush. |
System.Drawing.RectangleF | layoutRectangle | RectangleF structure that specifies the bounds of the drawn text. |
PdfStringFormat | format | 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, Single, Single)
Draws the specified text string at the specified location with the specified Brush and Font objects.
Declaration
public void DrawString(string s, PdfFont font, PdfPen pen, PdfBrush brush, float x, float y)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | The text string. |
PdfFont | font | Font that defines the text format of the string. |
PdfPen | pen | Pen that determines the color, width, and style of the path. |
PdfBrush | brush | Brush that determines the color and texture of the drawn text. |
System.Single | x | The x-coordinate of the upper-left corner of the drawn text. |
System.Single | y | 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, Single, Single, PdfStringFormat)
Draws the specified text string at the specified location with the specified Brush and Font objects.
Declaration
public void DrawString(string s, PdfFont font, PdfPen pen, PdfBrush brush, float x, float y, PdfStringFormat format)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | The text string. |
PdfFont | font | Font that defines the text format of the string. |
PdfPen | pen | Pen that determines the color, width, and style of the path. |
PdfBrush | brush | Brush that determines the color and texture of the drawn text. |
System.Single | x | The x-coordinate of the upper-left corner of the drawn text. |
System.Single | y | The y-coordinate of the upper-left corner of the drawn text. |
PdfStringFormat | format | 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, PointF)
Draws the specified text string at the specified location with the specified Brush and Font objects.
Declaration
public void DrawString(string s, PdfFont font, PdfPen pen, PointF point)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | String to draw. |
PdfFont | font | Font that defines the text format of the string. |
PdfPen | pen | Pen that determines the color, width, and style of the path. |
System.Drawing.PointF | point | 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.
Declaration
public void DrawString(string s, PdfFont font, PdfPen pen, PointF point, PdfStringFormat format)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | String to draw. |
PdfFont | font | Font that defines the text format of the string. |
PdfPen | pen | Pen that determines the color, width, and style of the path. |
System.Drawing.PointF | point | PointF structure that specifies the upper-left corner of the drawn text. |
PdfStringFormat | format | 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.
Declaration
public void DrawString(string s, PdfFont font, PdfPen pen, RectangleF layoutRectangle)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | String to draw. |
PdfFont | font | Font that defines the text format of the string. |
PdfPen | pen | Pen that determines the color, width, and style of the path. |
System.Drawing.RectangleF | layoutRectangle | 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.
Declaration
public void DrawString(string s, PdfFont font, PdfPen pen, RectangleF layoutRectangle, PdfStringFormat format)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | String to draw. |
PdfFont | font | Font that defines the text format of the string. |
PdfPen | pen | Pen that determines the color, width, and style of the path. |
System.Drawing.RectangleF | layoutRectangle | RectangleF structure that specifies the bounds of the drawn text. |
PdfStringFormat | format | 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, Single, Single)
Draws the specified text string at the specified location with the specified Brush and Font objects.
Declaration
public void DrawString(string s, PdfFont font, PdfPen pen, float x, float y)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | String to draw. |
PdfFont | font | Font that defines the text format of the string. |
PdfPen | pen | Pen that determines the color, width, and style of the path. |
System.Single | x | The x-coordinate of the upper-left corner of the drawn text. |
System.Single | y | 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, Single, Single, PdfStringFormat)
Draws the specified text string at the specified location with the specified Brush and Font objects.
Declaration
public void DrawString(string s, PdfFont font, PdfPen pen, float x, float y, PdfStringFormat format)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | String to draw. |
PdfFont | font | Font that defines the text format of the string.. |
PdfPen | pen | Pen that determines the color, width, and style of the path. |
System.Single | x | The x-coordinate of the upper-left corner of the drawn text. |
System.Single | y | The y-coordinate of the upper-left corner of the drawn text. |
PdfStringFormat | format | 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.
Declaration
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.
Declaration
protected void OnStructElementChanged(PdfTag tag)
Parameters
Type | Name | Description |
---|---|---|
PdfTag | tag |
Restore()
Restores the state of this Graphics to the state represented by a GraphicsState.
Declaration
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.
Declaration
public void Restore(PdfGraphicsState state)
Parameters
Type | Name | Description |
---|---|---|
PdfGraphicsState | state | GraphicsState that represents the state to which to restore this Graphics. |
Remarks
This method works similar to
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)
RotateTransform(Single)
Applies the specified rotation to the transformation matrix of this Graphics.
Declaration
public void RotateTransform(float angle)
Parameters
Type | Name | Description |
---|---|---|
System.Single | angle | 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.
Declaration
public PdfGraphicsState Save()
Returns
Type | Description |
---|---|
PdfGraphicsState | This method returns a GraphicsState that represents the saved state of this Graphics. |
Remarks
This method works similar to
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)
ScaleTransform(Single, Single)
Applies the specified scaling operation to the transformation matrix of this Graphics by prepending it to the object's transformation matrix.
Declaration
public void ScaleTransform(float scaleX, float scaleY)
Parameters
Type | Name | Description |
---|---|---|
System.Single | scaleX | Scale factor in the x direction. |
System.Single | scaleY | 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(PdfPath)
Sets the clipping region of this Graphics to the result of the specified operation combining the current clip region and the specified PdfPath.
Declaration
public void SetClip(PdfPath path)
Parameters
Type | Name | Description |
---|---|---|
PdfPath | path | 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.
Declaration
public void SetClip(PdfPath path, PdfFillMode mode)
Parameters
Type | Name | Description |
---|---|---|
PdfPath | path | PdfPath to fill. |
PdfFillMode | mode | 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)
SetClip(RectangleF)
Sets the clipping region of this Graphics to the rectangle specified by a RectangleF structure.
Declaration
public void SetClip(RectangleF rectangle)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.RectangleF | rectangle | 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.
Declaration
public void SetClip(RectangleF rectangle, PdfFillMode mode)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.RectangleF | rectangle | RectangleF structure to combine. |
PdfFillMode | mode | 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)
SetTransparency(Single)
Sets the transparency of this Graphics with the specified value for pen
Declaration
public void SetTransparency(float alpha)
Parameters
Type | Name | Description |
---|---|---|
System.Single | alpha | 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(Single, Single)
Sets the transparency of this Graphics with the specified value for pen and brush
Declaration
public void SetTransparency(float alphaPen, float alphaBrush)
Parameters
Type | Name | Description |
---|---|---|
System.Single | alphaPen | The alpha value for pen operations. |
System.Single | alphaBrush | 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(Single, Single, PdfBlendMode)
Sets the transparency of this Graphics with the specified PdfBlendMode
Declaration
public void SetTransparency(float alphaPen, float alphaBrush, PdfBlendMode blendMode)
Parameters
Type | Name | Description |
---|---|---|
System.Single | alphaPen | The alpha value for pen operations. |
System.Single | alphaBrush | The alpha value for brush operations. |
PdfBlendMode | blendMode | 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(Single, Single)
Skews the coordinate system axes.
Declaration
public void SkewTransform(float angleX, float angleY)
Parameters
Type | Name | Description |
---|---|---|
System.Single | angleX | Skews the X axis by this angle (in degrees). |
System.Single | angleY | 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(Single, Single)
Changes the origin of the coordinate system by prepending the specified translation to the transformation matrix of this Graphics.
Declaration
public void TranslateTransform(float offsetX, float offsetY)
Parameters
Type | Name | Description |
---|---|---|
System.Single | offsetX | The x-coordinate of the translation. |
System.Single | offsetY | 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)