cete.dynamicpdf.pageelements.formattedtextarea
FormattedTextArea
- Namespace: ceTe.DynamicPDF.PageElements
- Assemblies: ceTe.DynamicPDF.40.dll
Represents an area of formatted text.
public class FormattedTextArea : RotatingPageElement, IArea, ICoordinate, ISerializable
Public Class FormattedTextArea
Inherits RotatingPageElement
Implements IArea, ICoordinate, ISerializable
Inheritance: Object → PageElement → TaggablePageElement → RotatingPageElement → FormattedTextArea
Implements: IArea, ICoordinate, ISerializable
Licensing
This class is a DynamicPDF Generator Professional Edition feature. One of the following licenses is required for non-evaluation usage:
- DynamicPDF Generator for .NET Professional Edition
- DynamicPDF Generator for .NET Enterprise Edition
- DynamicPDF Merger for .NET Professional Edition
- DynamicPDF Merger for .NET Enterprise Edition
- DynamicPDF ReportWriter for .NET Professional Edition
- DynamicPDF ReportWriter for .NET Enterprise Edition
- DynamicPDF Core Suite for .NET Professional Edition
- DynamicPDF Core Suite for .NET Enterprise Edition
Examples
The following example shows a paragraph of formatted text being displayed 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 style
Dim style As FormattedTextAreaStyle = New FormattedTextAreaStyle(FontFamily.Helvetica, 12, False)
' Create the text and the formatted text area
Dim formattedText As String = "<p>Formatted text area provide rich formatting support for " + _ "text that appears in the document. You have complete control over 8 paragraph " + _ "properties: spacing before, spacing after, first line indentation, left indentation," + _ " right indentation, alignment, allowing orphan lines, and white space preservation; " + _ "6 font properties: <font face='Times'>font face, </font><font " + _ "pointSize='6'>font size, </font><font color='FF0000'>color, " + _ "</font><b>bold, </b><i<italic and </i><u>" + _ "underline</u>; and 2 line properties: leading, and leading type. Text can " + _ "also be rotated.</p>"
Dim MyFormattedTextArea As FormattedTextArea = New FormattedTextArea(formattedText, 0, 0, 256, 400, style)
' Add the formatted text area to the page
MyPage.Elements.Add(MyFormattedTextArea)
' Save the PDF
MyDocument.Draw("C:\MyDocument.pdf")
End Sub
End Module
using System;
using ceTe.DynamicPDF;
using ceTe.DynamicPDF.PageElements;
class MyClass
{
static void Main()
{
// 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 formatted style
FormattedTextAreaStyle style = new FormattedTextAreaStyle( FontFamily.Helvetica, 12, false );
// Create the text and the formatted text area
string formattedText = "<p>Formatted text area provide rich formatting support for text that " + "appears in the document. You have complete control over 8 paragraph properties: " + "spacing before, spacing after, first line indentation, left indentation, right " + "indentation, alignment, allowing orphan lines, and white space preservation; 6 " + "font properties: <font face='Times'>font face, </font><font " + "pointSize='6'>font size, </font><font color='FF0000'>color, " + "</font><b>bold, </b><i>italic and </i><u>" + "underline</u>; and 2 line properties: leading, and leading type. Text can " + "also be rotated.</p>";
FormattedTextArea formattedTextArea = new FormattedTextArea( formattedText, 0, 0, 256, 400, style );
// Add the formatted text area to the page
page.Elements.Add( formattedTextArea );
// Save the PDF
document.Draw( @"C:\MyDocument.pdf" );
}
}
Remarks
This class can be used to place formatted text onto an area of the page.
For a complete list of supported font tags take a look at the Formatted TextArea Formatting topic.
See the Text Continuation topic for more on text continuation.
Constructors
FormattedTextArea(String, Single, Single, Single, Single, FontFamily, Single, Boolean)
Initializes a new instance of the FormattedTextArea class.
public FormattedTextArea(string text, float x, float y, float width, float height, FontFamily fontFamily, float fontSize, bool preserveWhitespace)
Public Sub New (text As String, x As Single, y As Single, width As Single, height As Single, fontFamily As FontFamily, fontSize As Single, preserveWhitespace As Boolean)
Parameters
- text: String
Text to display in the formatted text area.
- x: Single
X coordinate of the formatted text area.
- y: Single
Y coordinate of the formatted text area.
- width: Single
Width of the formatted text area.
- height: Single
Height of the formatted text area.
- fontFamily: FontFamily
Initial FontFamily of the formatted text area.
- fontSize: Single
Initial font size of the formatted text area.
- preserveWhitespace: Boolean
Specifies if white space should be preserved.
FormattedTextArea(String, Single, Single, Single, Single, FormattedTextAreaStyle)
Initializes a new instance of the FormattedTextArea class.
public FormattedTextArea(string text, float x, float y, float width, float height, FormattedTextAreaStyle style)
Public Sub New (text As String, x As Single, y As Single, width As Single, height As Single, style As FormattedTextAreaStyle)
Parameters
- text: String
Text to display in the formatted text area.
- x: Single
X coordinate of the formatted text area.
- y: Single
Y coordinate of the formatted text area.
- width: Single
Width of the formatted text area.
- height: Single
Height of the formatted text area.
- style: FormattedTextAreaStyle
Initial FormattedTextAreaStyle of the formatted text area.
Properties
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
FontFaces
Gets the FontFamilyList used by the formatted text area.
public FontFamilyList FontFaces { get; }
Public Property FontFaces As FontFamilyList
Property Value
Height
Gets or sets the height of the formatted text area.
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
Style
Gets or sets the FormattedTextAreaStyle object used to specify the initial style of the formatted text area.
public FormattedTextAreaStyle Style { get; set; }
Public Property Style As FormattedTextAreaStyle
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
Licensing
This property is a DynamicPDF Generator Enterprise Edition feature. One of the following licenses is required for non-evaluation usage:
- DynamicPDF Generator for .NET Enterprise Edition
- DynamicPDF Merger for .NET Enterprise Edition
- DynamicPDF ReportWriter for .NET Enterprise Edition
- DynamicPDF Core Suite for .NET Enterprise Edition
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 for the formatted text area.
public string Text { get; set; }
Public Property Text As String
Property Value
VAlign
Gets or sets a value indicating the vertical alignment of the formatted text area.
public VAlign VAlign { get; set; }
Public Property VAlign As VAlign
Property Value
Width
Gets or sets the width of the formatted text area.
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 .
GetOverflowFormattedTextArea()
Returns a new FormattedTextArea object containing the overflow text.
public FormattedTextArea GetOverflowFormattedTextArea()
Function GetOverflowFormattedTextArea() As FormattedTextArea
Returns
A FormattedTextArea if there is overflow text; otherwise, null .
Examples
The following example shows you how to use the GetOverflowFormattedTextArea object to allow text of variable length to flow onto new pages as needed.
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 string and assign it to text of variable length Dim myVariableText As String = "" Dim i As Integer For i = 0 To 50 MyVariableText &= "<i>This</i> is a <font color='FF0000'>sentence</font> that " + _ "I will use as my <b>variable length</b> text. " Next ' Create an formatted text area Dim MyFormattedTextArea As FormattedTextArea = New FormattedTextArea(MyVariableText, 0, 0, 250, 200, FontFamily.Helvetica, 12, False) Do ' Create a new page Dim MyPage As Page = New Page
' Add the text area to the page; MyPage.Elements.Add(MyFormattedTextArea)
' Add the page to the document MyDocument.Pages.Add(MyPage)
' Set the text area object equal to the rest of the text that did not fit ' if all the text fit this will set textArea to null MyFormattedTextArea = MyFormattedTextArea.GetOverflowFormattedTextArea() Loop While Not MyFormattedTextArea Is Nothing
' Save the PDF MyDocument.Draw("C:\MyDocument.pdf") End Sub
End Module
using System;
using ceTe.DynamicPDF;
using ceTe.DynamicPDF.PageElements;
class MyClass
{static void Main(){ // Create a PDF Document Document document = new Document();
// Create a string and assign it to text of variable length string variableText = ""; for( int i = 0; i < 50; i++ ) variableText += "<i>This</i> is a <font color='FF0000'>sentence</font> that I " + "will use as my <b>variable length</b> text. ";
// Create an formatted text area FormattedTextArea formattedTextArea = new FormattedTextArea( variableText, 0, 0, 250, 200, FontFamily.Helvetica, 12, false ); do { // Create a new page Page page = new Page();
// Add the text area to the page; page.Elements.Add( formattedTextArea );
// Add the page to the document document.Pages.Add( page );
// Set the formatted text area object equal to the rest of the text that did not fit // if all the text did fit, GetOverflowFormattedTextArea will return null formattedTextArea = formattedTextArea.GetOverflowFormattedTextArea(); } while( formattedTextArea != null ); // Save the PDF document.Draw( @"C:\MyDocument.pdf" );}
}
Remarks
This method returns a new FormattedTextArea object that contains the remaining text that did not fit.
GetOverflowFormattedTextArea(Single, Single)
Returns a new FormattedTextArea object containing the overflow text.
public FormattedTextArea GetOverflowFormattedTextArea(float x, float y)
Function GetOverflowFormattedTextArea(x As Single, y As Single) As FormattedTextArea
Parameters
- x: Single
X coordinate of the new object.
- y: Single
Y coordinate of the new object.
Returns
A FormattedTextArea if there is overflow text; otherwise, null .
Examples
The following example shows you how to use the GetOverflowFormattedTextArea object to allow text of variable length to flow onto new pages as needed.
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 string and assign it to text of variable length Dim myVariableText As String = "" Dim i As Integer For i = 0 To 50 MyVariableText &= "<i>This</i> is a <font color='FF0000'>sentence</font> that " + _ "I will use as my <b>variable length</b> text. " Next ' Create an formatted text area Dim MyFormattedTextArea As FormattedTextArea = New FormattedTextArea(MyVariableText, 0, 0, 250, 200, FontFamily.Helvetica, 12, False) Do ' Create a new page Dim MyPage As Page = New Page
' Add the text area to the page; MyPage.Elements.Add(MyFormattedTextArea)
' Add the page to the document MyDocument.Pages.Add(MyPage)
' Set the text area object equal to the rest of the text that did not fit ' if all the text fit this will set textArea to null MyFormattedTextArea = MyFormattedTextArea.GetOverflowFormattedTextArea(50, 50) Loop While Not MyFormattedTextArea Is Nothing
' Save the PDF MyDocument.Draw("C:\MyDocument.pdf") End Sub
End Module
using System;
using ceTe.DynamicPDF;
using ceTe.DynamicPDF.PageElements;
class MyClass
{static void Main(){ // Create a PDF Document Document document = new Document();
// Create a string and assign it to text of variable length string variableText = ""; for( int i = 0; i < 50; i++ ) variableText += "<i>This</i> is a <font color='FF0000'>sentence</font> that I " + "will use as my <b>variable length</b> text. ";
// Create an formatted text area FormattedTextArea formattedTextArea = new FormattedTextArea( variableText, 0, 0, 250, 200, FontFamily.Helvetica, 12, false ); do { // Create a new page Page page = new Page();
// Add the text area to the page; page.Elements.Add( formattedTextArea );
// Add the page to the document document.Pages.Add( page );
// Set the formatted text area object equal to the rest of the text that did not fit // if all the text did fit, GetOverflowFormattedTextArea will return null formattedTextArea = formattedTextArea.GetOverflowFormattedTextArea( 50, 50 ); } while( formattedTextArea != null ); // Save the PDF document.Draw( @"C:\MyDocument.pdf" );}
}
Remarks
This method returns a new FormattedTextArea object that contains the remaining text that did not fit.
GetOverflowFormattedTextArea(Single, Single, Single)
Returns a new FormattedTextArea object containing the overflow text.
public FormattedTextArea GetOverflowFormattedTextArea(float x, float y, float height)
Function GetOverflowFormattedTextArea(x As Single, y As Single, height As Single) As FormattedTextArea
Parameters
- x: Single
X coordinate of the new object.
- y: Single
Y coordinate of the new object.
- height: Single
Height of the new object.
Returns
A FormattedTextArea if there is overflow text; otherwise, null .
Examples
The following example shows you how to use the GetOverflowFormattedTextArea object to allow text of variable length to flow onto new pages as needed.
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 string and assign it to text of variable length Dim myVariableText As String = "" Dim i As Integer For i = 0 To 50 MyVariableText &= "<i>This</i> is a <font color='FF0000'>sentence</font> that " + _ "I will use as my <b>variable length</b> text. " Next ' Create an formatted text area Dim MyFormattedTextArea As FormattedTextArea = New FormattedTextArea(MyVariableText, 0, 0, 250, 200, FontFamily.Helvetica, 12, False) Do ' Create a new page Dim MyPage As Page = New Page
' Add the text area to the page; MyPage.Elements.Add(MyFormattedTextArea)
' Add the page to the document MyDocument.Pages.Add(MyPage)
' Set the text area object equal to the rest of the text that did not fit ' if all the text fit this will set textArea to null MyFormattedTextArea = MyFormattedTextArea.GetOverflowFormattedTextArea(50, 50, 100) Loop While Not MyFormattedTextArea Is Nothing
' Save the PDF MyDocument.Draw("C:\MyDocument.pdf") End Sub
End Module
using System;
using ceTe.DynamicPDF;
using ceTe.DynamicPDF.PageElements;
class MyClass
{static void Main(){ // Create a PDF Document Document document = new Document();
// Create a string and assign it to text of variable length string variableText = ""; for( int i = 0; i < 50; i++ ) variableText += "<i>This</i> is a <font color='FF0000'>sentence</font> that I " + "will use as my <b>variable length</b> text. ";
// Create an formatted text area FormattedTextArea formattedTextArea = new FormattedTextArea( variableText, 0, 0, 250, 200, FontFamily.Helvetica, 12, false ); do { // Create a new page Page page = new Page();
// Add the text area to the page; page.Elements.Add( formattedTextArea );
// Add the page to the document document.Pages.Add( page );
// Set the formatted text area object equal to the rest of the text that did not fit // if all the text did fit, GetOverflowFormattedTextArea will return null formattedTextArea = formattedTextArea.GetOverflowFormattedTextArea( 50, 50, 100 ); } while( formattedTextArea != null ); // Save the PDF document.Draw( @"C:\MyDocument.pdf" );}
}
Remarks
This method returns a new FormattedTextArea object that contains the remaining text that did not fit.
GetRequiredHeight()
Returns the required height to fit all of the text of the FormattedTextArea .
public float GetRequiredHeight()
Function GetRequiredHeight() As Single
Returns
Height required to fit all text.
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.
HasOverflowText()
Returns a value specifying if there is text that did not fit in the FormattedTextArea .
public bool HasOverflowText()
Function HasOverflowText() As Boolean
Returns
True if the FormattedTextArea has overflow text.
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 .