Method SetText
SetText(string)
Attaches a textual representation to the attachment, replacing any previously extracted text.
public void SetText(string text)
Parameters
textstringThe text to associate with this attachment.
Remarks
Useful for supplying OCR results or curated descriptions for image-based attachments. Subsequent calls to GetText(CancellationToken) and GetTextAsync(CancellationToken) will return this text.
SetText(string, int)
Attaches a textual representation to a specific page of the attachment, overriding any previously set text for that page.
public void SetText(string text, int pageIndex)
Parameters
textstringThe text to associate with the specified page.
pageIndexintZero-based index of the page to set.
Remarks
Useful for supplying OCR results or curated descriptions for specific pages of multi-page attachments. If the page index exceeds the current page count, empty page elements are inserted to fill the gap. Subsequent calls to GetPageText(int, CancellationToken) and GetPageTextAsync(int, CancellationToken) for the specified page will return this text.
Exceptions
- ArgumentOutOfRangeException
Thrown when
pageIndexis negative.
SetText(PageElement)
Attaches a textual representation to the attachment from a PageElement structure, overriding any previously set text elements.
public void SetText(PageElement pageElement)
Parameters
pageElementPageElementThe page element containing text content to associate with this attachment.
Remarks
The provided element is cloned internally. Subsequent text retrieval returns the attached element's content.
SetText(PageElement, int)
Attaches a textual representation to a specific page of the attachment, overriding any previously set text for that page.
public void SetText(PageElement pageElement, int pageIndex)
Parameters
pageElementPageElementThe page element containing text content to associate with the specified page.
pageIndexintZero-based index of the page to set.
Remarks
The provided element is cloned internally. If the page index exceeds the current page element count, empty page elements are inserted to fill the gap. Subsequent text retrieval for the specified page returns the attached element's content.
Exceptions
- ArgumentOutOfRangeException
Thrown when
pageIndexis negative or exceeds the attachment's page count.