New to Telerik Document ProcessingStart a free 30-day trial

Defines utility class used for editing RadFlowDocument

Definition

Namespace:Telerik.Windows.Documents.Flow.Model.Editing

Assembly:Telerik.Windows.Documents.Flow.dll

Syntax:

C#
public class RadFlowDocumentEditor

Inheritance: objectRadFlowDocumentEditor

Constructors

Initializes a new instance of the RadFlowDocumentEditor class.

C#
public RadFlowDocumentEditor(RadFlowDocument document)
Parameters:documentRadFlowDocument

The document.

Methods

Removes the specified bookmark from the document, deleting its range markers.

C#
public void DeleteBookmark(Bookmark bookmark)
Parameters:bookmarkBookmark

The bookmark.

Removes the bookmark with the specified name from the document, deleting its range markers.

C#
public void DeleteBookmark(string name)
Parameters:namestring

The name.

Removes all content between the start and end inline elements within the same block container, optionally including the boundary elements.

C#
public void DeleteContent(InlineBase start, InlineBase end, bool inclusive = true)
Parameters:startInlineBase

The start inline element.

endInlineBase

The end inline element.

inclusivebool

Indicates if the start end elements should be deleted as well.

Removes the specified permission range from the document, deleting its range markers.

C#
public void DeletePermissionRange(PermissionRange permission)
Parameters:permissionPermissionRange

The permission.

Searches the document for all matches of the specified regular expression and returns their positions and associated runs.

C#
public ReadOnlyCollection<FindResult> FindAll(Regex regex)
Parameters:regexRegex

The regex.

Returns:

ReadOnlyCollection<FindResult>

Collection of type FindResult.

Searches the document for all occurrences of the specified text and returns their positions and associated runs.

C#
public ReadOnlyCollection<FindResult> FindAll(string text, bool matchCase = true, bool matchWholeWord = false)
Parameters:textstring

The searched text.

matchCasebool

Indicates whether the casing should be matched.

matchWholeWordbool

Indicates whether only whole words should be matched.

Returns:

ReadOnlyCollection<FindResult>

Collection of type FindResult.

Creates a bookmark with the specified name and inserts its range markers to span from before inlineStart to after inlineEnd.

C#
public Bookmark InsertBookmark(string name, InlineBase inlineStart, InlineBase inlineEnd)
Parameters:namestring

The name.

inlineStartInlineBase

The inline start. The start of the bookmark will be inserted before this inline.

inlineEndInlineBase

The inline end. The end of the bookmark will be inserted after this inline.

Returns:

Bookmark

The created bookmark.

Creates a bookmark with the specified name and inserts its range markers at the current position.

C#
public Bookmark InsertBookmark(string name)
Parameters:namestring

The name.

Returns:

Bookmark

The created bookmark.

Inserts a break of the specified type at the current position, handling table context for page and column breaks.

C#
public Break InsertBreak(BreakType type)
Parameters:typeBreakType

The type of the break.

Returns:

Break

The inserted break.

Inserts the range markers of an existing comment to span from before inlineStart to after inlineEnd.

C#
public Comment InsertComment(Comment comment, InlineBase inlineStart, InlineBase inlineEnd)
Parameters:commentComment

The comment.

inlineStartInlineBase

The inline start. The start of the comment will be inserted before this inline.

inlineEndInlineBase

The inline end. The end of the comment will be inserted after this inline.

Returns:

Comment

The comment.

Inserts the range markers of an existing comment at the current position.

C#
public Comment InsertComment(Comment comment)
Parameters:commentComment

The comment.

Returns:

Comment

The comment.

Creates a comment with the specified text and inserts its range markers to span from before inlineStart to after inlineEnd.

C#
public Comment InsertComment(string text, InlineBase inlineStart, InlineBase inlineEnd)
Parameters:textstring

The text.

inlineStartInlineBase

The inline start. The start of the comment will be inserted before this inline.

inlineEndInlineBase

The inline end. The end of the comment will be inserted after this inline.

Returns:

Comment

Creates a comment with the specified text and inserts its range markers at the current position.

C#
public Comment InsertComment(string text)
Parameters:textstring

The text of the comment.

Returns:

Comment

The created comment.

Merges the source document into this document at the current position using the specified options for conflict resolution.

C#
public void InsertDocument(RadFlowDocument sourceDocument, InsertDocumentOptions insertOptions)
Parameters:sourceDocumentRadFlowDocument

