RtfLosslessEditor
OfficeIMO.Rtf
Applies targeted edits to an RTF syntax tree while preserving untouched raw RTF.
Inheritance
- object
- RtfLosslessEditor
Usage
Explore 2 API references to this type
This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.
Returned or exposed by 2
- Method RtfReadResult.EditLossless
- Method RtfSyntaxTree.EditLossless
Constructors
public RtfLosslessEditor(RtfReadResult readResult) #Creates a lossless editor from a read result.
Parameters
- readResult OfficeIMO.Rtf.RtfReadResult
public RtfLosslessEditor(RtfSyntaxTree syntaxTree) #Creates a lossless editor from an RTF syntax tree.
Parameters
- syntaxTree OfficeIMO.Rtf.Syntax.RtfSyntaxTree
Methods
public void AddRevisionSaveId(int id) #Adds a revision save id to the root rsidtbl destination, replacing duplicate entries with a single occurrence.
Parameters
- id int
public void AppendParagraph(string text) #Appends a plain RTF paragraph at the end of the root document group while preserving existing syntax.
Parameters
- text string
public void InsertRootParagraph(int index, string text) #Inserts a plain paragraph at a direct root-node index.
Parameters
- index int
- text string
public void InsertRootRtf(int index, string rtfFragment) #Inserts a validated raw RTF fragment at a direct root-node index.
Parameters
- index int
- rtfFragment string
public void MoveRootNodes(int fromIndex, int count, int toIndex) #Moves direct root syntax nodes to their final root-node index.
Parameters
- fromIndex int
- count int
- toIndex int
public void RemoveColor(int index) #Removes the one-based color-table entry when it exists while preserving the rest of the RTF stream.
Parameters
- index int
public void RemoveFileReference(int id) #Removes all file-table references with the supplied identifier while preserving the rest of the RTF stream.
Parameters
- id int
public void RemoveFont(int id) #Removes all font-table entries with the supplied RTF font identifier while preserving the rest of the RTF stream.
Parameters
- id int
public void RemovePageBorder(RtfPageBorderSide side) #Removes one root page-border side while preserving untouched RTF syntax.
Parameters
- side OfficeIMO.Rtf.RtfPageBorderSide
public void RemoveRevisionAuthor(int index) #Removes the zero-based revision author table entry when it exists while preserving the rest of the RTF stream.
Parameters
- index int
public void RemoveRevisionSaveId(int id) #Removes all matching revision save ids from the root rsidtbl destination while preserving the rest of the RTF stream.
Parameters
- id int
public int RemoveRootNodes(int index, int count = 1) #Removes direct root syntax nodes and returns the number removed.
Parameters
- index int
- count int = 1
Returns
intpublic void RemoveStyle(int id, RtfStyleKind kind = Paragraph) #Removes all stylesheet entries matching the supplied id and kind while preserving the rest of the RTF stream.
Parameters
- id int
- kind OfficeIMO.Rtf.RtfStyleKind = Paragraph
public void RemoveUserProperty(string name) #Removes all custom document properties with the supplied name while preserving the rest of the RTF stream.
Parameters
- name string
public void RemoveXmlNamespace(int id) #Removes all XML namespace declarations with the supplied id while preserving the rest of the RTF stream.
Parameters
- id int
public int ReplaceDestinationContent(string destination, string rtfFragment) #Replaces the content of every matching destination group, including headers and footers.
Parameters
- destination string
- rtfFragment string
Returns
intpublic bool ReplaceImage(int imageIndex, RtfImage replacement) #Replaces the nth picture destination while preserving all unrelated syntax.
Parameters
- imageIndex int
- replacement OfficeIMO.Rtf.RtfImage
Returns
boolpublic int ReplaceText(string oldText, string newText, StringComparison comparison = Ordinal) #Replaces literal visible text contained inside individual text nodes.
Parameters
- oldText string
- newText string
- comparison System.StringComparison = Ordinal
Returns
intpublic Task SaveLosslessAsync(string path, CancellationToken cancellationToken = default) #Saves the edited syntax tree to a file without semantic normalization.
Parameters
- path string
- cancellationToken System.Threading.CancellationToken = default
Returns
Taskpublic Task SaveLosslessAsync(Stream stream, CancellationToken cancellationToken = default) #Saves the edited syntax tree to a stream without semantic normalization.
Parameters
- stream System.IO.Stream
- cancellationToken System.Threading.CancellationToken = default
Returns
Taskpublic void SetAnsiCodePage(int? codePage) #Adds, replaces, or removes the root ANSI code page control while preserving the rest of the RTF stream.
Parameters
- codePage int?
public void SetCharacterSet(RtfDocumentCharacterSet characterSet, int? ansiCodePage = null) #Sets the root document character set declaration and optionally replaces the root ANSI code page.
Parameters
- characterSet OfficeIMO.Rtf.RtfDocumentCharacterSet
- ansiCodePage int? = null
public void SetColor(int index, RtfColor color) #Adds or replaces a one-based color-table entry while preserving the rest of the RTF stream.
Parameters
- index int
- color OfficeIMO.Rtf.RtfColor
public void SetColor(int index, byte red, byte green, byte blue) #Adds or replaces a one-based RGB color-table entry while preserving the rest of the RTF stream.
Parameters
- index int
- red byte
- green byte
- blue byte
public void SetDefaultFont(int? fontId) #Adds, replaces, or removes the root default font id control while preserving the rest of the RTF stream.
Parameters
- fontId int?
public void SetDefaultLanguages(int? defaultLanguageId = null, int? defaultFarEastLanguageId = null, int? defaultAlternateLanguageId = null) #Adds, replaces, or removes root default language controls while preserving untouched RTF syntax.
Parameters
- defaultLanguageId int? = null
- defaultFarEastLanguageId int? = null
- defaultAlternateLanguageId int? = null
public void SetDefaultTabWidth(int? twips) #Adds, replaces, or removes the root default tab width while preserving untouched RTF syntax.
Parameters
- twips int?
public void SetDocumentDirection(RtfTextDirection? direction) #Adds, replaces, or removes the root document direction control while preserving untouched RTF syntax.
Parameters
- direction OfficeIMO.Rtf.RtfTextDirection?
public void SetDocumentHyphenation(bool? automatic = null, bool? caps = null, int? consecutiveLimit = null, int? zoneTwips = null) #Adds, replaces, or removes root document hyphenation controls while preserving untouched RTF syntax.
Parameters
- automatic bool? = null
- caps bool? = null
- consecutiveLimit int? = null
- zoneTwips int? = null
public void SetDocumentLayoutOptions(bool? widowOrphanControl = null, bool? facingPages = null, bool? mirrorMargins = null) #Adds, replaces, or removes root document layout option controls while preserving untouched RTF syntax.
Parameters
- widowOrphanControl bool? = null
- facingPages bool? = null
- mirrorMargins bool? = null
public void SetDocumentProtection(bool? forms = null, bool? revisions = null, bool? annotations = null, bool? readOnly = null) #Adds, replaces, or removes root document protection controls while preserving untouched RTF syntax.
Parameters
- forms bool? = null
- revisions bool? = null
- annotations bool? = null
- readOnly bool? = null
public void SetDocumentVariable(string name, string? value) #Adds, replaces, or removes a root document variable while preserving the rest of the RTF stream. Pass null for value to remove all variables with the supplied name.
Parameters
- name string
- value string?
public void SetDocumentView(int? kind = null, int? scale = null, int? zoomKind = null, int? backspaceBehavior = null) #Adds, replaces, or removes root document view controls while preserving untouched RTF syntax.
Parameters
- kind int? = null
- scale int? = null
- zoomKind int? = null
- backspaceBehavior int? = null
public void SetDrawingGrid(int? horizontalSpacingTwips = null, int? verticalSpacingTwips = null, int? horizontalOriginTwips = null, int? verticalOriginTwips = null, int? horizontalShow = null, int? verticalShow = null, bool? snapToGrid = null, bool? useMargins = null) #Adds, replaces, or removes root drawing grid controls while preserving untouched RTF syntax.
Parameters
- horizontalSpacingTwips int? = null
- verticalSpacingTwips int? = null
- horizontalOriginTwips int? = null
- verticalOriginTwips int? = null
- horizontalShow int? = null
- verticalShow int? = null
- snapToGrid bool? = null
- useMargins bool? = null
public void SetFileReference(RtfFileReference fileReference) #Adds or replaces a file-table reference in the root filetbl destination while preserving the rest of the RTF stream.
Parameters
- fileReference OfficeIMO.Rtf.RtfFileReference
public void SetFileReference(int id, string path) #Adds or replaces a file-table reference with the supplied identifier and path.
Parameters
- id int
- path string
public void SetFont(RtfFont font) #Adds or replaces a font-table entry by its RTF font identifier while preserving the rest of the RTF stream.
Parameters
- font OfficeIMO.Rtf.RtfFont
public void SetFont(int id, string name) #Adds or replaces a font-table entry by its RTF font identifier and display name.
Parameters
- id int
- name string
public void SetGenerator(string? value) #Adds, replaces, or removes the root generator metadata group while preserving the rest of the RTF stream.
Parameters
- value string?
public void SetGutterWidth(int? gutterWidthTwips) #Adds, replaces, or removes the root document gutter width while preserving untouched RTF syntax.
Parameters
- gutterWidthTwips int?
public void SetInfo(RtfDocumentInfoField field, string? value) #Adds, replaces, or removes a document information field while preserving the rest of the RTF stream.
Parameters
- field OfficeIMO.Rtf.RtfDocumentInfoField
- value string?
public void SetInfoNumber(RtfDocumentInfoNumberField field, int? value) #Adds, replaces, or removes a numeric document information field while preserving the rest of the RTF stream.
Parameters
- field OfficeIMO.Rtf.RtfDocumentInfoNumberField
- value int?
public void SetInfoTimestamp(RtfDocumentInfoTimestampField field, DateTime? value) #Adds, replaces, or removes a document information timestamp while preserving the rest of the RTF stream.
Parameters
- field OfficeIMO.Rtf.RtfDocumentInfoTimestampField
- value System.DateTime?
public void SetLandscape(bool enabled = true) #Adds or removes the root landscape orientation control while preserving untouched RTF syntax.
Parameters
- enabled bool = true
public void SetMargins(int? leftTwips = null, int? rightTwips = null, int? topTwips = null, int? bottomTwips = null) #Adds, replaces, or removes root document margin controls while preserving untouched RTF syntax.
Parameters
- leftTwips int? = null
- rightTwips int? = null
- topTwips int? = null
- bottomTwips int? = null
public void SetPageBorder(RtfPageBorderSide side, RtfPageBorderStyle style, int? width = null, int? space = null, int? colorIndex = null, bool frame = false) #Adds, replaces, or removes one root page-border side while preserving untouched RTF syntax.
Parameters
- side OfficeIMO.Rtf.RtfPageBorderSide
- style OfficeIMO.Rtf.RtfPageBorderStyle
- width int? = null
- space int? = null
- colorIndex int? = null
- frame bool = false
public void SetPageBorderOptions(bool? includeHeader = null, bool? includeFooter = null, bool? snapToPageBorder = null, RtfPageBorderScope? scope = null, bool? displayBehindText = null, RtfPageBorderOffset? offsetFrom = null) #Adds, replaces, or removes root page-border option controls while preserving untouched RTF syntax.
Parameters
- includeHeader bool? = null
- includeFooter bool? = null
- snapToPageBorder bool? = null
- scope OfficeIMO.Rtf.RtfPageBorderScope? = null
- displayBehindText bool? = null
- offsetFrom OfficeIMO.Rtf.RtfPageBorderOffset? = null
public void SetPageNumbering(int? start = null, bool? restart = null, RtfPageNumberFormat? format = null, int? positionXTwips = null, int? positionYTwips = null) #Adds, replaces, or removes root page-numbering controls while preserving untouched RTF syntax.
Parameters
- start int? = null
- restart bool? = null
- format OfficeIMO.Rtf.RtfPageNumberFormat? = null
- positionXTwips int? = null
- positionYTwips int? = null
public void SetPageSize(int? widthTwips, int? heightTwips) #Adds, replaces, or removes root document paper size controls while preserving untouched RTF syntax.
Parameters
- widthTwips int?
- heightTwips int?
public void SetPrinterPaper(int? paperSize = null, int? firstPageSource = null, int? otherPagesSource = null) #Adds, replaces, or removes root printer paper metadata controls while preserving untouched RTF syntax.
Parameters
- paperSize int? = null
- firstPageSource int? = null
- otherPagesSource int? = null
public void SetRevisionAuthor(int index, string name) #Adds or replaces a zero-based revision author table entry while preserving the rest of the RTF stream.
Parameters
- index int
- name string
public void SetRevisionRootSaveId(int? id) #Adds, replaces, or removes the root revision save id in the root rsidtbl destination while preserving the rest of the RTF stream.
Parameters
- id int?
public void SetRevisionTracking(bool? enabled = null, int? displayStyle = null, int? barPlacement = null) #Adds, replaces, or removes root revision tracking controls while preserving untouched RTF syntax.
Parameters
- enabled bool? = null
- displayStyle int? = null
- barPlacement int? = null
public void SetRtlGutter(bool enabled = true) #Adds or removes the root right-to-left gutter control while preserving untouched RTF syntax.
Parameters
- enabled bool = true
public void SetStyleName(int id, string name, RtfStyleKind kind = Paragraph) #Adds a basic stylesheet entry or renames an existing entry while preserving the existing style formatting controls.
Parameters
- id int
- name string
- kind OfficeIMO.Rtf.RtfStyleKind = Paragraph
public void SetUnicodeSkipCount(int? count) #Adds, replaces, or removes the root Unicode fallback skip count while preserving the rest of the RTF stream.
Parameters
- count int?
public void SetUserProperty(RtfUserProperty property) #Adds or replaces a custom document property in the root userprops destination while preserving the rest of the RTF stream.
Parameters
- property OfficeIMO.Rtf.RtfUserProperty
public void SetUserProperty(string name, string value) #Adds or replaces a text custom document property in the root userprops destination.
Parameters
- name string
- value string
public void SetXmlNamespace(int id, string? uri) #Adds, replaces, or removes an XML namespace declaration in the root xmlnstbl destination while preserving the rest of the RTF stream.
Parameters
- id int
- uri string?
public byte[] ToBytesLossless() #Serializes the edited syntax tree to source-preserving bytes without semantic normalization.
Returns
byte[]public RtfReadResult ToReadResult(RtfLoadOptions? options = null) #Reads the edited syntax tree into a fresh semantic model.
Parameters
- options OfficeIMO.Rtf.RtfLoadOptions? = null
Returns
RtfReadResultpublic string ToRtf() #Serializes the edited syntax tree without semantic normalization.
Returns
stringInherited Methods
Properties
public int RootNodeCount { get; } #Number of direct syntax nodes inside the root RTF group.