cete.dynamicpdf.pageelements.label
Label
- Namespace: ceTe.DynamicPDF.PageElements
- Assemblies: DynamicPDF.CoreSuite.dll
Represents a label page element.
public class Label : RotatingPageElement, IArea, ICoordinate, ISerializable
Public Class Label
Inherits RotatingPageElement
Implements IArea, ICoordinate, ISerializable
Inheritance: Object → PageElement → TaggablePageElement → RotatingPageElement → Label
Implements: IArea, ICoordinate, ISerializable
Examples
The following example will display text in a label 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 the string and label
Dim MyText As String = "This is the dark blue, centered text at a 15 degree angle contained in the label."
Dim MyLabel As Label = New Label(MyText, 0, 0, 512, 14, Font.Helvetica, 14, TextAlign.Center, RgbColor.DarkBlue)
' Change the angle property
MyLabel.Angle = 15
' Add the label to the page
MyPage.Elements.Add(MyLabel)
' 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 the string and label
string text = "This is the dark blue, centered text at a 15 degree angle contained in the label.";
Label label = new Label(text, 0, 0, 512, 14, Font.Helvetica, 14, TextAlign.Center, RgbColor.DarkBlue);
// Change the angle property
label.Angle = 15;
// Add the label to the page
page.Elements.Add(label);
// Save the PDF
document.Draw(outputPath);
}
}
Remarks
This class can be used to place labels of text on a page.
Constructors
Label(String, Single, Single, Single, Single)
Initializes a new instance of the Label class.
public Label(string text, float x, float y, float width, float height)
Public Sub New (text As String, x As Single, y As Single, width As Single, height As Single)
Parameters
- text: String
Text to display in the label.
- x: Single
X coordinate of the label.
- y: Single
Y coordinate of the label.
- width: Single
Width of the label.
- height: Single
Height of the label.
Label(String, Single, Single, Single, Single, Font)
Initializes a new instance of the Label class.
public Label(string text, float x, float y, float width, float height, Font font)
Public Sub New (text As String, x As Single, y As Single, width As Single, height As Single, font As Font)
Parameters
- text: String
Text to display in the label.
- x: Single
X coordinate of the label.
- y: Single
Y coordinate of the label.
- width: Single
Width of the label.
- height: Single
Height of the label.
- font: Font
Font for the text of the label.
Label(String, Single, Single, Single, Single, Font, Single)
Initializes a new instance of the Label class.
public Label(string text, float x, float y, float width, float height, Font font, float fontSize)
Public Sub New (text As String, x As Single, y As Single, width As Single, height As Single, font As Font, fontSize As Single)
Parameters
- text: String
Text to display in the label.
- x: Single
X coordinate of the label.
- y: Single
Y coordinate of the label.
- width: Single
Width of the label.
- height: Single
Height of the label.
- font: Font
Font for the text of the label.
- fontSize: Single
Font size of the text of the label.
Label(String, Single, Single, Single, Single, Font, Single, Color)
Initializes a new instance of the Label class.
public Label(string text, float x, float y, float width, float height, Font font, float fontSize, Color textColor)
Public Sub New (text As String, x As Single, y As Single, width As Single, height As Single, font As Font, fontSize As Single, textColor As Color)
Parameters
- text: String
Text to display in the label.
- x: Single
X coordinate of the label.
- y: Single
Y coordinate of the label.
- width: Single
Width of the label.
- height: Single
Height of the label.
- font: Font
Font for the text of the label.
- fontSize: Single
Font size of the text of the label.
- textColor: Color
Color of the text of the label.
Label(String, Single, Single, Single, Single, Font, Single, TextAlign)
Initializes a new instance of the Label class.
public Label(string text, float x, float y, float width, float height, Font font, float fontSize, TextAlign align)
Public Sub New (text As String, x As Single, y As Single, width As Single, height As Single, font As Font, fontSize As Single, align As TextAlign)
Parameters
- text: String
Text to display in the label.
- x: Single
X coordinate of the label.
- y: Single
Y coordinate of the label.
- width: Single
Width of the label.
- height: Single
Height of the label.
- font: Font
Font for the text of the label.
- fontSize: Single
Font size of the text of the label.
- align: TextAlign
Alignment of the text of the label.
Label(String, Single, Single, Single, Single, Font, Single, TextAlign, Color)
Initializes a new instance of the Label class.
public Label(string text, float x, float y, float width, float height, Font font, float fontSize, TextAlign align, Color textColor)
Public Sub New (text As String, x As Single, y As Single, width As Single, height As Single, font As Font, fontSize As Single, align As TextAlign, textColor As Color)
Parameters
- text: String
Text to display in the label.
- x: Single
X coordinate of the label.
- y: Single
Y coordinate of the label.
- width: Single
Width of the label.
- height: Single
Height of the label.
- font: Font
Font for the text of the label.
- fontSize: Single
Font size of the text of the label.
- align: TextAlign
Alignment of the text of the label.
- textColor: Color
Color of the text of the label.
Properties
Align
Gets or sets the Align enumeration that specifies the text alignment of the label.
public TextAlign Align { get; set; }
Public Property Align As TextAlign
Property Value
Angle
Gets or sets the heights of the angle element. (Inherited from RotatingPageElement)
public float Angle { get; set; }
Public Property Angle As Single
Property Value
Font
Gets or sets the Font object to use for the text of the label.
public Font Font { get; set; }
Public Property Font As Font
Property Value
FontSize
Gets or sets the font size for the text of the label.
public float FontSize { get; set; }
Public Property FontSize As Single
Property Value
Height
Gets or sets the height or the label.
public float Height { get; set; }
Public Property Height As Single
Property Value
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
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
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
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);
}
}
RightToLeft
Gets or sets a value indicating if text should be displayed right to left.
public bool RightToLeft { get; set; }
Public Property RightToLeft As Boolean
Property Value
Strikethrough
Gets or sets the strike through to use for the text of the label.
public bool Strikethrough { get; set; }
Public Property Strikethrough As Boolean
Property Value
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
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
Text
Gets or sets the text of the label.
public string Text { get; set; }
Public Property Text As String
Property Value
TextColor
Gets or sets the Color object to use for the text of the label.
public Color TextColor { get; set; }
Public Property TextColor As Color
Property Value
TextOutlineColor
Gets or sets the Color object to use for the text outline of the label.
public Color TextOutlineColor { get; set; }
Public Property TextOutlineColor As Color
Property Value
TextOutlineWidth
Gets or sets the line width to use for the text outline of the label.
public float TextOutlineWidth { get; set; }
Public Property TextOutlineWidth As Single
Property Value
Underline
Gets or sets a value indicating if the label is underlined.
public bool Underline { get; set; }
Public Property Underline As Boolean
Property Value
VAlign
Gets or sets the VAlign enumeration that specifies the vertical text alignment of the label.
public VAlign VAlign { get; set; }
Public Property VAlign As VAlign
Property Value
Width
Gets or sets the width or the label.
public float Width { get; set; }
Public Property Width As Single
Property Value
X
Gets or sets the X coordinate of the page element. (Inherited from RotatingPageElement)
public float X { get; set; }
Public Property X As Single
Property Value
Y
Gets or sets the Y coordinate of the page element. (Inherited from RotatingPageElement)
public float Y { get; set; }
Public Property Y As Single
Property Value
Methods
Draw(PageWriter)
Draws the page element to the given PageWriter object. (Inherited from RotatingPageElement)
public void Draw(PageWriter writer)
Sub Draw(writer As PageWriter)
Parameters
- writer: PageWriter
PageWriter object to receive the page element'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
- obj: Object
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 .