The source document.

insertOptionsInsertDocumentOptions

The insert options.

Inserts the source document at the current position in the target document.

C#
public void InsertDocument(RadFlowDocument sourceDocument)
Parameters:sourceDocumentRadFlowDocument

The source document.

Inserts a field with the specified code and optional result text, creating the start, separator, and end markers.

C#
public FieldInfo InsertField(string code, string result = "")
Parameters:codestring

The code fragment.

resultstring

The result fragment.

Returns:

FieldInfo

Inserts a floating image with the specified source and explicit size, positioned absolutely with text wrapping support.

C#
public FloatingImage InsertFloatingImage(ImageSource source, Size size)
Parameters:sourceImageSource

The image source.

sizeSize

The size.

Returns:

FloatingImage

The floating image inline.

Inserts a floating image from a stream with the specified size, positioned absolutely with text wrapping support.

C#
public FloatingImage InsertFloatingImage(Stream stream, string extension, Size size)
Parameters:streamStream

The image stream.

extensionstring

The image extension.

sizeSize

The size.

Returns:

FloatingImage

The floating image inline.

Inserts a floating image from a stream at its original size, positioned absolutely with text wrapping support.

C#
public FloatingImage InsertFloatingImage(Stream stream, string extension)
Parameters:streamStream

The stream.

extensionstring

The extension.

Returns:

FloatingImage

The inserted floating image.

Inserts a hyperlink field with the specified display text and target URI or bookmark anchor, applying the Hyperlink style.

C#
public Hyperlink InsertHyperlink(string text, string uri, bool isAnchor, string toolTip = null)
Parameters:textstring

The text.

uristring

The URI.

isAnchorbool

True for hyperlinks pointing to a bookmark.

toolTipstring

The tool tip.

Returns:

Hyperlink

Inserts an inline image with the specified source and explicit size at the current position.

C#
public ImageInline InsertImageInline(ImageSource source, Size size)
Parameters:sourceImageSource

The image source.

sizeSize

The size.

Returns:

ImageInline

The inserted image inline.

Inserts an inline image from a stream with the specified size at the current position.

C#
public ImageInline InsertImageInline(Stream stream, string extension, Size size)
Parameters:streamStream

The image stream.

extensionstring

The image extension.

sizeSize

The size.

Returns:

ImageInline

The inserted image inline.

Inserts an inline image from a stream at its original size, constrained to the page width excluding margins.

C#
public ImageInline InsertImageInline(Stream stream, string extension)
Parameters:streamStream

The stream.

extensionstring

The extension.

Returns:

ImageInline

The inserted inline image.

Inserts an existing inline element at the current position and advances the cursor past it.

C#
public InlineBase InsertInline(InlineBase inline)
Parameters:inlineInlineBase

The inline.

Returns:

InlineBase

The inline.

Inserts text at the current position and immediately follows it with a new paragraph, returning the last inserted run.

C#
public Run InsertLine(string text)
Parameters:textstring

The text.

Returns:

Run

The inserted last inserted Run element.

Inserts a new paragraph at the current position with the current paragraph formatting and moves the cursor to its start.

C#
public Paragraph InsertParagraph()
Returns:

Paragraph

The inserted Paragraph element.

Creates a permission range with the specified credentials and inserts its markers to span from before inlineStart to after inlineEnd.

C#
public PermissionRange InsertPermissionRange(PermissionRangeCredentials permissionRangeCredentials, InlineBase inlineStart, InlineBase inlineEnd)
Parameters:permissionRangeCredentialsPermissionRangeCredentials

The permission range credentials.

inlineStartInlineBase

The inline start.

inlineEndInlineBase

The inline end.

Returns:

PermissionRange

Creates a permission range with the specified credentials and inserts its markers to protect the entire table cell.

C#
public PermissionRange InsertPermissionRange(PermissionRangeCredentials permissionRangeCredentials, TableCell cell)
Parameters:permissionRangeCredentialsPermissionRangeCredentials

The permission range credentials.

cellTableCell

The cell.

Returns:

PermissionRange

Creates a permission range with the specified credentials and inserts its markers to protect the entire table row.

C#
public PermissionRange InsertPermissionRange(PermissionRangeCredentials permissionRangeCredentials, TableRow row)
Parameters:permissionRangeCredentialsPermissionRangeCredentials

The permission range credentials.

rowTableRow

The row.

Returns:

PermissionRange

