Class PdfTextObject
PdfTextObject represents a text object within a PDF document. It is derived from PdfPageObject and provides the ability to manipulate text content on a PDF page.
public class PdfTextObject : PdfPageObject, IDisposable
- Inheritance
-
PdfTextObject
- Implements
- Inherited Members
Methods
GetFont()
Retrieves the font associated with the current text object.
public PdfFont GetFont()
Returns
Exceptions
- dotPDFiumException
Thrown if the font cannot be retrieved from the text object.
GetFontSize()
Retrieves the font size of the text object.
public float GetFontSize()
Returns
Exceptions
- dotPDFiumException
Thrown if the font size cannot be retrieved from the text object.
GetRenderMode()
Retrieves the text rendering mode of the current PDF text object.
public PdfTextRenderMode GetRenderMode()
Returns
- PdfTextRenderMode
A PdfTextRenderMode value representing the rendering mode of the text object.
Exceptions
- dotPDFiumException
Thrown if the text rendering mode retrieved is not a valid PdfTextRenderMode value.
GetText(PdfPage)
Extracts the text content from the specified PDF page.
public string GetText(PdfPage page)
Parameters
Returns
- string
A string containing the text content of the specified PDF page. Returns an empty string if the page contains no text or if the extraction fails.
Remarks
The extracted text may include a null terminator at the end, which is removed before returning the result.
SetRenderMode(PdfTextRenderMode)
Sets the text rendering mode for the current PDF text object.
public void SetRenderMode(PdfTextRenderMode mode)
Parameters
mode
PdfTextRenderModeThe text rendering mode to apply. This determines how text is rendered, such as fill, stroke, or a combination of both.
Remarks
The mode
parameter specifies the rendering style for text, which can
include options such as filling, stroking, or clipping text. Ensure that the text object is valid and properly
initialized before calling this method.
Exceptions
- dotPDFiumException
Thrown if the operation fails due to an error in the underlying PDF library.
SetText(string)
Sets the text content of the PdfTextObject. This method allows you to modify the text displayed in the text object.
public void SetText(string text)
Parameters
text
string