Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Rich Text Format engine

OfficeIMO.Rtf

Read, create, edit, preserve, and convert Rich Text Format documents with bounded parsing and explicit fidelity reports.

MIT licensed No Office required Cross-platform .NET
Install dotnet add package OfficeIMO.Rtf
Independent first-page render of the generated RTF change approval memo: a decision callout, change details, a controls table with green and amber states, and a checklist
Change approval memo

The downloadable RTF and PDF come from the same OfficeIMO.Rtf model. The preview independently renders the first-party conversion result.

Download source RTF · View source · Explore the example
C# · excerpt cut from the example source; the full file is linked above
RtfDocument document = RtfDocument.Create();
document.Properties.Title = "Change approval memo";
document.Properties.Author = "Platform operations";

int accent = document.AddColor(35, 95, 180);
int headerFill = document.AddColor(226, 236, 250);
int doneFill = document.AddColor(222, 244, 230);
int pendingFill = document.AddColor(255, 240, 207);
int calloutFill = document.AddColor(240, 245, 252);
int muted = document.AddColor(90, 104, 122);

RtfStyle title = document.AddStyle(1, "Title");
title.Bold = true;
title.FontSize = 22;
title.ForegroundColorIndex = accent;
title.SpaceAfterTwips = 60;
RtfStyle heading = document.AddStyle(2, "Heading 1");
heading.Bold = true;
heading.FontSize = 14;
heading.ForegroundColorIndex = accent;
heading.SpaceBeforeTwips = 240;
heading.SpaceAfterTwips = 80;

// Footer with a live page number.
RtfParagraph footer = document.AddFooter().AddParagraph("Change approval memo - CHG-2041 - page ");
footer.AddPageNumber("1");

document.AddParagraph("Change approval memo").SetStyle(1);
RtfParagraph subtitle = document.AddParagraph();
subtitle.AddText("CHG-2041 · Rotate the payment gateway TLS certificates · ").SetForegroundColor(muted);
subtitle.AddText("Ready for approval").SetBold().SetForegroundColor(accent);

// A one-cell shaded table carries the decision.
RtfTableCell callout = document.AddTable(1, 1).Rows[0].Cells[0];
callout.SetBackgroundColor(calloutFill).SetPadding(120, 160, 120, 160);
callout.AddParagraph("Decision requested: approve the certificate rotation for Saturday 02:00-04:00 UTC. " +
    "Backup and rollback are already verified; only the business approval is open.");
document.AddParagraph("Change details").SetStyle(2);
foreach ((string label, string value) in new[] {
    ("Window", "Saturday 02:00-04:00 UTC, expected downtime none"),
    ("Risk", "Low - certificates are replaced behind the load balancer"),
    ("Rollback", "Restore the previous certificate bundle, about 10 minutes") }) {
    RtfParagraph line = document.AddParagraph();
    line.AddText(label + ": ").SetBold();
    line.AddText(value);
}

document.AddParagraph("Approval controls").SetStyle(2);
string[][] controls = {
    new[] { "Control", "Owner", "State" },
    new[] { "Backup verified", "Operations", "Complete" },
    new[] { "Rollback tested", "Engineering", "Complete" },
    new[] { "Monitoring and alert ownership", "Operations", "Complete" },
    new[] { "Customer notice sent", "Support", "Complete" },
    new[] { "Business approval", "Service owner", "Pending" }
};
RtfTable table = document.AddTable(controls.Length, 3);
table.Rows[0].RepeatHeader = true;
table.Rows[0].SetBackgroundColor(headerFill);
for (int row = 0; row < controls.Length; row++) {
    for (int column = 0; column < 3; column++) {
        table.Rows[row].Cells[column].AddParagraph(controls[row][column]);
    }
    if (row > 0) table.Rows[row].Cells[2].SetBackgroundColor(controls[row][2] == "Complete" ? doneFill : pendingFill);
}

document.AddParagraph("Execution checklist").SetStyle(2);
AddRtfBullet(document, "Confirm monitoring and alert ownership.");
AddRtfBullet(document, "Apply the change during the approved window.");
AddRtfBullet(document, "Record validation results and close the change.");

One engine for normalized and source-preserving RTF work

OfficeIMO.Rtf exposes an editable semantic document for normal authoring and a lossless syntax tree for surgical changes that must retain untouched producer data.

using OfficeIMO.Rtf;

RtfReadResult read = RtfDocument.LoadResult("input.rtf");
RtfDocument document = read.Document;
document.ReplaceText("Draft", "Approved");
File.WriteAllText("approved.rtf", document.ToRtf());

Useful for

  • Generating RTF reports, letters, and interchange documents.
  • Editing text, bookmarks, images, metadata, headers, and selected syntax without Microsoft Word.
  • Processing uploaded RTF with limits on depth, tokens, text, binary payloads, images, objects, and output blocks.
  • Converting between RTF and Word, Markdown, HTML, PDF, or Reader results.
  • Enforcing a no-loss policy from structured conversion diagnostics.

The parser supports legacy code pages used by Word and Outlook producers and retains unknown syntax on the lossless path. It never fetches external resources.

Start with the RTF guide or inspect the support matrix.

Same engine, other surfaces

Use OfficeIMO another way

Next step

Turn the package into a working document.

Follow a focused guide and inspect the API reference for this package.

Example source