PdfTextElement Class

Represents a block of text to be rendered in a PDF document. Supports positioning, styling and multi-page continuation

Definition

Namespace: HiQPdf.Next
Assembly: HiQPdf.Next (in HiQPdf.Next.dll) Version: 18.9.2
C#
public class PdfTextElement
Inheritance
Object    PdfTextElement

Constructors

PdfTextElement Initializes a new instance of the PdfTextElement class with the specified text and font. Use PdfFontManager to create the font

Properties

Accessibility Accessibility metadata used when the host PdfDocument is tagged. The default structure type for a text block is Paragraph; set StructureType to Heading1..Heading6 for headings, or to Artifact for decorative fragments
Alignment The horizontal alignment of the text
BackgroundColor Optional background color drawn behind the text on each page where the text is rendered. The background covers the full column area available to the text on that page, follows the rotation applied to the element and is emitted as a decorative artifact in the structure tree. When null no background is drawn
BackgroundOpacity The opacity of the background color in the range 0..1. The default value is 1 which produces a fully opaque background
ContinueOnNextPage If true, text that does not fit will continue rendering on the next page. The default value is false
Direction The direction in which the text is rendered (LTR or RTL) Default is LeftToRight.
Font The font used to render the text content created by PdfFontManager
Height The height of the text block. If zero or negative, the available page height is used
Leading The line spacing multiplier used when rendering text. This value is multiplied by the font size to determine the space between lines. If zero, a default value of 1.2 is used
OnAfterPageRender Optional callback triggered after rendering on each document page, providing the full PdfTextPageRenderInfo for that page. The callback receives the geometric rectangle (including the rotated four-corner outline, the visible portion of the bounds and the page dimensions) together with the portion of text actually drawn on that page
OnBeforePageRender Optional callback triggered immediately before the text is drawn on each document page, providing the PdfTextPageRenderInfo for that page. The callback receives the geometric area where the text will be drawn together with the substring of text about to be rendered. Use this hook to insert per-page content under the text (custom backgrounds, gradients, side decorations) by drawing on the same page from inside the callback; any drawing performed there is placed in the page content stream before the text glyphs, so the result is layered underneath the text. In the non-rotated path the rectangle is derived from a layout simulation and matches the area used by the post-render callback in normal cases. In the rotated path the rectangle equals the actual used area because the text has already been laid out into an offscreen template at this point
OnPageRendered Optional callback triggered after rendering on each document page. Receives the document page number and the bounding box of the rendered area. The bounding box is relative to the container in which the text element was added. When the text is added directly to a page, the bounding box is page-relative. When the text is added to a template, including placeholder-based text rendered later, the bounding box is template-relative
Opacity Opacity of the rendered text (0..1). Default is 1 (fully opaque)
PageNumberOffset An optional offset (positive or negative) applied to the current page number when replacing the {page_number} placeholder. The default value is 0
RotationDegrees Rotation angle in degrees applied to the entire text block. Positive values rotate counter-clockwise. Default is 0 (no rotation)
RotationPivot Gets or sets the pivot point used when rotating this element. The pivot determines which point of the element's bounding box remains fixed during rotation. The default value is TopLeft.
Text The text content to be rendered. Supports placeholder variables such as {page_number} and {total_pages} which are replaced with their actual values in the rendered PDF. Placeholders also work when the text is added inside a PdfTemplate that is repeated across PDF pages.
TotalPagesOffset An optional offset (positive or negative) applied to the total number of pages when replacing the {total_pages} placeholder. The default value is 0
Width The width of the text block. If zero or negative, the available page width is used
X The horizontal position (from the left margin) of the text block in points
Y The vertical position (from the top margin) of the text block in points

Methods

Equals
(Inherited from Object)
Finalize
(Inherited from Object)
GetHashCode
(Inherited from Object)
GetType
(Inherited from Object)
MemberwiseClone
(Inherited from Object)
ToString
(Inherited from Object)

See Also