Class RadFlowDocumentEditor
Defines utility class used for editing RadFlowDocument
Inheritance
Inherited Members
Namespace: Telerik.Windows.Documents.Flow.Model.Editing
Assembly: Telerik.Windows.Documents.Flow.dll
Syntax
public class RadFlowDocumentEditor
Constructors
RadFlowDocumentEditor(RadFlowDocument)
Initializes a new instance of the RadFlowDocumentEditor class.
Declaration
public RadFlowDocumentEditor(RadFlowDocument document)
Parameters
|
RadFlowDocument
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
|
CharacterProperties
The character formatting. |
Document
Gets the document being edited by this editor instance.
Declaration
public RadFlowDocument Document { get; }
Property Value
|
RadFlowDocument
The document. |
ParagraphFormatting
Gets the paragraph formatting applied to newly inserted paragraphs, including alignment, spacing, and indentation.
Declaration
public ParagraphProperties ParagraphFormatting { get; }
Property Value
|
ParagraphProperties
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
|
TableProperties
The table formatting. |
Methods
DeleteBookmark(String)
Removes the bookmark with the specified name from the document, deleting its range markers.
Declaration
public void DeleteBookmark(string name)
Parameters
|
System.String
name
The name. |
DeleteBookmark(Bookmark)
Removes the specified bookmark from the document, deleting its range markers.
Declaration
public void DeleteBookmark(Bookmark bookmark)
Parameters
|
Bookmark
bookmark
The bookmark. |
DeleteContent(InlineBase, InlineBase, Boolean)
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
|
InlineBase
start
The start inline element. |
|
InlineBase
end
The end inline element. |
|
System.Boolean
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
|
PermissionRange
permission
The permission. |
FindAll(String, Boolean, Boolean)
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
|
System.String
text
The searched text. |
|
System.Boolean
matchCase
Indicates whether the casing should be matched. |
|
System.Boolean
matchWholeWord
Indicates whether only whole words should be matched. |
Returns
|
System.Collections.ObjectModel.ReadOnlyCollection<FindResult>
Collection of type FindResult. |
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
|
System.Text.RegularExpressions.Regex
regex
The regex. |
Returns
|
System.Collections.ObjectModel.ReadOnlyCollection<FindResult>
Collection of type FindResult. |
InsertBookmark(String)
Creates a bookmark with the specified name and inserts its range markers at the current position.
Declaration
public Bookmark InsertBookmark(string name)
Parameters
|
System.String
name
The name. |
Returns
|
Bookmark
The created bookmark. |
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
|
System.String
name
The name. |
|
InlineBase
inlineStart
The inline start. The start of the bookmark will be inserted before this inline. |
|
InlineBase
inlineEnd
The inline end. The end of the bookmark will be inserted after this inline. |
Returns
|
Bookmark
The created bookmark. |
InsertBreak(BreakType)
Inserts a break of the specified type at the current position, handling table context for page and column breaks.
Declaration
public Break InsertBreak(BreakType type)
Parameters
|
BreakType
type
The type of the break. |
Returns
|
Break
The inserted break. |
InsertComment(String)
Creates a comment with the specified text and inserts its range markers at the current position.
Declaration
public Comment InsertComment(string text)
Parameters
|
System.String
text
The text of the comment. |
Returns
|
Comment
The created comment. |
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
|
System.String
text
The text. |
|
InlineBase
inlineStart
The inline start. The start of the comment will be inserted before this inline. |
|
InlineBase
inlineEnd
The inline end. The end of the comment will be inserted after this inline. |
Returns
|
Comment
|
InsertComment(Comment)
Inserts the range markers of an existing comment at the current position.
Declaration
public Comment InsertComment(Comment comment)
Parameters
|
Comment
comment
The comment. |
Returns
|
Comment
The comment. |
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
comment
The comment. |
|
InlineBase
inlineStart
The inline start. The start of the comment will be inserted before this inline. |
|
InlineBase
inlineEnd
The inline end. The end of the comment will be inserted after this inline. |
Returns
|
Comment
The comment. |
InsertDocument(RadFlowDocument)
Inserts the source document at the current position in the target document.
Declaration
public void InsertDocument(RadFlowDocument sourceDocument)
Parameters
|
RadFlowDocument
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
|
RadFlowDocument
sourceDocument
The source document. |
|
InsertDocumentOptions
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.
Declaration
public FieldInfo InsertField(string code, string result = "")
Parameters
|
System.String
code
The code fragment. |
|
System.String
result
The result fragment. |
Returns
|
FieldInfo
|
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
|
System.IO.Stream
stream
The stream. |
|
System.String
extension
The extension. |
Returns
|
FloatingImage
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
|
System.IO.Stream
stream
The image stream. |
|
System.String
extension
The image extension. |
|
System.Windows.Size
size
The size. |
Returns
|
FloatingImage
The floating image inline. |
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
|
ImageSource
source
The image source. |
|
System.Windows.Size
size
The size. |
Returns
|
FloatingImage
The floating image inline. |
InsertHyperlink(String, String, Boolean, String)
Inserts a hyperlink field with the specified display text and target URI or bookmark anchor, applying the Hyperlink style.
Declaration
public Hyperlink InsertHyperlink(string text, string uri, bool isAnchor, string toolTip = null)
Parameters
|
System.String
text
The text. |
|
System.String
uri
The URI. |
|
System.Boolean
isAnchor
True for hyperlinks pointing to a bookmark. |
|
System.String
toolTip
The tool tip. |
Returns
|
Hyperlink
|
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
|
System.IO.Stream
stream
The stream. |
|
System.String
extension
The extension. |
Returns
|
ImageInline
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
|
System.IO.Stream
stream
The image stream. |
|
System.String
extension
The image extension. |
|
System.Windows.Size
size
The size. |
Returns
|
ImageInline
The inserted image inline. |
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
|
ImageSource
source
The image source. |
|
System.Windows.Size
size
The size. |
Returns
|
ImageInline
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
|
InlineBase
inline
The inline. |
Returns
|
InlineBase
The inline. |
InsertLine(String)
Inserts text at the current position and immediately follows it with a new paragraph, returning the last inserted run.
Declaration
public Run InsertLine(string text)
Parameters
|
System.String
text
The text. |
Returns
|
Run
The inserted last inserted Run element. |
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
|
Paragraph
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
permissionRangeCredentials
The permission range credentials. |
|
InlineBase
inlineStart
The inline start. |
|
InlineBase
inlineEnd
The inline end. |
Returns
|
PermissionRange
|
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
permissionRangeCredentials
The permission range credentials. |
|
TableCell
cell
The cell. |
Returns
|
PermissionRange
|
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
permissionRangeCredentials
The permission range credentials. |
|
TableRow
row
The row. |
Returns
|
PermissionRange
|
InsertSection()
Inserts a new section at the current position, providing a container for blocks with independent page settings.
Declaration
public Section InsertSection()
Returns
|
Section
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
|
SdtProperties
properties
The properties of the SDT. |
Returns
|
SdtRangeStart
|
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
|
SdtProperties
properties
The properties of the SDT. |
|
DocumentElementBase
startElement
The start of the SDT will be inserted before the provided element. |
|
DocumentElementBase
endElement
The end of the SDT will be inserted after the provided element. |
Returns
|
SdtRangeStart
|
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
|
SdtType
type
The type for the SDT to be generated. |
Returns
|
SdtRangeStart
|
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
|
SdtType
type
The type for the SDT to be generated. |
|
DocumentElementBase
startElement
The start of the SDT will be inserted before the provided element. |
|
DocumentElementBase
endElement
The end of the SDT will be inserted after the provided element. |
Returns
|
SdtRangeStart
|
InsertTable()
Inserts an empty table at the current position with the current table formatting and moves the cursor after it.
Declaration
public Table InsertTable()
Returns
|
Table
The inserted table. |
InsertTable(Int32, Int32)
Inserts a table with the specified number of rows and columns, applying current formatting, and moves the cursor after it.
Declaration
public Table InsertTable(int rows, int columns)
Parameters
|
System.Int32
rows
The number of rows in the table. |
|
System.Int32
columns
The number of columns in the table. |
Returns
|
Table
The inserted table. |
InsertText(String)
Inserts text at the current position, creating runs with the current character formatting, and returns the last inserted run.
Declaration
public Run InsertText(string text)
Parameters
|
System.String
text
The text. |
Returns
|
Run
The inserted last inserted Run element. |
MoveToInlineEnd(InlineBase)
Positions the cursor immediately after the specified inline element.
Declaration
public void MoveToInlineEnd(InlineBase inline)
Parameters
|
InlineBase
inline
The inline. |
MoveToInlineStart(InlineBase)
Positions the cursor immediately before the specified inline element.
Declaration
public void MoveToInlineStart(InlineBase inline)
Parameters
|
InlineBase
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
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
paragraph
The paragraph. |
MoveToTableEnd(Table)
Positions the cursor immediately after the specified table.
Declaration
public void MoveToTableEnd(Table table)
Parameters
|
Table
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
|
System.String
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
|
System.String
password
The password. |
|
ProtectionMode
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
sdtRangeStart
The start of the SDT to be removed. |
RemoveStructuredDocumentTag(SdtRangeStart, Boolean)
Removes the content control, optionally preserving or deleting its enclosed content.
Declaration
public void RemoveStructuredDocumentTag(SdtRangeStart sdtRangeStart, bool removeContent)
Parameters
|
SdtRangeStart
sdtRangeStart
The start of the SDT to be removed. |
|
System.Boolean
removeContent
If true the content of the SDT is removed; else only the SDT is removed leaving behind the content. |
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
|
System.String
searchedText
The searched text. |
|
System.Action<CharacterProperties>
replacePropertiesAction
The action which replaces character properties. |
ReplaceStyling(String, Boolean, Boolean, 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
|
System.String
searchedText
The searched text. |
|
System.Boolean
matchCase
Indicates whether the casing should be matched. |
|
System.Boolean
matchWholeWord
Indicates whether only whole words should be matched. |
|
System.Action<CharacterProperties>
replacePropertiesAction
The action which replaces character properties. |
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
|
System.Text.RegularExpressions.Regex
regex
The regex. |
|
System.Action<CharacterProperties>
replacePropertiesAction
The action which replaces character properties. |
ReplaceText(String, IEnumerable<BlockBase>, Boolean, Boolean)
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
|
System.String
oldText
The searched text. |
|
System.Collections.Generic.IEnumerable<BlockBase>
blocks
The replace System.Collections.Generic.IEnumerable<T> elements. |
|
System.Boolean
matchCase
Indicates whether the casing should be matched. |
|
System.Boolean
matchWholeWord
Indicates whether only whole words should be matched. |
ReplaceText(String, IEnumerable<InlineBase>, Boolean, Boolean)
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
|
System.String
oldText
The searched text. |
|
System.Collections.Generic.IEnumerable<InlineBase>
inlines
The replace System.Collections.Generic.IEnumerable<T> elements. |
|
System.Boolean
matchCase
Indicates whether the casing should be matched. |
|
System.Boolean
matchWholeWord
Indicates whether only whole words should be matched. |
ReplaceText(String, String, Boolean, Boolean)
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
|
System.String
oldText
The searched text. |
|
System.String
newText
The replace text. |
|
System.Boolean
matchCase
Indicates whether the casing should be matched. |
|
System.Boolean
matchWholeWord
Indicates whether only whole words should be matched. |
ReplaceText(String, BlockBase, Boolean, Boolean)
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
|
System.String
oldText
The searched text. |
|
BlockBase
block
The replace BlockBase elements. |
|
System.Boolean
matchCase
Indicates whether the casing should be matched. |
|
System.Boolean
matchWholeWord
Indicates whether only whole words should be matched. |
ReplaceText(String, InlineBase, Boolean, Boolean)
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
|
System.String
oldText
The searched text. |
|
InlineBase
inline
The replace InlineBase elements. |
|
System.Boolean
matchCase
Indicates whether the casing should be matched. |
|
System.Boolean
matchWholeWord
Indicates whether only whole words should be matched. |
ReplaceText(Regex, IEnumerable<BlockBase>)
Searches the document for all matches of the specified regular expression and replaces them with the specified block elements.
Declaration
public void ReplaceText(Regex regex, IEnumerable<BlockBase> blocks)
Parameters
|
System.Text.RegularExpressions.Regex
regex
The regex. |
|
System.Collections.Generic.IEnumerable<BlockBase>
blocks
The replace System.Collections.Generic.IEnumerable<T> 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
|
System.Text.RegularExpressions.Regex
regex
The regex. |
|
System.Collections.Generic.IEnumerable<InlineBase>
inlines
The replace System.Collections.Generic.IEnumerable<T> elements. |
ReplaceText(Regex, String)
Searches the document for all matches of the specified regular expression and replaces them with the new text.
Declaration
public void ReplaceText(Regex regex, string newText)
Parameters
|
System.Text.RegularExpressions.Regex
regex
The regex. |
|
System.String
newText
The replace text. |
ReplaceText(Regex, BlockBase)
Searches the document for all matches of the specified regular expression and replaces them with the specified block element.
Declaration
public void ReplaceText(Regex regex, BlockBase block)
Parameters
|
System.Text.RegularExpressions.Regex
regex
The regex. |
|
BlockBase
block
The replace BlockBase element. |
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
|
System.Text.RegularExpressions.Regex
regex
The regex. |
|
InlineBase
inline
The replace InlineBase elements. |
SetSdtMessageProvider(IMessageProvider)
Configures a custom message provider to display messages during content control creation operations.
Declaration
public void SetSdtMessageProvider(IMessageProvider provider)
Parameters
|
IMessageProvider
provider
A custom message provider which implements IMessageProvider. |
SetWatermark(Watermark, Header)
Applies the specified watermark to the header, replacing any existing watermarks.
Declaration
public void SetWatermark(Watermark watermark, Header header)
Parameters
|
Watermark
watermark
The watermark. |
|
Header
header
The header. |
SetWatermark(Watermark, Section, HeaderFooterType)
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.
Declaration
public bool Unprotect(string password)
Parameters
|
System.String
password
The password. |
Returns
|
System.Boolean
|