Table of Contents

Class PdfLine

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

Represents a line shape.

public class PdfLine : PdfDrawElement
Inheritance
PdfLine
Inherited Members

Examples

//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a new PDF page.
PdfPage page = document.Pages.Add();
//Create new PdfLine instance.
PdfLine line = new PdfLine(new PointF(0, 0), new PointF(100, 0));
//Draw the line to PDF page.
line.Draw(page, PointF.Empty);
//Save the PDF docment.
document.Save("output.pdf");
//Close the PDF document.
document.Close(true);
'Create a new PDF document.
 Dim document As New PdfDocument()
 'Add a new PDF page.
 Dim page As PdfPage = document.Pages.Add()
 'Create new PdfLine instance.
 Dim line As New PdfLine(New PointF(0, 0), New PointF(100, 0))
 'Draw the line to PDF page.
 line.Draw(page, PointF.Empty)
 'Save the PDF docment.
 document.Save("output.pdf")
 'Close the PDF document.
 document.Close(True)

Constructors

PdfLine(PointF, PointF)

Initializes a new instance of the PdfLine class.

public PdfLine(PointF point1, PointF point2)

Parameters

point1 PointF

The line start point.

point2 PointF

The line end point.

Examples

//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a new PDF page.
PdfPage page = document.Pages.Add();
//Create new PdfLine instance.
PdfLine line = new PdfLine(new PointF(0, 0), new PointF(100, 0));
//Draw the line to PDF page.
line.Draw(page, PointF.Empty);
//Save the PDF docment.
document.Save("output.pdf");
//Close the PDF document.
document.Close(true);
'Create a new PDF document.
 Dim document As New PdfDocument()
 'Add a new PDF page.
 Dim page As PdfPage = document.Pages.Add()
 'Create new PdfLine instance.
 Dim line As New PdfLine(New PointF(0, 0), New PointF(100, 0))
 'Draw the line to PDF page.
 line.Draw(page, PointF.Empty)
 'Save the PDF docment.
 document.Save("output.pdf")
 'Close the PDF document.
 document.Close(True)

PdfLine(PdfPen, PointF, PointF)

Initializes a new instance of the PdfLine class.

public PdfLine(PdfPen pen, PointF point1, PointF point2)

Parameters

pen PdfPen

The pen.

point1 PointF

The line start point.

point2 PointF

The line end point.

Examples

//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a new PDF page.
PdfPage page = document.Pages.Add();
//Create new PDF pen.
PdfPen pen = new PdfPen(Color.Red);
//Create new PdfLine instance.
PdfLine line = new PdfLine(pen, new PointF(0, 0), new PointF(100, 0));
//Draw the line to PDF page.
line.Draw(page, PointF.Empty);
//Save the PDF docment.
document.Save("output.pdf");
//Close the PDF document.
document.Close(true);
'Create a new PDF document.
 Dim document As New PdfDocument()
 'Add a new PDF page.
 Dim page As PdfPage = document.Pages.Add()
 'Create new PDF pen.
 Dim pen As New PdfPen(Color.Red)
 'Create new PdfLine instance.
 Dim line As New PdfLine(pen, New PointF(0, 0), New PointF(100, 0))
 'Draw the line to PDF page.
 line.Draw(page, PointF.Empty)
 'Save the PDF docment.
 document.Save("output.pdf")
 'Close the PDF document.
 document.Close(True)

PdfLine(PdfPen, float, float, float, float)

Initializes a new instance of the PdfLine class.

public PdfLine(PdfPen pen, float x1, float y1, float x2, float y2)

Parameters

pen PdfPen

The pen.

x1 float

The x-coordinate of the first point.

y1 float

The y-coordinate of the first point.

x2 float

The x-coordinate of the end pint.

y2 float

The y-coordinate of the end pint.

Examples

