OfficeIMO.Rtf 2.0.1

Prefix Reserved
dotnet add package OfficeIMO.Rtf --version 2.0.1
                    
NuGet\Install-Package OfficeIMO.Rtf -Version 2.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OfficeIMO.Rtf" Version="2.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OfficeIMO.Rtf" Version="2.0.1" />
                    
Directory.Packages.props
<PackageReference Include="OfficeIMO.Rtf" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add OfficeIMO.Rtf --version 2.0.1
                    
#r "nuget: OfficeIMO.Rtf, 2.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package OfficeIMO.Rtf@2.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=OfficeIMO.Rtf&version=2.0.1
                    
Install as a Cake Addin
#tool nuget:?package=OfficeIMO.Rtf&version=2.0.1
                    
Install as a Cake Tool

OfficeIMO.Rtf

OfficeIMO.Rtf is the managed Rich Text Format engine for OfficeIMO. It parses RTF into both a source-preserving syntax tree and an editable semantic model, writes deterministic RTF, enforces resource limits, and reports content that cannot be represented semantically.

Install

dotnet add package OfficeIMO.Rtf

Create and read RTF

using OfficeIMO.Rtf;

RtfDocument document = RtfDocument.Create();
document.AddParagraph().AddText("Quarterly report").SetBold();
document.AddParagraph("Prepared by OfficeIMO");

string rtf = document.ToRtf();
RtfReadResult read = RtfDocument.Read(rtf);

RtfDocument.ToRtf() writes a normalized semantic document. Use the lossless path when untouched source syntax, unknown destinations, binary payloads, or trailing bytes must remain exact:

RtfReadResult read = RtfDocument.Load("input.rtf");
read.SaveLossless("unchanged-copy.rtf");

Read untrusted RTF

The compatibility profile is intentionally permissive apart from nesting depth. Uploaded files should use the bounded profile and a cancellation token:

RtfReadOptions options = RtfReadOptions.CreateUntrustedProfile();
using FileStream input = File.OpenRead("upload.rtf");

RtfReadResult read = await RtfDocument.LoadAsync(
    input,
    options,
    cancellationToken: cancellationToken);

The profile caps input bytes and characters, group depth/count, token count, text, binary payloads, images, objects, and semantic block count. A breached limit throws RtfReadLimitException with a stable Code, LimitSource, observed value, configured limit, and source position.

It also disables embedded-object and file-reference materialization and restricts semantic hyperlinks to web and mail schemes. The core never fetches external resources.

Require no conversion loss

All adapters use RtfConversionReport for preserved, flattened, omitted, and blocked content:

var report = new RtfConversionReport();
report.AddReadDiagnostics(read.Diagnostics, "upload.rtf");

// Merge an adapter's report here.
report.Merge(adapterReport);
report.RequireNoLoss();

RequireNoLoss() throws RtfConversionLossException whenever a conversion flattened, omitted, blocked, or failed content. For permissive workflows, inspect report.Diagnostics and accept only the actions appropriate for that destination.

Semantic editing

Semantic editing produces normalized RTF and is the simplest option when the document meaning is more important than its original control-word layout:

RtfDocument document = RtfDocument.Load("input.rtf").Document;

document.InsertParagraph(0, "Confidential");
document.MoveBlock(0, document.Blocks.Count - 1);
document.ReplaceText("Contoso Ltd.", "Contoso Europe");
document.ReplaceBookmarkText("CustomerName", "Contoso Europe");

RtfDocument independentCopy = document.Clone();
RtfDocumentMergeResult merge = document.AppendDocument(otherDocument);
merge.Report.RequireNoLoss();

AppendDocument remaps fonts, colors, revision authors, blocks, tables, and notes. It reports style/list flattening and source header/footer omission rather than hiding those tradeoffs.

Lossless structural editing

RtfLosslessEditor changes selected syntax nodes while retaining every untouched node:

RtfLosslessEditor editor = RtfDocument.Load("input.rtf").EditLossless();

editor.ReplaceText("Old text", "New text");
editor.SetInfo(RtfDocumentInfoField.Title, "Updated title");
editor.InsertRootParagraph(editor.RootNodeCount, "Appended note");
editor.ReplaceImage(0, replacementImage);
editor.ReplaceDestinationContent("header", @"\pard Updated header\par");

editor.SaveLossless("edited.rtf");

Root nodes can also be inserted, removed, or moved with InsertRootRtf, RemoveRootNodes, and MoveRootNodes. Those APIs are syntax-indexed; bookmark and rich-text operations belong to the semantic model.

Encoding and interoperability

The reader supports Unicode escapes, single-byte Windows code pages 874 and 1250-1258, IBM 437/850, Mac Roman, and East Asian Windows code pages 932/936/949/950. Font charset changes can switch the active decoder within a document. Unsupported code pages emit diagnostic RTF103 and use the documented Windows-1252 fallback while lossless source remains intact.

The checked producer corpus includes real Microsoft Word 16 and Outlook 16 output plus pinned LibreOffice regression files. Google Docs, macOS TextEdit/RTFD, EHR/CRM generators, and commercial producer output remain explicitly unverified.

  • OfficeIMO.Word.Rtf: Word/DOCX conversion and result-bearing mail merge, find/replace, fields, merge, and compare workflows.
  • OfficeIMO.Html: web-safe or trusted round-trip HTML conversion.
  • OfficeIMO.Rtf.Markdown: Markdown conversion with footnotes and media callbacks.
  • OfficeIMO.Rtf.Pdf: visual PDF export and extractive PDF import.
  • OfficeIMO.Reader.Rtf: bounded chunk and provenance extraction.

See the living support matrix for feature-level boundaries and evidence.

Dependency footprint

  • External: No third-party RTF engine. System.Text.Encoding.CodePages supplies legacy encodings.
  • OfficeIMO: OfficeIMO.Drawing. Lexing, parsing, semantic binding, editing, and writing are first-party.

See the complete OfficeIMO package map for related formats and conversion paths.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (6)

Showing the top 5 NuGet packages that depend on OfficeIMO.Rtf:

Package Downloads
OfficeIMO.Html

Shared HTML parsing, resource policy, layout, diagnostics, and direct PNG/SVG rendering for OfficeIMO converters.

OfficeIMO.Reader.Rtf

Bounded RTF chunk, table, visual, warning, and provenance adapter for OfficeIMO.Reader.

OfficeIMO.Word.Rtf

Result-bearing RTF converter and document workflow bridge for OfficeIMO.Word.

OfficeIMO.Rtf.Pdf

Bidirectional semantic RTF/PDF converter with shared fidelity diagnostics and managed image handling.

OfficeIMO.Rtf.Markdown

Semantic Rich Text Format and Markdown conversion bridge for OfficeIMO.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.1 677 7/14/2026
2.0.0 476 7/14/2026
0.1.10 1,085 7/9/2026
0.1.9 1,138 7/8/2026
0.1.8 1,258 7/5/2026
0.1.7 1,064 7/4/2026
0.1.6 1,127 6/27/2026
0.1.5 912 6/27/2026
0.1.4 1,150 6/24/2026
0.1.3 967 6/23/2026
0.1.2 1,055 6/21/2026
0.1.1 972 6/16/2026
0.1.0 1,042 6/16/2026