Table of Contents

Class TextBlock

Namespace
PDFjet.NET
Assembly
PDFjet.dll

A block of text that wraps at its width, with an optional border, background and padding. Without a height the block is as tall as its text; with one the text that does not fit is cut, and the lines are aligned to the top, the center or the bottom of the block.

Use a TextBlock for one run of text in one font: a label, a note, a table cell or a paragraph in a box. It breaks words that do not fit on a line, wraps right to left and Thai text, highlights keywords and can be cut to a height. Use a TextColumn for paragraphs of TextLine objects that differ in font or color, for justified text or for a rotated column, and a TextFrame for text that flows from one frame to the next. See Example_01, 10 and 11.

public class TextBlock : IDrawable
Inheritance
TextBlock
Implements
Inherited Members

Constructors

TextBlock(Font, string)

Creates a text block with the specified font and text.

public TextBlock(Font font, string textContent)

Parameters

font Font
textContent string

Methods

DrawOn(Page)

Draws this text block on the specified page.

public float[] DrawOn(Page page)

Parameters

page Page

Returns

float[]

GetBackgroundColor()

Returns the background color.

public float[] GetBackgroundColor()

Returns

float[]

GetBorderColor()

Returns the border color, or null.

public float[] GetBorderColor()

Returns

float[]

GetBorderWidth()

Returns the border width.

public float GetBorderWidth()

Returns

float

GetFont()

Returns the font of the text.

public Font GetFont()

Returns

Font

GetHeight()

Returns the height of this text block as it is drawn: the height set with SetHeight or SetSize, or the height of the text and padding without one.

public float GetHeight()

Returns

float

GetLocation()

Returns the x and y coordinates of the top left corner of this text block.

public float[] GetLocation()

Returns

float[]

GetPadding()

Returns the space between the text and the border.

public float GetPadding()

Returns

float

GetStrikeout()

Returns whether the text is struck out.

public bool GetStrikeout()

Returns

bool

GetText()

Returns the text.

public string GetText()

Returns

string

GetTextAlignment()

Returns the horizontal alignment of the text.

public Alignment GetTextAlignment()

Returns

Alignment

GetTextColor()

Returns the text color.

public float[] GetTextColor()

Returns

float[]

GetUnderline()

Returns whether the text is underlined.

public bool GetUnderline()

Returns

bool

GetVerticalAlignment()

Returns the vertical alignment of the text.

public Alignment GetVerticalAlignment()

Returns

Alignment

GetWidth()

Returns the width of this text block.

public float GetWidth()

Returns

float

SetBackgroundColor(int)

Sets the background color as a 0xRRGGBB value. Color.transparent removes the background.

public TextBlock SetBackgroundColor(int color)

Parameters

color int

Returns

TextBlock

SetBackgroundColor(float[])

Sets the background color from an array of red, green and blue values.

public TextBlock SetBackgroundColor(float[] rgbColor)

Parameters

rgbColor float[]

Returns

TextBlock

SetBorderColor(int)

Sets the border color as a 0xRRGGBB value. Color.transparent removes the border.

public TextBlock SetBorderColor(int color)

Parameters

color int

Returns

TextBlock

SetBorderColor(float[])

Sets the border color from an array of red, green and blue values.

public TextBlock SetBorderColor(float[] rgbColor)

Parameters

rgbColor float[]

Returns

TextBlock

SetBorderWidth(float)

Sets the border width.

public TextBlock SetBorderWidth(float borderWidth)

Parameters

borderWidth float

Returns

TextBlock

SetCornerRadius(float)

Sets the radius of the border corners.

public TextBlock SetCornerRadius(float borderCornerRadius)

Parameters

borderCornerRadius float

Returns

TextBlock

SetFallbackFont(Font)

Sets the font used for characters the main font does not have.

public TextBlock SetFallbackFont(Font font)

Parameters

font Font

Returns

TextBlock

SetFallbackFontSize(float)

Sets the size of the characters drawn in the fallback font. By default they are drawn at the font size.

public TextBlock SetFallbackFontSize(float fontSize)

Parameters

fontSize float

Returns

TextBlock

SetFont(Font)

Sets the font of the text. The fallback font changes with it, unless a different fallback font was set.

public TextBlock SetFont(Font font)

Parameters

font Font

Returns

TextBlock

