OfficeIMO.Rtf
0.1.1
Prefix Reserved
dotnet add package OfficeIMO.Rtf --version 0.1.1
NuGet\Install-Package OfficeIMO.Rtf -Version 0.1.1
<PackageReference Include="OfficeIMO.Rtf" Version="0.1.1" />
<PackageVersion Include="OfficeIMO.Rtf" Version="0.1.1" />
<PackageReference Include="OfficeIMO.Rtf" />
paket add OfficeIMO.Rtf --version 0.1.1
#r "nuget: OfficeIMO.Rtf, 0.1.1"
#:package OfficeIMO.Rtf@0.1.1
#addin nuget:?package=OfficeIMO.Rtf&version=0.1.1
#tool nuget:?package=OfficeIMO.Rtf&version=0.1.1
OfficeIMO.Rtf
OfficeIMO.Rtf is a dependency-free Rich Text Format engine for OfficeIMO.
The package owns RTF parsing, syntax-tree preservation, semantic document binding, fluent document construction, and deterministic RTF writing. Adapters such as OfficeIMO.Word.Rtf should reference this package instead of reimplementing RTF parsing or writing.
Layers
OfficeIMO.Rtf.Syntaxtokenizes and parses RTF groups, control words, control symbols, text, and binary payloads while retaining raw source tokens.OfficeIMO.Rtf.Modelexposes a semantic document model for paragraphs, runs, fonts, colors, styles, tables, images, and future document constructs.OfficeIMO.Rtf.Writingserializes the semantic model back to deterministic RTF.RtfDestinationRegistrycentralizes destination categories used by readers, editors, and diagnostics.RtfReadResult.ToRtfLossless(),RtfReadResult.SaveLossless(...), and their async counterparts write the parsed syntax tree without semantic normalization, preserving unknown destinations and raw binary payload bytes.
Basic Usage
using OfficeIMO.Rtf;
RtfDocument document = RtfDocument.Create();
document.AddParagraph()
.AddText("Hello ")
.Bold();
document.Paragraphs[0]
.AddText("RTF");
string rtf = document.ToRtf();
RtfReadResult read = RtfDocument.Read(rtf);
Lossless Round Trip
Use the lossless API when the goal is to preserve an existing RTF stream exactly, including destinations that are not yet semantically modeled.
RtfReadResult read = RtfDocument.Load("input.rtf");
read.SaveLossless("output.rtf");
Async file and stream APIs are available for the same boundary:
RtfReadResult read = await RtfDocument.LoadAsync("input.rtf");
await read.SaveLosslessAsync("output.rtf");
The normal RtfDocument.ToRtf() path writes from the semantic model and is intentionally normalized. The lossless path writes from the syntax tree captured during read.
Encoding
RTF hex escapes such as \'a3 and literal high-byte text loaded through the byte-preserving APIs are decoded according to the active ANSI code page. The reader currently supports dependency-free decoding for single-byte Windows ANSI code pages 874 and 1250 through 1258, with Windows-1252 as the default. Unsupported code pages emit diagnostic RTF103 and fall back to Windows-1252 while the original syntax remains available through the lossless APIs.
Lossless Editing
Use RtfLosslessEditor for targeted changes that should preserve untouched RTF syntax.
RtfReadResult read = RtfDocument.Load("input.rtf");
RtfLosslessEditor editor = read.EditLossless();
editor.ReplaceText("Old text", "New text");
editor.SetInfo(RtfDocumentInfoField.Title, "Updated title");
editor.SetUserProperty("Client", "Contoso");
editor.SetDocumentVariable("Client", "Contoso");
editor.AppendParagraph("New paragraph");
string editedRtf = editor.ToRtf();
RtfReadResult editedRead = editor.ToReadResult();
The editor rewrites only affected syntax nodes and RTF-escapes inserted text. Text replacement intentionally skips structural destinations such as font tables, stylesheets, metadata, pictures, objects, list tables, ignorable destinations, and field instructions.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 is compatible. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.7.2
- No dependencies.
-
.NETStandard 2.0
- No dependencies.
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages (4)
Showing the top 4 NuGet packages that depend on OfficeIMO.Rtf:
| Package | Downloads |
|---|---|
|
OfficeIMO.Html
Shared HTML ingestion policies, helpers, and first-party HTML bridge APIs for OfficeIMO converters. |
|
|
OfficeIMO.Word.Rtf
RTF converter for OfficeIMO.Word using the dependency-free OfficeIMO.Rtf engine. |
|
|
OfficeIMO.Rtf.Pdf
Bidirectional semantic RTF/PDF converter for OfficeIMO.Rtf using the dependency-free OfficeIMO.Pdf engine. |
|
|
OfficeIMO.Reader.Rtf
RTF adapter for OfficeIMO.Reader using the dependency-free OfficeIMO.Rtf semantic model. |
GitHub repositories
This package is not used by any popular GitHub repositories.