//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a new PDF page.
PdfPage page = document.Pages.Add();
//Create new PDF pen.
PdfPen pen = new PdfPen(Color.Red);
//Create new PdfLine instance.
PdfLine line = new PdfLine(pen, 0, 0, 100, 0);
//Draw the line to PDF page.
line.Draw(page, PointF.Empty);
//Save the PDF docment.
document.Save("output.pdf");
//Close the PDF document.
document.Close(true);
'Create a new PDF document.
 Dim document As New PdfDocument()
 'Add a new PDF page.
 Dim page As PdfPage = document.Pages.Add()
 'Create new PDF pen.
 Dim pen As New PdfPen(Color.Red)
 'Create new PdfLine instance.
 Dim line As New PdfLine(pen, 0, 0, 100, 0)
 'Draw the line to PDF page.
 line.Draw(page, PointF.Empty)
 'Save the PDF docment.
 document.Save("output.pdf")
 'Close the PDF document.
 document.Close(True)

PdfLine(float, float, float, float)

Initializes a new instance of the PdfLine class from the specified two pair fo coordinates.

public PdfLine(float x1, float y1, float x2, float y2)

Parameters

x1 float

The x-coordinate of the first point.

y1 float

The y-coordinate of the first point.

x2 float

The x-coordinate of the end pint.

y2 float

The y-coordinate of the end pint.

Examples

//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a new PDF page.
PdfPage page = document.Pages.Add();
//Create new PdfLine instance.
PdfLine line = new PdfLine(0, 0, 100, 0);
//Draw the line to PDF page.
line.Draw(page, PointF.Empty);
//Save the PDF docment.
document.Save("output.pdf");
//Close the PDF document.
document.Close(true);
'Create a new PDF document.
 Dim document As New PdfDocument()
 'Add a new PDF page.
 Dim page As PdfPage = document.Pages.Add()
 'Create new PdfLine instance.
 Dim line As New PdfLine(0, 0, 100, 0)
 'Draw the line to PDF page.
 line.Draw(page, PointF.Empty)
 'Save the PDF docment.
 document.Save("output.pdf")
 'Close the PDF document.
 document.Close(True)

Properties

X1

Gets or sets the x coordinate of the start point.

public float X1 { get; set; }

Property Value

float

Examples

//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a new PDF page.
PdfPage page = document.Pages.Add();
//Create new PdfLine instance.
PdfLine line = new PdfLine(new PointF(0, 0), new PointF(100, 0));
//Set the x coordinate of the start point.
line.X1 = 0;
//Set the y coordinate of the start point.
line.Y1 = 0;
//Set the x coordinate of the end point.
line.X2 = 100;
//Set the y coordinate of the end point.
line.Y2 = 0;
//Draw the line to PDF page.
line.Draw(page, PointF.Empty);
//Save the PDF docment.
document.Save("output.pdf");
//Close the PDF document.
document.Close(true);
'Create a new PDF document.
 Dim document As New PdfDocument()
 'Add a new PDF page.
 Dim page As PdfPage = document.Pages.Add()
 'Create new PdfLine instance.
 Dim line As New PdfLine(New PointF(0, 0), New PointF(100, 0))
 'Set the x coordinate of the start point.
 line.X1 = 0
 'Set the y coordinate of the start point.
 line.Y1 = 0
 'Set the x coordinate of the end point.
 line.X2 = 100
 'Set the y coordinate of the end point.
 line.Y2 = 0
 'Draw the line to PDF page.
 line.Draw(page, PointF.Empty)
 'Save the PDF docment.
 document.Save("output.pdf")
 'Close the PDF document.
 document.Close(True)

X2

Gets or sets the x coordinate of the end point.

public float X2 { get; set; }

Property Value

float

Examples

