Skip to main content

Line

Version: 11.0

cete.dynamicpdf.pageelements.line

Line​

Represents a line page element.

public class Line : TaggablePageElement, ISerializable
Public Class Line
Inherits TaggablePageElement
Implements ISerializable

Inheritance: Object → PageElement → TaggablePageElement → Line

Implements: ISerializable

Examples​

The following example will display two different lines on the page.

Imports System
Imports ceTe.DynamicPDF
Imports ceTe.DynamicPDF.PageElements

Module MyModule

Sub Main()

' Create a PDF Document
Dim MyDocument As Document = New Document

' Create a Page and add it to the document
Dim MyPage As Page = New Page
MyDocument.Pages.Add(MyPage)

' Create a line
Dim MyLine As Line = New Line(50, 50, 50, 400, 5, _
Grayscale.Black, LineStyle.Solid)

' Change the line cap property
MyLine.Cap = LineCap.Round

' Add two lines to the page
MyPage.Elements.Add(MyLine)
MyPage.Elements.Add(New Line(60, 50, 150, 400, 2, _
RgbColor.Blue, LineStyle.DashLarge))

' Save the PDF
MyDocument.Draw("C:\MyDocument.pdf")

End Sub
End Module
using System;
using ceTe.DynamicPDF;
using ceTe.DynamicPDF.PageElements;

public class Example
{
public static void CreatePDF(string outputPath)
{
// Create a PDF Document
Document document = new Document();

// Create a Page and add it to the document
Page page = new Page();
document.Pages.Add(page);

// Create a line
Line line = new Line(50, 50, 50, 400, 5, Grayscale.Black,
LineStyle.Solid);

// Change the line cap property
line.Cap = LineCap.Round;

// Add two lines to the page
page.Elements.Add(line);
page.Elements.Add(new Line(60, 50, 150, 400, 2,
RgbColor.Blue, LineStyle.DashLarge));

// Save the PDF
document.Draw(outputPath);
}
}

Remarks​

This class can be used to place lines of different length, width, color and patterns on a page.

Constructors​

Line(Single, Single, Single, Single)​

Initializes a new instance of the Line class.

public Line(float x1, float y1, float x2, float y2)
Public Sub New (x1 As Single, y1 As Single, x2 As Single, y2 As Single)

Parameters​

X1 coordinate of the line.

Y1 coordinate of the line.

X2 coordinate of the line.

Y2 coordinate of the line.

Line(Single, Single, Single, Single, Color)​

Initializes a new instance of the Line class.

public Line(float x1, float y1, float x2, float y2, Color color)
Public Sub New (x1 As Single, y1 As Single, x2 As Single, y2 As Single, color As Color)

Parameters​

X1 coordinate of the line.

Y1 coordinate of the line.

X2 coordinate of the line.

Y2 coordinate of the line.

Color of the line.

Line(Single, Single, Single, Single, Single)​

Initializes a new instance of the Line class.

public Line(float x1, float y1, float x2, float y2, float width)
Public Sub New (x1 As Single, y1 As Single, x2 As Single, y2 As Single, width As Single)

Parameters​

X1 coordinate of the line.

Y1 coordinate of the line.

X2 coordinate of the line.

Y2 coordinate of the line.

Width of the line.

Line(Single, Single, Single, Single, Single, Color)​

Initializes a new instance of the Line class.

public Line(float x1, float y1, float x2, float y2, float width, Color color)
Public Sub New (x1 As Single, y1 As Single, x2 As Single, y2 As Single, width As Single, color As Color)

Parameters​

X1 coordinate of the line.

Y1 coordinate of the line.

X2 coordinate of the line.

Y2 coordinate of the line.

Width of the line.

Color of the line.

Line(Single, Single, Single, Single, Single, Color, LineStyle)​

Initializes a new instance of the Line class.

public Line(float x1, float y1, float x2, float y2, float width, Color color, LineStyle style)
Public Sub New (x1 As Single, y1 As Single, x2 As Single, y2 As Single, width As Single, color As Color, style As LineStyle)

Parameters​

X1 coordinate of the line.

Y1 coordinate of the line.

X2 coordinate of the line.

Y2 coordinate of the line.

Width of the line.

Color of the line.

Style of the line.

Properties​

Cap​

Gets or sets the LineCap enumeration used to specify the line cap style of the line.

public LineCap Cap { get; set; }
Public Property Cap As LineCap

Property Value​

LineCap