Inserts a new section at the current position, providing a container for blocks with independent page settings.

C#
public Section InsertSection()
Returns:

Section

The inserted Section element.

Inserts a content control with the specified properties wrapping the range from before the start element to after the end element and returns its start marker.

C#
public SdtRangeStart InsertStructuredDocumentTag(SdtProperties properties, DocumentElementBase startElement, DocumentElementBase endElement)
Parameters:propertiesSdtProperties

The properties of the SDT.

startElementDocumentElementBase

The start of the SDT will be inserted before the provided element.

endElementDocumentElementBase

The end of the SDT will be inserted after the provided element.

Returns:

SdtRangeStart

Inserts a content control with the specified properties at the current cursor position and returns its start marker.

C#
public SdtRangeStart InsertStructuredDocumentTag(SdtProperties properties)
Parameters:propertiesSdtProperties

The properties of the SDT.

Returns:

SdtRangeStart

Inserts a content control wrapping the range from before the start element to after the end element and returns its start marker.

C#
public SdtRangeStart InsertStructuredDocumentTag(SdtType type, DocumentElementBase startElement, DocumentElementBase endElement)
Parameters:typeSdtType

The type for the SDT to be generated.

startElementDocumentElementBase

The start of the SDT will be inserted before the provided element.

endElementDocumentElementBase

The end of the SDT will be inserted after the provided element.

Returns:

SdtRangeStart

Inserts a content control of the specified type at the current cursor position and returns its start marker.

C#
public SdtRangeStart InsertStructuredDocumentTag(SdtType type)
Parameters:typeSdtType

The type for the SDT to be generated.

Returns:

SdtRangeStart

Inserts an empty table at the current position with the current table formatting and moves the cursor after it.

C#
public Table InsertTable()
Returns:

Table

The inserted table.

Inserts a table with the specified number of rows and columns, applying current formatting, and moves the cursor after it.

C#
public Table InsertTable(int rows, int columns)
Parameters:rowsint

The number of rows in the table.

columnsint

The number of columns in the table.

Returns:

Table

The inserted table.

Inserts text at the current position, creating runs with the current character formatting, and returns the last inserted run.

C#
public Run InsertText(string text)
Parameters:textstring

The text.

Returns:

Run

The inserted last inserted Run element.

Positions the cursor immediately after the specified inline element.

C#
public void MoveToInlineEnd(InlineBase inline)
Parameters:inlineInlineBase

The inline.

Positions the cursor immediately before the specified inline element.

C#
public void MoveToInlineStart(InlineBase inline)
Parameters:inlineInlineBase

The inline.

Positions the cursor at the end of the specified paragraph, after all inline elements.

C#
public void MoveToParagraphEnd(Paragraph paragraph)
Parameters:paragraphParagraph

The paragraph.

Positions the cursor at the start of the specified paragraph, before all inline elements.

C#
public void MoveToParagraphStart(Paragraph paragraph)
Parameters:paragraphParagraph

The paragraph.

Positions the cursor immediately after the specified table.

C#
public void MoveToTableEnd(Table table)
Parameters:tableTable

The table.

Enables protection on the document with the specified password and protection mode, using SHA-512 hashing.

C#
public void Protect(string password, ProtectionMode protectionMode)
Parameters:passwordstring

The password.

protectionModeProtectionMode

The protection mode.

Enables read-only protection on the document with the specified password, using SHA-512 hashing.

C#
public void Protect(string password)
Parameters:passwordstring

The password.

Removes the content control, optionally preserving or deleting its enclosed content.

C#
public void RemoveStructuredDocumentTag(SdtRangeStart sdtRangeStart, bool removeContent)
Parameters:sdtRangeStartSdtRangeStart

The start of the SDT to be removed.

removeContentbool

If true the content of the SDT is removed; else only the SDT is removed leaving behind the content.

Removes the content control and all its enclosed content from the document.

C#
public void RemoveStructuredDocumentTag(SdtRangeStart sdtRangeStart)
Parameters:sdtRangeStartSdtRangeStart

The start of the SDT to be removed.

Searches the document for all matches of the specified regular expression and applies the formatting action to the matching runs.

C#
public void ReplaceStyling(Regex regex, Action<CharacterProperties> replacePropertiesAction)
Parameters:regexRegex

The regex.

replacePropertiesActionAction<CharacterProperties>

The action which replaces character properties.

Searches the document for all occurrences of the specified text and applies the formatting action to the matching runs.