SetFontSize(float)

Sets the font size.

public TextBlock SetFontSize(float fontSize)

Parameters

fontSize float

Returns

TextBlock

SetHeight(float)

Sets the height of this text block. With a height above 0 the block is that tall: the lines that do not fit are cut, the last line that fits ends with "...", and the lines are aligned by the vertical alignment. A height of 0 is the height of the text.

public TextBlock SetHeight(float height)

Parameters

height float

Returns

TextBlock

SetHighlightColors(Dictionary<string, int>)

Sets the colors used to highlight keywords. The keywords are matched ignoring case.

public TextBlock SetHighlightColors(Dictionary<string, int> map)

Parameters

map Dictionary<string, int>

Returns

TextBlock

SetLanguage(string)

Sets the language of the text, for example "he", "ar" or "fa", as a BCP 47 language tag. The text is marked with it, for screen readers and text extraction.

public TextBlock SetLanguage(string language)

Parameters

language string

Returns

TextBlock

SetLineSpacing(float)

Sets the line spacing as a multiple of the font's body height.

public TextBlock SetLineSpacing(float lineSpacing)

Parameters

lineSpacing float

Returns

TextBlock

SetLocation(float, float)

Sets the location of the top left corner of this text block.

public TextBlock SetLocation(float x, float y)

Parameters

x float
y float

Returns

TextBlock

SetPadding(float)

Sets the space between the text and the border.

public TextBlock SetPadding(float padding)

Parameters

padding float

Returns

TextBlock

SetRightToLeft(bool)

Sets whether the text is right to left, like Arabic and Hebrew text. Each paragraph is wrapped at the width in logical order, and each line is then reordered with Bidi.ReorderVisually, which also shapes the Arabic letters, and aligned to the right, unless the text alignment is Alignment.CENTER.

public TextBlock SetRightToLeft(bool rightToLeft)

Parameters

rightToLeft bool

Returns

TextBlock

SetSize(float, float)

Sets the size of this text block. With a height above 0 the block is that tall: the lines that do not fit are cut, the last line that fits ends with "...", and the lines are aligned by the vertical alignment. A height of 0 is the height of the text.

public TextBlock SetSize(float width, float height)

Parameters

width float
height float

Returns

TextBlock

SetStrikeout(bool)

Sets whether the text is struck out.

public TextBlock SetStrikeout(bool strikeout)

Parameters

strikeout bool

Returns

TextBlock

SetStructureType(StructElem)

Sets the structure element type of this text block, for example StructElem.P, the default, or StructElem.H1 for a heading, as a tagged document, PDF/UA or a PDF/A of level A, tags it.

public TextBlock SetStructureType(StructElem structureType)

Parameters

structureType StructElem

Returns

TextBlock

SetText(string)

Sets the text.

public TextBlock SetText(string text)

Parameters

text string

Returns

TextBlock

SetTextAlignment(Alignment)

Sets the horizontal alignment of the text.

public TextBlock SetTextAlignment(Alignment textAlignment)

Parameters

textAlignment Alignment

Returns

TextBlock

SetTextColor(int)

Sets the text color as a 0xRRGGBB value. Color.transparent leaves the text color unchanged.

public TextBlock SetTextColor(int color)

Parameters

color int

Returns

TextBlock

SetTextColor(float[])

Sets the text color from an array of red, green and blue values. A null color leaves the text color unchanged.

public TextBlock SetTextColor(float[] textColor)

Parameters

textColor float[]

Returns

TextBlock

SetURIAction(string)

Sets the URI opened when this text block is clicked.

public TextBlock SetURIAction(string uri)

Parameters

uri string

Returns

TextBlock

SetUnderline(bool)

Sets whether the text is underlined.

public TextBlock SetUnderline(bool underline)

Parameters

underline bool

Returns

TextBlock

SetVerticalAlignment(Alignment)

Sets the vertical alignment of the text in a block with a height: Alignment.TOP, the default, Alignment.CENTER or Alignment.BOTTOM.

public TextBlock SetVerticalAlignment(Alignment verticalAlignment)

Parameters

verticalAlignment Alignment

Returns

TextBlock

SetWidth(float)

Sets the width of this text block and resets its height, so the height fits the text.

public TextBlock SetWidth(float width)

Parameters

width float

Returns

TextBlock