//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a new PDF page.
PdfPage page = document.Pages.Add();
//Create new PdfLine instance.
PdfLine line = new PdfLine(new PointF(0, 0), new PointF(100, 0));
//Set the x coordinate of the start point.
line.X1 = 0;
//Set the y coordinate of the start point.
line.Y1 = 0;
//Set the x coordinate of the end point.
line.X2 = 100;
//Set the y coordinate of the end point.
line.Y2 = 0;
//Draw the line to PDF page.
line.Draw(page, PointF.Empty);
//Save the PDF docment.
document.Save("output.pdf");
//Close the PDF document.
document.Close(true);
'Create a new PDF document.
 Dim document As New PdfDocument()
 'Add a new PDF page.
 Dim page As PdfPage = document.Pages.Add()
 'Create new PdfLine instance.
 Dim line As New PdfLine(New PointF(0, 0), New PointF(100, 0))
 'Set the x coordinate of the start point.
 line.X1 = 0
 'Set the y coordinate of the start point.
 line.Y1 = 0
 'Set the x coordinate of the end point.
 line.X2 = 100
 'Set the y coordinate of the end point.
 line.Y2 = 0
 'Draw the line to PDF page.
 line.Draw(page, PointF.Empty)
 'Save the PDF docment.
 document.Save("output.pdf")
 'Close the PDF document.
 document.Close(True)

Y1

Gets or sets the y coordinate of the start point.

public float Y1 { get; set; }

Property Value

float

Examples

//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a new PDF page.
PdfPage page = document.Pages.Add();
//Create new PdfLine instance.
PdfLine line = new PdfLine(new PointF(0, 0), new PointF(100, 0));
//Set the x coordinate of the start point.
line.X1 = 0;
//Set the y coordinate of the start point.
line.Y1 = 0;
//Set the x coordinate of the end point.
line.X2 = 100;
//Set the y coordinate of the end point.
line.Y2 = 0;
//Draw the line to PDF page.
line.Draw(page, PointF.Empty);
//Save the PDF docment.
document.Save("output.pdf");
//Close the PDF document.
document.Close(true);
'Create a new PDF document.
 Dim document As New PdfDocument()
 'Add a new PDF page.
 Dim page As PdfPage = document.Pages.Add()
 'Create new PdfLine instance.
 Dim line As New PdfLine(New PointF(0, 0), New PointF(100, 0))
 'Set the x coordinate of the start point.
 line.X1 = 0
 'Set the y coordinate of the start point.
 line.Y1 = 0
 'Set the x coordinate of the end point.
 line.X2 = 100
 'Set the y coordinate of the end point.
 line.Y2 = 0
 'Draw the line to PDF page.
 line.Draw(page, PointF.Empty)
 'Save the PDF docment.
 document.Save("output.pdf")
 'Close the PDF document.
 document.Close(True)

Y2

Gets or sets the y coordinate of the end point.

public float Y2 { get; set; }

Property Value

float

Examples

//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a new PDF page.
PdfPage page = document.Pages.Add();
//Create new PdfLine instance.
PdfLine line = new PdfLine(new PointF(0, 0), new PointF(100, 0));
//Set the x coordinate of the start point.
line.X1 = 0;
//Set the y coordinate of the start point.
line.Y1 = 0;
//Set the x coordinate of the end point.
line.X2 = 100;
//Set the y coordinate of the end point.
line.Y2 = 0;
//Draw the line to PDF page.
line.Draw(page, PointF.Empty);
//Save the PDF docment.
document.Save("output.pdf");
//Close the PDF document.
document.Close(true);
'Create a new PDF document.
 Dim document As New PdfDocument()
 'Add a new PDF page.
 Dim page As PdfPage = document.Pages.Add()
 'Create new PdfLine instance.
 Dim line As New PdfLine(New PointF(0, 0), New PointF(100, 0))
 'Set the x coordinate of the start point.
 line.X1 = 0
 'Set the y coordinate of the start point.
 line.Y1 = 0
 'Set the x coordinate of the end point.
 line.X2 = 100
 'Set the y coordinate of the end point.
 line.Y2 = 0
 'Draw the line to PDF page.
 line.Draw(page, PointF.Empty)
 'Save the PDF docment.
 document.Save("output.pdf")
 'Close the PDF document.
 document.Close(True)

Methods

DrawInternal(PdfGraphics)

Draws an element on the Graphics.

protected override void DrawInternal(PdfGraphics graphics)

Parameters

graphics PdfGraphics

Graphics context where the element should be printed.

GetBoundsInternal()

Overloaded. Returns a rectangle that bounds this element.

protected override RectangleF GetBoundsInternal()

Returns

RectangleF

Returns a rectangle that bounds this element.