C#
public void ReplaceStyling(string searchedText, Action<CharacterProperties> replacePropertiesAction)
Parameters:searchedTextstring

The searched text.

replacePropertiesActionAction<CharacterProperties>

The action which replaces character properties.

Searches the document for all occurrences of the specified text and applies the formatting action to the matching runs.

C#
public void ReplaceStyling(string searchedText, bool matchCase, bool matchWholeWord, Action<CharacterProperties> replacePropertiesAction)
Parameters:searchedTextstring

The searched text.

matchCasebool

Indicates whether the casing should be matched.

matchWholeWordbool

Indicates whether only whole words should be matched.

replacePropertiesActionAction<CharacterProperties>

The action which replaces character properties.

Searches the document for all matches of the specified regular expression and replaces them with the specified block element.

C#
public void ReplaceText(Regex regex, BlockBase block)
Parameters:regexRegex

The regex.

blockBlockBase

The replace BlockBase element.

Searches the document for all matches of the specified regular expression and replaces them with the specified block elements.

C#
public void ReplaceText(Regex regex, IEnumerable<BlockBase> blocks)
Parameters:regexRegex

The regex.

blocksIEnumerable<BlockBase>

The replace IEnumerable<T> elements.

Searches the document for all matches of the specified regular expression and replaces them with the specified inline elements.

C#
public void ReplaceText(Regex regex, IEnumerable<InlineBase> inlines)
Parameters:regexRegex

The regex.

inlinesIEnumerable<InlineBase>

The replace IEnumerable<T> elements.

Searches the document for all matches of the specified regular expression and replaces them with the specified inline element.

C#
public void ReplaceText(Regex regex, InlineBase inline)
Parameters:regexRegex

The regex.

inlineInlineBase

The replace InlineBase elements.

Searches the document for all matches of the specified regular expression and replaces them with the new text.

C#
public void ReplaceText(Regex regex, string newText)
Parameters:regexRegex

The regex.

newTextstring

The replace text.

Searches the document for all occurrences of the specified text and replaces them with the specified block element.

C#
public void ReplaceText(string oldText, BlockBase block, bool matchCase = true, bool matchWholeWord = false)
Parameters:oldTextstring

The searched text.

blockBlockBase

The replace BlockBase elements.

matchCasebool

Indicates whether the casing should be matched.

matchWholeWordbool

Indicates whether only whole words should be matched.

Searches the document for all occurrences of the specified text and replaces them with the specified block elements.

C#
public void ReplaceText(string oldText, IEnumerable<BlockBase> blocks, bool matchCase = true, bool matchWholeWord = false)
Parameters:oldTextstring

The searched text.

blocksIEnumerable<BlockBase>

The replace IEnumerable<T> elements.

matchCasebool

Indicates whether the casing should be matched.

matchWholeWordbool

Indicates whether only whole words should be matched.

Searches the document for all occurrences of the specified text and replaces them with the specified inline elements.

C#
public void ReplaceText(string oldText, IEnumerable<InlineBase> inlines, bool matchCase = true, bool matchWholeWord = false)
Parameters:oldTextstring

The searched text.

inlinesIEnumerable<InlineBase>

The replace IEnumerable<T> elements.

matchCasebool

Indicates whether the casing should be matched.

matchWholeWordbool

Indicates whether only whole words should be matched.

Searches the document for all occurrences of the specified text and replaces them with the specified inline element.

C#
public void ReplaceText(string oldText, InlineBase inline, bool matchCase = true, bool matchWholeWord = false)
Parameters:oldTextstring

The searched text.

inlineInlineBase

The replace InlineBase elements.

matchCasebool

Indicates whether the casing should be matched.

matchWholeWordbool

Indicates whether only whole words should be matched.

Searches the document for all occurrences of the specified text and replaces them with the new text.

C#
public void ReplaceText(string oldText, string newText, bool matchCase = true, bool matchWholeWord = false)
Parameters:oldTextstring

The searched text.

newTextstring

The replace text.

matchCasebool

Indicates whether the casing should be matched.

matchWholeWordbool

Indicates whether only whole words should be matched.

Configures a custom message provider to display messages during content control creation operations.

C#
public void SetSdtMessageProvider(IMessageProvider provider)
Parameters:providerIMessageProvider

A custom message provider which implements IMessageProvider.

Applies the specified watermark to the header, replacing any existing watermarks.

