ClassRadFlowDocumentEditor
Defines utility class used for editing RadFlowDocument
Definition
Namespace:Telerik.Windows.Documents.Flow.Model.Editing
Assembly:Telerik.Windows.Documents.Flow.dll
Syntax:
public class RadFlowDocumentEditor
Inheritance: objectRadFlowDocumentEditor
Constructors
RadFlowDocumentEditor(RadFlowDocument)
Initializes a new instance of the RadFlowDocumentEditor class.
Declaration
public RadFlowDocumentEditor(RadFlowDocument document)
Parameters
document
The document.
Properties
CharacterFormatting
Gets the character formatting applied to newly inserted text runs, including font, size, color, and styles.
Declaration
public CharacterProperties CharacterFormatting { get; }
Property Value
The character formatting.
Document
Gets the document being edited by this editor instance.
Declaration
public RadFlowDocument Document { get; }
Property Value
The document.
ParagraphFormatting
Gets the paragraph formatting applied to newly inserted paragraphs, including alignment, spacing, and indentation.
Declaration
public ParagraphProperties ParagraphFormatting { get; }
Property Value
The paragraph formatting.
TableFormatting
Gets the table formatting applied to newly inserted tables, including borders, cell spacing, and alignment.
Declaration
public TableProperties TableFormatting { get; }
Property Value
The table formatting.
Methods
DeleteBookmark(Bookmark)
Removes the specified bookmark from the document, deleting its range markers.
Declaration
public void DeleteBookmark(Bookmark bookmark)
Parameters
bookmark
The bookmark.
DeleteBookmark(string)
Removes the bookmark with the specified name from the document, deleting its range markers.
Declaration
public void DeleteBookmark(string name)
Parameters
name
The name.
DeleteContent(InlineBase, InlineBase, bool)
Removes all content between the start and end inline elements within the same block container, optionally including the boundary elements.
Declaration
public void DeleteContent(InlineBase start, InlineBase end, bool inclusive = true)
Parameters
start
The start inline element.
end
The end inline element.
inclusive
Indicates if the start end elements should be deleted as well.
DeletePermissionRange(PermissionRange)
Removes the specified permission range from the document, deleting its range markers.
Declaration
public void DeletePermissionRange(PermissionRange permission)
Parameters
permission
The permission.
FindAll(Regex)
Searches the document for all matches of the specified regular expression and returns their positions and associated runs.
Declaration
public ReadOnlyCollection<FindResult> FindAll(Regex regex)
Parameters
regex
The regex.
Returns
ReadOnlyCollection<FindResult>
Collection of type FindResult.
FindAll(string, bool, bool)
Searches the document for all occurrences of the specified text and returns their positions and associated runs.
Declaration
public ReadOnlyCollection<FindResult> FindAll(string text, bool matchCase = true, bool matchWholeWord = false)
Parameters
text
The searched text.
matchCase
Indicates whether the casing should be matched.
matchWholeWord
Indicates whether only whole words should be matched.
Returns
ReadOnlyCollection<FindResult>
Collection of type FindResult.
InsertBookmark(string)
Creates a bookmark with the specified name and inserts its range markers at the current position.
InsertBookmark(string, InlineBase, InlineBase)
Creates a bookmark with the specified name and inserts its range markers to span from before inlineStart to after inlineEnd.
Declaration
public Bookmark InsertBookmark(string name, InlineBase inlineStart, InlineBase inlineEnd)
Parameters
name
The name.
inlineStart
The inline start. The start of the bookmark will be inserted before this inline.
inlineEnd
The inline end. The end of the bookmark will be inserted after this inline.
Returns
The created bookmark.
InsertBreak(BreakType)
Inserts a break of the specified type at the current position, handling table context for page and column breaks.
InsertComment(Comment)
Inserts the range markers of an existing comment at the current position.
InsertComment(Comment, InlineBase, InlineBase)
Inserts the range markers of an existing comment to span from before inlineStart to after inlineEnd.
Declaration
public Comment InsertComment(Comment comment, InlineBase inlineStart, InlineBase inlineEnd)
Parameters
comment
The comment.
inlineStart
The inline start. The start of the comment will be inserted before this inline.
inlineEnd
The inline end. The end of the comment will be inserted after this inline.
Returns
The comment.
InsertComment(string)
Creates a comment with the specified text and inserts its range markers at the current position.
InsertComment(string, InlineBase, InlineBase)
Creates a comment with the specified text and inserts its range markers to span from before inlineStart to after inlineEnd.
Declaration
public Comment InsertComment(string text, InlineBase inlineStart, InlineBase inlineEnd)
Parameters
text
The text.
inlineStart
The inline start. The start of the comment will be inserted before this inline.
inlineEnd
The inline end. The end of the comment will be inserted after this inline.
Returns
InsertDocument(RadFlowDocument)
Inserts the source document at the current position in the target document.
Declaration
public void InsertDocument(RadFlowDocument sourceDocument)
Parameters
sourceDocument
The source document.
InsertDocument(RadFlowDocument, InsertDocumentOptions)
Merges the source document into this document at the current position using the specified options for conflict resolution.
Declaration
public void InsertDocument(RadFlowDocument sourceDocument, InsertDocumentOptions insertOptions)
Parameters
sourceDocument
The source document.
insertOptions
The insert options.
InsertField(string, string)
Inserts a field with the specified code and optional result text, creating the start, separator, and end markers.
InsertFloatingImage(ImageSource, Size)
Inserts a floating image with the specified source and explicit size, positioned absolutely with text wrapping support.
Declaration
public FloatingImage InsertFloatingImage(ImageSource source, Size size)
Parameters
source
The image source.
size
The size.
Returns
The floating image inline.
InsertFloatingImage(Stream, string)
Inserts a floating image from a stream at its original size, positioned absolutely with text wrapping support.
Declaration
public FloatingImage InsertFloatingImage(Stream stream, string extension)
Parameters
stream
The stream.
extension
The extension.
Returns
The inserted floating image.
InsertFloatingImage(Stream, string, Size)
Inserts a floating image from a stream with the specified size, positioned absolutely with text wrapping support.
Declaration
public FloatingImage InsertFloatingImage(Stream stream, string extension, Size size)
Parameters
stream
The image stream.
extension
The image extension.
size
The size.
Returns
The floating image inline.
InsertHyperlink(string, string, bool, string)
Inserts a hyperlink field with the specified display text and target URI or bookmark anchor, applying the Hyperlink style.
InsertImageInline(ImageSource, Size)
Inserts an inline image with the specified source and explicit size at the current position.
Declaration
public ImageInline InsertImageInline(ImageSource source, Size size)
Parameters
source
The image source.
size
The size.
Returns
The inserted image inline.
InsertImageInline(Stream, string)
Inserts an inline image from a stream at its original size, constrained to the page width excluding margins.
Declaration
public ImageInline InsertImageInline(Stream stream, string extension)
Parameters
stream
The stream.
extension
The extension.
Returns
The inserted inline image.
InsertImageInline(Stream, string, Size)
Inserts an inline image from a stream with the specified size at the current position.
Declaration
public ImageInline InsertImageInline(Stream stream, string extension, Size size)
Parameters
stream
The image stream.
extension
The image extension.
size
The size.
Returns
The inserted image inline.
InsertInline(InlineBase)
Inserts an existing inline element at the current position and advances the cursor past it.
Declaration
public InlineBase InsertInline(InlineBase inline)
Parameters
inline
The inline.
Returns
The inline.
InsertLine(string)
Inserts text at the current position and immediately follows it with a new paragraph, returning the last inserted run.
InsertParagraph()
Inserts a new paragraph at the current position with the current paragraph formatting and moves the cursor to its start.
Declaration
public Paragraph InsertParagraph()
Returns
The inserted Paragraph element.
InsertPermissionRange(PermissionRangeCredentials, InlineBase, InlineBase)
Creates a permission range with the specified credentials and inserts its markers to span from before inlineStart to after inlineEnd.
Declaration
public PermissionRange InsertPermissionRange(PermissionRangeCredentials permissionRangeCredentials, InlineBase inlineStart, InlineBase inlineEnd)
Parameters
permissionRangeCredentials
The permission range credentials.
inlineStart
The inline start.
inlineEnd
The inline end.
Returns
InsertPermissionRange(PermissionRangeCredentials, TableCell)
Creates a permission range with the specified credentials and inserts its markers to protect the entire table cell.
Declaration
public PermissionRange InsertPermissionRange(PermissionRangeCredentials permissionRangeCredentials, TableCell cell)
Parameters
permissionRangeCredentials
The permission range credentials.
cell
The cell.
Returns
InsertPermissionRange(PermissionRangeCredentials, TableRow)
Creates a permission range with the specified credentials and inserts its markers to protect the entire table row.
Declaration
public PermissionRange InsertPermissionRange(PermissionRangeCredentials permissionRangeCredentials, TableRow row)
Parameters
permissionRangeCredentials
The permission range credentials.
row
The row.
Returns
InsertSection()
Inserts a new section at the current position, providing a container for blocks with independent page settings.
Declaration
public Section InsertSection()
Returns
The inserted Section element.
InsertStructuredDocumentTag(SdtProperties)
Inserts a content control with the specified properties at the current cursor position and returns its start marker.
Declaration
public SdtRangeStart InsertStructuredDocumentTag(SdtProperties properties)
Parameters
properties
The properties of the SDT.
Returns
InsertStructuredDocumentTag(SdtProperties, DocumentElementBase, DocumentElementBase)
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.
Declaration
public SdtRangeStart InsertStructuredDocumentTag(SdtProperties properties, DocumentElementBase startElement, DocumentElementBase endElement)
Parameters
properties
The properties of the SDT.
startElement
The start of the SDT will be inserted before the provided element.
endElement
The end of the SDT will be inserted after the provided element.
Returns
InsertStructuredDocumentTag(SdtType)
Inserts a content control of the specified type at the current cursor position and returns its start marker.
Declaration
public SdtRangeStart InsertStructuredDocumentTag(SdtType type)
Parameters
type
The type for the SDT to be generated.
Returns
InsertStructuredDocumentTag(SdtType, DocumentElementBase, DocumentElementBase)
Inserts a content control wrapping the range from before the start element to after the end element and returns its start marker.
Declaration
public SdtRangeStart InsertStructuredDocumentTag(SdtType type, DocumentElementBase startElement, DocumentElementBase endElement)
Parameters
type
The type for the SDT to be generated.
startElement
The start of the SDT will be inserted before the provided element.
endElement
The end of the SDT will be inserted after the provided element.
Returns
InsertTable()
Inserts an empty table at the current position with the current table formatting and moves the cursor after it.
InsertTable(int, int)
Inserts a table with the specified number of rows and columns, applying current formatting, and moves the cursor after it.
InsertText(string)
Inserts text at the current position, creating runs with the current character formatting, and returns the last inserted run.
MoveToInlineEnd(InlineBase)
Positions the cursor immediately after the specified inline element.
Declaration
public void MoveToInlineEnd(InlineBase inline)
Parameters
inline
The inline.
MoveToInlineStart(InlineBase)
Positions the cursor immediately before the specified inline element.
Declaration
public void MoveToInlineStart(InlineBase inline)
Parameters
inline
The inline.
MoveToParagraphEnd(Paragraph)
Positions the cursor at the end of the specified paragraph, after all inline elements.
Declaration
public void MoveToParagraphEnd(Paragraph paragraph)
Parameters
paragraph
The paragraph.
MoveToParagraphStart(Paragraph)
Positions the cursor at the start of the specified paragraph, before all inline elements.
Declaration
public void MoveToParagraphStart(Paragraph paragraph)
Parameters
paragraph
The paragraph.
MoveToTableEnd(Table)
Positions the cursor immediately after the specified table.
Declaration
public void MoveToTableEnd(Table table)
Parameters
table
The table.
Protect(string)
Enables read-only protection on the document with the specified password, using SHA-512 hashing.
Declaration
public void Protect(string password)
Parameters
password
The password.
Protect(string, ProtectionMode)
Enables protection on the document with the specified password and protection mode, using SHA-512 hashing.
Declaration
public void Protect(string password, ProtectionMode protectionMode)
Parameters
password
The password.
protectionMode
The protection mode.
RemoveStructuredDocumentTag(SdtRangeStart)
Removes the content control and all its enclosed content from the document.
Declaration
public void RemoveStructuredDocumentTag(SdtRangeStart sdtRangeStart)
Parameters
sdtRangeStart
The start of the SDT to be removed.
RemoveStructuredDocumentTag(SdtRangeStart, bool)
Removes the content control, optionally preserving or deleting its enclosed content.
Declaration
public void RemoveStructuredDocumentTag(SdtRangeStart sdtRangeStart, bool removeContent)
Parameters
sdtRangeStart
The start of the SDT to be removed.
removeContent
If true the content of the SDT is removed; else only the SDT is removed leaving behind the content.
ReplaceStyling(Regex, Action<CharacterProperties>)
Searches the document for all matches of the specified regular expression and applies the formatting action to the matching runs.
Declaration
public void ReplaceStyling(Regex regex, Action<CharacterProperties> replacePropertiesAction)
Parameters
regex
The regex.
replacePropertiesAction
The action which replaces character properties.
ReplaceStyling(string, Action<CharacterProperties>)
Searches the document for all occurrences of the specified text and applies the formatting action to the matching runs.
Declaration
public void ReplaceStyling(string searchedText, Action<CharacterProperties> replacePropertiesAction)
Parameters
searchedText
The searched text.
replacePropertiesAction
The action which replaces character properties.
ReplaceStyling(string, bool, bool, Action<CharacterProperties>)
Searches the document for all occurrences of the specified text and applies the formatting action to the matching runs.
Declaration
public void ReplaceStyling(string searchedText, bool matchCase, bool matchWholeWord, Action<CharacterProperties> replacePropertiesAction)
Parameters
searchedText
The searched text.
matchCase
Indicates whether the casing should be matched.
matchWholeWord
Indicates whether only whole words should be matched.
replacePropertiesAction
The action which replaces character properties.
ReplaceText(Regex, BlockBase)
Searches the document for all matches of the specified regular expression and replaces them with the specified block element.
ReplaceText(Regex, IEnumerable<BlockBase>)
Searches the document for all matches of the specified regular expression and replaces them with the specified block elements.
ReplaceText(Regex, IEnumerable<InlineBase>)
Searches the document for all matches of the specified regular expression and replaces them with the specified inline elements.
Declaration
public void ReplaceText(Regex regex, IEnumerable<InlineBase> inlines)
Parameters
regex
The regex.
inlines
IEnumerable<InlineBase>
The replace IEnumerable<T> elements.
ReplaceText(Regex, InlineBase)
Searches the document for all matches of the specified regular expression and replaces them with the specified inline element.
Declaration
public void ReplaceText(Regex regex, InlineBase inline)
Parameters
regex
The regex.
inline
The replace InlineBase elements.
ReplaceText(Regex, string)
Searches the document for all matches of the specified regular expression and replaces them with the new text.
ReplaceText(string, BlockBase, bool, bool)
Searches the document for all occurrences of the specified text and replaces them with the specified block element.
Declaration
public void ReplaceText(string oldText, BlockBase block, bool matchCase = true, bool matchWholeWord = false)
Parameters
oldText
The searched text.
block
The replace BlockBase elements.
matchCase
Indicates whether the casing should be matched.
matchWholeWord
Indicates whether only whole words should be matched.
ReplaceText(string, IEnumerable<BlockBase>, bool, bool)
Searches the document for all occurrences of the specified text and replaces them with the specified block elements.
Declaration
public void ReplaceText(string oldText, IEnumerable<BlockBase> blocks, bool matchCase = true, bool matchWholeWord = false)
Parameters
oldText
The searched text.
blocks
IEnumerable<BlockBase>
The replace IEnumerable<T> elements.
matchCase
Indicates whether the casing should be matched.
matchWholeWord
Indicates whether only whole words should be matched.
ReplaceText(string, IEnumerable<InlineBase>, bool, bool)
Searches the document for all occurrences of the specified text and replaces them with the specified inline elements.
Declaration
public void ReplaceText(string oldText, IEnumerable<InlineBase> inlines, bool matchCase = true, bool matchWholeWord = false)
Parameters
oldText
The searched text.
inlines
IEnumerable<InlineBase>
The replace IEnumerable<T> elements.
matchCase
Indicates whether the casing should be matched.
matchWholeWord
Indicates whether only whole words should be matched.
ReplaceText(string, InlineBase, bool, bool)
Searches the document for all occurrences of the specified text and replaces them with the specified inline element.
Declaration
public void ReplaceText(string oldText, InlineBase inline, bool matchCase = true, bool matchWholeWord = false)
Parameters
oldText
The searched text.
inline
The replace InlineBase elements.
matchCase
Indicates whether the casing should be matched.
matchWholeWord
Indicates whether only whole words should be matched.
ReplaceText(string, string, bool, bool)
Searches the document for all occurrences of the specified text and replaces them with the new text.
Declaration
public void ReplaceText(string oldText, string newText, bool matchCase = true, bool matchWholeWord = false)
Parameters
oldText
The searched text.
newText
The replace text.
matchCase
Indicates whether the casing should be matched.
matchWholeWord
Indicates whether only whole words should be matched.
SetSdtMessageProvider(IMessageProvider)
Configures a custom message provider to display messages during content control creation operations.
Declaration
public void SetSdtMessageProvider(IMessageProvider provider)
Parameters
provider
A custom message provider which implements IMessageProvider.
SetWatermark(Watermark, Header)
Applies the specified watermark to the header, replacing any existing watermarks.
SetWatermark(Watermark, Section, HeaderFooterType)
Applies the specified watermark to the section's header of the specified type, creating the header if needed.
Declaration
public void SetWatermark(Watermark watermark, Section section, HeaderFooterType headerType)
Parameters
watermark
The watermark.
section
The section.
headerType
Type of the header.
Unprotect()
Removes all protection from the document without password validation.
Declaration
public void Unprotect()
Unprotect(string)
Attempts to remove document protection by validating the specified password against the stored hash.