Class PdfPen
A class defining settings for drawing operations, that determines the color, width, and style of the drawing elements.
Inheritance
Implements
Namespace: Syncfusion.Pdf.Graphics
Assembly: Syncfusion.Pdf.Portable.dll
Syntax
public class PdfPen : Object, ICloneable
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create new PDF pen instance.
PdfPen pen = new PdfPen(Color.Red);
//Draw rectangle.
graphics.DrawRectangle(pen, new RectangleF(10, 10, 200, 100));
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create new PDF pen instance.
Dim pen As New PdfPen(Color.Red)
'Draw rectangle.
graphics.DrawRectangle(pen, New RectangleF(10, 10, 200, 100))
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)
Constructors
PdfPen(Color)
Initializes a new instance of the PdfPen class.
Declaration
public PdfPen(Color color)
Parameters
Type | Name | Description |
---|---|---|
Color | color | The system color. |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create new PDF pen instance.
PdfPen pen = new PdfPen(Color.Red);
//Draw rectangle.
graphics.DrawRectangle(pen, new RectangleF(10, 10, 200, 100));
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create new PDF pen instance.
Dim pen As New PdfPen(Color.Red)
'Draw rectangle.
graphics.DrawRectangle(pen, New RectangleF(10, 10, 200, 100))
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)
PdfPen(Color, Single)
Initializes a new instance of the PdfPen class with color and width of the pen
Declaration
public PdfPen(Color color, float width)
Parameters
Type | Name | Description |
---|---|---|
Color | color | The Color provides color to the pen. |
System.Single | width | Width of the pen's line. |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create new PDF pen instance.
PdfPen pen = new PdfPen(Color.Red, 2);
//Draw rectangle.
graphics.DrawRectangle(pen, new RectangleF(10, 10, 200, 100));
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create new PDF pen instance.
Dim pen As New PdfPen(Color.Red, 2)
'Draw rectangle.
graphics.DrawRectangle(pen, New RectangleF(10, 10, 200, 100))
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)
PdfPen(PdfExtendedColor)
Initializes a new instance of the PdfPen class with color.
Declaration
public PdfPen(PdfExtendedColor color)
Parameters
Type | Name | Description |
---|---|---|
PdfExtendedColor | color | The PdfColor provides color to the pen. |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
// Create Gray ColorSpace
PdfCalGrayColorSpace calGrayCS = new PdfCalGrayColorSpace();
// Create new instance for PdfCalGrayColor
PdfCalGrayColor gray = new PdfCalGrayColor(calGrayCS);
gray.Gray = 0.2;
//Create new PDF pen instance.
PdfPen pen = new PdfPen(gray);
//Draw rectangle.
graphics.DrawRectangle(pen, new RectangleF(10, 10, 200, 100));
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
' Create Gray ColorSpace
Dim calGrayCS As New PdfCalGrayColorSpace()
' Create new instance for PdfCalGrayColor
Dim gray As New PdfCalGrayColor(calGrayCS)
gray.Gray = 0.2
'Create new PDF pen instance.
Dim pen As New PdfPen(gray)
'Draw rectangle.
graphics.DrawRectangle(pen, New RectangleF(10, 10, 200, 100))
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)
PdfPen(PdfBrush)
Initializes a new instance of the PdfPen class with PdfBrush
Declaration
public PdfPen(PdfBrush brush)
Parameters
Type | Name | Description |
---|---|---|
PdfBrush | brush | The PdfBrush provides color and texture to the pen. |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create new PDF pen instance.
PdfPen pen = new PdfPen(new PdfSolidBrush(Color.Red));
//Draw rectangle.
graphics.DrawRectangle(pen, new RectangleF(10, 10, 200, 100));
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create new PDF pen instance.
Dim pen As New PdfPen(New PdfSolidBrush(Color.Red))
'Draw rectangle.
graphics.DrawRectangle(pen, New RectangleF(10, 10, 200, 100))
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)
PdfPen(PdfBrush, Single)
Initializes a new instance of the PdfPen class with PdfBrush and width.
Declaration
public PdfPen(PdfBrush brush, float width)
Parameters
Type | Name | Description |
---|---|---|
PdfBrush | brush | The PdfBrush provides color and texture to the pen. |
System.Single | width | Width of the pen's line. |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create new PDF pen instance.
PdfPen pen = new PdfPen(new PdfSolidBrush(Color.Red), 2);
//Draw rectangle.
graphics.DrawRectangle(pen, new RectangleF(10, 10, 200, 100));
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create new PDF pen instance.
Dim pen As New PdfPen(New PdfSolidBrush(Color.Red), 2)
'Draw rectangle.
graphics.DrawRectangle(pen, New RectangleF(10, 10, 200, 100))
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)
PdfPen(PdfColor)
Initializes a new instance of the PdfPen class.
Declaration
public PdfPen(PdfColor color)
Parameters
Type | Name | Description |
---|---|---|
PdfColor | color | The color. |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create new PDF pen instance.
PdfPen pen = new PdfPen(new PdfColor(Color.Red));
//Draw rectangle.
graphics.DrawRectangle(pen, new RectangleF(10, 10, 200, 100));
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create new PDF pen instance.
Dim pen As New PdfPen(New PdfColor(Color.Red))
'Draw rectangle.
graphics.DrawRectangle(pen, New RectangleF(10, 10, 200, 100))
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)
PdfPen(PdfColor, Single)
Initializes a new instance of the PdfPen class with color and width of the pen
Declaration
public PdfPen(PdfColor color, float width)
Parameters
Type | Name | Description |
---|---|---|
PdfColor | color | The PdfColor provides color to the pen. |
System.Single | width | Width of the pen's line. |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create new PDF pen instance.
PdfPen pen = new PdfPen(new PdfColor(Color.Red), 2);
//Draw rectangle.
graphics.DrawRectangle(pen, new RectangleF(10, 10, 200, 100));
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create new PDF pen instance.
Dim pen As New PdfPen(New PdfColor(Color.Red), 2)
'Draw rectangle.
graphics.DrawRectangle(pen, New RectangleF(10, 10, 200, 100))
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)
Properties
Brush
Gets or sets the brush, which specifies the pen behavior.
Declaration
public PdfBrush Brush { get; set; }
Property Value
Type | Description |
---|---|
PdfBrush | The PdfBrush that determines the color and texture |
Remarks
If the brush is set, the color values are ignored, except for PdfSolidBrush.
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create new PDF pen instance.
PdfPen pen = new PdfPen(Color.Red);
//Set brush.
pen.Brush = new PdfSolidBrush(Color.Green);
//Draw rectangle.
graphics.DrawRectangle(pen, new RectangleF(10, 10, 200, 100));
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create new PDF pen instance.
Dim pen As New PdfPen(Color.Red)
'Set brush.
pen.Brush = New PdfSolidBrush(Color.Green)
'Draw rectangle.
graphics.DrawRectangle(pen, New RectangleF(10, 10, 200, 100))
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)
Color
Gets or sets the color of the pen.
Declaration
public PdfColor Color { get; set; }
Property Value
Type | Description |
---|---|
PdfColor | The PdfColor provide the color to pen |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create new PDF pen instance.
PdfPen pen = new PdfPen(Color.Red);
//Set pen color.
pen.Color = new PdfColor(Color.Green);
//Draw rectangle.
graphics.DrawRectangle(pen, new RectangleF(10, 10, 200, 100));
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create new PDF pen instance.
Dim pen As New PdfPen(Color.Red)
'Set pen color.
pen.Color = New PdfColor(Color.Green)
'Draw rectangle.
graphics.DrawRectangle(pen, New RectangleF(10, 10, 200, 100))
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)
DashOffset
Gets or sets the dash offset of the pen.
Declaration
public float DashOffset { get; set; }
Property Value
Type |
---|
System.Single |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create new PDF pen instance.
PdfPen pen = new PdfPen(Color.Red);
//Set pen dash offset.
pen.DashOffset = 0.5f;
//Draw rectangle.
graphics.DrawRectangle(pen, new RectangleF(10, 10, 200, 100));
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create new PDF pen instance.
Dim pen As New PdfPen(Color.Red)
'Set pen dash offset.
pen.DashOffset = 0.5F
'Draw rectangle.
graphics.DrawRectangle(pen, New RectangleF(10, 10, 200, 100))
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)
DashPattern
Gets or sets the dash pattern of the pen.
Declaration
public float[] DashPattern { get; set; }
Property Value
Type |
---|
System.Single[] |
Remarks
we can't set the Dash pattern for solid dash style
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create new PDF pen instance.
PdfPen pen = new PdfPen(Color.Red);
//Set custom dash style.
pen.DashStyle = PdfDashStyle.Custom;
// Create a custom dash pattern.
pen.DashPattern = new float[] { 4.0f, 2.0f, 1.0f, 3.0f }
//Draw rectangle.
graphics.DrawRectangle(pen, new RectangleF(10, 10, 200, 100));
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create new PDF pen instance.
Dim pen As New PdfPen(Color.Red)
'Set custom dash style.
pen.DashStyle = PdfDashStyle.Custom
'Create a custom dash pattern.
pen.DashPattern = New Single() { 4.0F, 2.0F, 1.0F, 3.0F}
'Draw rectangle.
graphics.DrawRectangle(pen, New RectangleF(10, 10, 200, 100))
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)
DashStyle
Gets or sets the dash style of the pen.
Declaration
public PdfDashStyle DashStyle { get; set; }
Property Value
Type | Description |
---|---|
PdfDashStyle | The PdfDashStyle provides the various dash styles |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create new PDF pen instance.
PdfPen pen = new PdfPen(Color.Red);
//Set custom dash style.
pen.DashStyle = PdfDashStyle.Custom;
// Create a custom dash pattern.
pen.DashPattern = new float[] { 4.0f, 2.0f, 1.0f, 3.0f }
//Draw rectangle.
graphics.DrawRectangle(pen, new RectangleF(10, 10, 200, 100));
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create new PDF pen instance.
Dim pen As New PdfPen(Color.Red)
'Set custom dash style.
pen.DashStyle = PdfDashStyle.Custom
'Create a custom dash pattern.
pen.DashPattern = New Single() { 4.0F, 2.0F, 1.0F, 3.0F}
'Draw rectangle.
graphics.DrawRectangle(pen, New RectangleF(10, 10, 200, 100))
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)
LineCap
Gets or sets the line cap of the pen.
Declaration
public PdfLineCap LineCap { get; set; }
Property Value
Type | Description |
---|---|
PdfLineCap | The PdfLineCap gives various line cap options |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create new PDF pen instance.
PdfPen pen = new PdfPen(Color.Red);
//Set custom dash style.
pen.DashStyle = PdfDashStyle.Custom;
//Set line cap.
pen.LineCap = PdfLineCap.Round;
// Create a custom dash pattern.
pen.DashPattern = new float[] { 4.0f, 2.0f, 1.0f, 3.0f }
//Draw rectangle.
graphics.DrawRectangle(pen, new RectangleF(10, 10, 200, 100));
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create new PDF pen instance.
Dim pen As New PdfPen(Color.Red)
'Set custom dash style.
pen.DashStyle = PdfDashStyle.Custom
'Create a custom dash pattern.
'Set line cap.
pen.LineCap = PdfLineCap.Round
pen.DashPattern = New Single() { 4.0F, 2.0F, 1.0F, 3.0F}
'Draw rectangle.
graphics.DrawRectangle(pen, New RectangleF(10, 10, 200, 100))
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)
LineJoin
Gets or sets the line join style of the pen.
Declaration
public PdfLineJoin LineJoin { get; set; }
Property Value
Type | Description |
---|---|
PdfLineJoin | The PdfLineJoin provides various line join options. |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create new PDF pen instance.
PdfPen pen = new PdfPen(Color.Red);
//Set custom dash style.
pen.DashStyle = PdfDashStyle.Custom;
//Set line jion.
pen.LineJoin = PdfLineJoin.Bevel;
// Create a custom dash pattern.
pen.DashPattern = new float[] { 4.0f, 2.0f, 1.0f, 3.0f }
//Draw rectangle.
graphics.DrawRectangle(pen, new RectangleF(10, 10, 200, 100));
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create new PDF pen instance.
Dim pen As New PdfPen(Color.Red)
'Set custom dash style.
pen.DashStyle = PdfDashStyle.Custom
'Set line jion.
pen.LineJoin = PdfLineJoin.Bevel
'Create a custom dash pattern.
pen.DashPattern = New Single() { 4.0F, 2.0F, 1.0F, 3.0F}
'Draw rectangle.
graphics.DrawRectangle(pen, New RectangleF(10, 10, 200, 100))
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)
MiterLimit
Gets or sets the miter limit.
Declaration
public float MiterLimit { get; set; }
Property Value
Type |
---|
System.Single |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create new PDF pen instance.
PdfPen pen = new PdfPen(Color.Red);
//Set pen width.
pen.Width = 4;
//Set miter limit,
pen.MiterLimit = 2;
//Draw rectangle.
graphics.DrawRectangle(pen, new RectangleF(10, 10, 200, 100));
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create new PDF pen instance.
Dim pen As New PdfPen(Color.Red)
'Set pen width.
pen.Width = 4
'Set miter limit,
pen.MiterLimit = 2
'Draw rectangle.
graphics.DrawRectangle(pen, New RectangleF(10, 10, 200, 100))
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)
Width
Gets or sets the width of the pen.
Declaration
public float Width { get; set; }
Property Value
Type |
---|
System.Single |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create new PDF pen instance.
PdfPen pen = new PdfPen(Color.Red);
//Set pen width.
pen.Width = 4;
//Draw rectangle.
graphics.DrawRectangle(pen, new RectangleF(10, 10, 200, 100));
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create new PDF pen instance.
Dim pen As New PdfPen(Color.Red)
'Set pen width.
pen.Width = 4
'Draw rectangle.
graphics.DrawRectangle(pen, New RectangleF(10, 10, 200, 100))
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)
Methods
Clone()
Clones this instance.
Declaration
public PdfPen Clone()
Returns
Type | Description |
---|---|
PdfPen | A new pen with the same properties. |
Examples
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create new PDF pen instance.
PdfPen pen = new PdfPen(Color.Red);
//Draw rectangle.
graphics.DrawRectangle(pen, new RectangleF(10, 10, 200, 100));
//Clone the PDF pen.
PdfPen pen1 = pen.Clone();
pen1.Width = 10;
graphics.DrawRectangle(pen1, new RectangleF(10, 120, 200, 100));
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create new PDF pen instance.
Dim pen As New PdfPen(Color.Red)
'Draw rectangle.
graphics.DrawRectangle(pen, New RectangleF(10, 10, 200, 100))
'Clone the PDF pen.
Dim pen1 As PdfPen = pen.Clone()
pen1.Width = 10
graphics.DrawRectangle(pen1, New RectangleF(10, 120, 200, 100))
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)
Explicit Interface Implementations
ICloneable.Clone()
Creates a new object that is a copy of the current instance.
Declaration
object ICloneable.Clone()
Returns
Type | Description |
---|---|
System.Object | A new object that is a copy of this instance. |