Color​

Gets or sets the Color object to use for the line.

public Color Color { get; set; }
Public Property Color As Color

Property Value​

Color

ID​

Gets or sets the ID of the page element. (Inherited from PageElement)

public string ID { get; set; }
Public Property ID As String

Property Value​

String

IgnoreMargins​

Gets or sets ignore margin property. Setting false will consider the margin while placing the page element based on the RelativeTo property. (Inherited from PageElement)

public bool IgnoreMargins { get; set; }
Public Property IgnoreMargins As Boolean

Property Value​

Boolean

Examples​

The following example will place the Label in the top-left of the page with IgnoreMargin

using ceTe.DynamicPDF;
using ceTe.DynamicPDF.PageElements;

public class Example
{
public static void CreatePDF(string outputPath)
{
// Create a PDF Document
Document document = new Document();

// Create a Page and add it to the document
Page page = new Page();
document.Pages.Add(page); // Create an Label and place it in page top left with margin ignored
Label label = new Label("I am placed in Page top left with margin ignored", 0, 0, 160, 30);
label.RelativeTo = RelativeTo.TopLeft;
label.IgnoreMargin=true; page.Elements.Add(label);

// Save the PDF
document.Draw(outputPath);
}
}

RelativeTo​

Gets and sets placement of the page element on the page. (Inherited from PageElement)

public RelativeTo RelativeTo { get; set; }
Public Property RelativeTo As RelativeTo

Property Value​

RelativeTo

Examples​

The following example will place the Label in the top-left of the page.

using ceTe.DynamicPDF;
using ceTe.DynamicPDF.PageElements;

public class Example
{
public static void CreatePDF(string outputPath)
{
// Create a PDF Document
Document document = new Document();

// Create a Page and add it to the document
Page page = new Page();
document.Pages.Add(page); // Create an Label and place it in page top left with margin
Label label = new Label("I am placed in Page top left with margin.", 0, 0, 160, 30);
label.RelativeTo = RelativeTo.TopLeft;
page.Elements.Add(label);

// Save the PDF
document.Draw(outputPath);
}
}

Style​

Gets or sets the LineStyle object to use for the style of the line.

public LineStyle Style { get; set; }
Public Property Style As LineStyle

Property Value​

LineStyle

Tag​

Gets or sets the tag of the taggable element. (Inherited from TaggablePageElement)

public Tag Tag { get; set; }
Public Property Tag As Tag

Property Value​

Tag

TagOrder​

Gets or sets the tag order of the taggable element. (Inherited from TaggablePageElement)

public int TagOrder { get; set; }
Public Property TagOrder As Int32

Property Value​

Int32

Width​

Gets or sets the width of the line.

public float Width { get; set; }
Public Property Width As Single

Property Value​

Single

X1​

Gets or sets the X1 coordinate of the line.

public float X1 { get; set; }
Public Property X1 As Single

Property Value​

Single

X2​

Gets or sets the X2 coordinate of the line.

public float X2 { get; set; }
Public Property X2 As Single

Property Value​

Single

Y1​

Gets or sets the Y1 coordinate of the line.

public float Y1 { get; set; }
Public Property Y1 As Single

Property Value​

Single

Y2​

Gets or sets the Y2 coordinate of the line.

public float Y2 { get; set; }
Public Property Y2 As Single

Property Value​

Single

Methods​

Draw(PageWriter)​

Draws the line to the given PageWriter object.

public void Draw(PageWriter writer)
Sub Draw(writer As PageWriter)

Parameters​

PageWriter object to receive the line's output.

Equals(Object)​

Determines whether the specified Object is equal to the current Object . (Inherited from Object)

public bool Equals(Object obj)
Function Equals(obj As Object) As Boolean

Parameters​

The Object to compare with the current Object .

Returns​

true if the specified Object is equal to the current Object ; otherwise, false.

GetHashCode()​

Serves as a hash function for a particular type. (Inherited from Object)

public int GetHashCode()
Function GetHashCode() As Integer

Returns​

A hash code for the current Object .

GetType()​

Gets the Type of the current instance. (Inherited from Object)

public Type GetType()
Function GetType() As Type

Returns​

The Type instance that represents the exact runtime type of the current instance.

ToString()​

Returns a String that represents the current Object . (Inherited from Object)

public string ToString()
Function ToString() As String

Returns​

A String that represents the current Object .

See Also​

ceTe.DynamicPDF.PageElements