C#
public void SetWatermark(Watermark watermark, Header header)
Parameters:watermarkWatermark

The watermark.

headerHeader

The header.

Applies the specified watermark to the section's header of the specified type, creating the header if needed.

C#
public void SetWatermark(Watermark watermark, Section section, HeaderFooterType headerType)
Parameters:watermarkWatermark

The watermark.

sectionSection

The section.

headerTypeHeaderFooterType

Type of the header.

Removes all protection from the document without password validation.

C#
public void Unprotect()

Attempts to remove document protection by validating the specified password against the stored hash.

C#
public bool Unprotect(string password)
Parameters:passwordstring

The password.

Returns:

bool

True if the password is correct; otherwise, False.

Properties

Gets the character formatting applied to newly inserted text runs, including font, size, color, and styles.

C#
public CharacterProperties CharacterFormatting { get; }
Property Value:

The character formatting.

Gets the document being edited by this editor instance.

C#
public RadFlowDocument Document { get; }
Property Value:

The document.

Gets the paragraph formatting applied to newly inserted paragraphs, including alignment, spacing, and indentation.

C#
public ParagraphProperties ParagraphFormatting { get; }
Property Value:

The paragraph formatting.

Gets the table formatting applied to newly inserted tables, including borders, cell spacing, and alignment.

C#
public TableProperties TableFormatting { get; }
Property Value:

The table formatting.

In this article
DefinitionConstructorsRadFlowDocumentEditor(RadFlowDocument)MethodsDeleteBookmark(Bookmark)DeleteBookmark(string)DeleteContent(InlineBase, InlineBase, bool)DeletePermissionRange(PermissionRange)FindAll(Regex)FindAll(string, bool, bool)InsertBookmark(string, InlineBase, InlineBase)InsertBookmark(string)InsertBreak(BreakType)InsertComment(Comment, InlineBase, InlineBase)InsertComment(Comment)InsertComment(string, InlineBase, InlineBase)InsertComment(string)InsertDocument(RadFlowDocument, InsertDocumentOptions)InsertDocument(RadFlowDocument)InsertField(string, string)InsertFloatingImage(ImageSource, Size)InsertFloatingImage(Stream, string, Size)InsertFloatingImage(Stream, string)InsertHyperlink(string, string, bool, string)InsertImageInline(ImageSource, Size)InsertImageInline(Stream, string, Size)InsertImageInline(Stream, string)InsertInline(InlineBase)InsertLine(string)InsertParagraph()InsertPermissionRange(PermissionRangeCredentials, InlineBase, InlineBase)InsertPermissionRange(PermissionRangeCredentials, TableCell)InsertPermissionRange(PermissionRangeCredentials, TableRow)InsertSection()InsertStructuredDocumentTag(SdtProperties, DocumentElementBase, DocumentElementBase)InsertStructuredDocumentTag(SdtProperties)InsertStructuredDocumentTag(SdtType, DocumentElementBase, DocumentElementBase)InsertStructuredDocumentTag(SdtType)InsertTable()InsertTable(int, int)InsertText(string)MoveToInlineEnd(InlineBase)MoveToInlineStart(InlineBase)MoveToParagraphEnd(Paragraph)MoveToParagraphStart(Paragraph)MoveToTableEnd(Table)Protect(string, ProtectionMode)Protect(string)RemoveStructuredDocumentTag(SdtRangeStart, bool)RemoveStructuredDocumentTag(SdtRangeStart)ReplaceStyling(Regex, Action<CharacterProperties>)ReplaceStyling(string, Action<CharacterProperties>)ReplaceStyling(string, bool, bool, Action<CharacterProperties>)ReplaceText(Regex, BlockBase)ReplaceText(Regex, IEnumerable<BlockBase>)ReplaceText(Regex, IEnumerable<InlineBase>)ReplaceText(Regex, InlineBase)ReplaceText(Regex, string)ReplaceText(string, BlockBase, bool, bool)ReplaceText(string, IEnumerable<BlockBase>, bool, bool)ReplaceText(string, IEnumerable<InlineBase>, bool, bool)ReplaceText(string, InlineBase, bool, bool)ReplaceText(string, string, bool, bool)SetSdtMessageProvider(IMessageProvider)SetWatermark(Watermark, Header)SetWatermark(Watermark, Section, HeaderFooterType)Unprotect()Unprotect(string)PropertiesCharacterFormattingDocumentParagraphFormattingTableFormatting
Not finding the help you need?
Contact Support