![]() |
VOOZH | about |
dotnet add package ReasonableRTF.Standard --version 2026.6.0
NuGet\Install-Package ReasonableRTF.Standard -Version 2026.6.0
<PackageReference Include="ReasonableRTF.Standard" Version="2026.6.0" />
<PackageVersion Include="ReasonableRTF.Standard" Version="2026.6.0" />Directory.Packages.props
<PackageReference Include="ReasonableRTF.Standard" />Project file
paket add ReasonableRTF.Standard --version 2026.6.0
#r "nuget: ReasonableRTF.Standard, 2026.6.0"
#:package ReasonableRTF.Standard@2026.6.0
#addin nuget:?package=ReasonableRTF.Standard&version=2026.6.0Install as a Cake Addin
#tool nuget:?package=ReasonableRTF.Standard&version=2026.6.0Install as a Cake Tool
A lightweight and performant C# library designed for rapidly converting Rich Text Format (RTF) files into plain text.
Install the library via NuGet:
dotnet add package ReasonableRTF.Standard
Converting an RTF file to plain text is straightforward. The Convert method returns an RtfResult object, providing the converted text and comprehensive error information, if any.
Here is how to convert an RTF file to a plain text string:
using ReasonableRTF;
using ReasonableRTF.Models;
using System.IO;
// ...
// 1. Initialize the converter
RtfToTextConverter converter = new RtfToTextConverter();
// 2. Load the RTF data from a file and convert
RtfResult result = converter.Convert("some_file.rtf");
if (result.Error == RtfError.OK)
{
// Conversion was successful
string plainText = result.Text;
Console.WriteLine("Converted Text:\n" + plainText);
}
else
{
// Handle conversion errors
Console.WriteLine($"Conversion Error: {result.Error} at byte position: {result.BytePositionOfError}");
if (result.Exception != null)
{
Console.WriteLine($"Exception Details: {result.Exception.Message}");
}
}
The RtfResult object provides full details about the conversion process, ensuring you can robustly handle success and failure cases.
| Property | Type | Description |
|---|---|---|
Text |
string |
The converted plain text. |
Error |
RtfError |
The error code. This will be RtfError.OK upon successful conversion. |
BytePositionOfError |
int |
The approximate position in the data stream where the error occurred, or -1 if no error. |
Exception |
Exception? |
The caught exception, or null if no exception occurred during conversion. |
For more control over the output, you can provide an instance of the RtfToTextConverterOptions class to the Convert method. This allows customization of line breaks, special character handling, and hidden text inclusion.
RtfToTextConverter converter = new RtfToTextConverter();
RtfToTextConverterOptions options = new RtfToTextConverterOptions
{
ConvertHiddenText = true, // Include text marked as hidden
LineBreakStyle = LineBreakStyle.LF // Use Unix-style line breaks
};
RtfResult result = converter.Convert("some_file.rtf", options);
// ... check result
| Property | Type | Default | Description |
|---|---|---|---|
SwapUppercaseAndLowercasePhiSymbols |
bool |
true |
If set to true, swaps the uppercase and lowercase Greek phi characters in the Symbol font translation. This addresses a common reversal in the Windows Symbol font. |
SymbolFontA0Char |
SymbolFontA0Char |
SymbolFontA0Char.EuroSign |
Sets the character at index 0xA0 (160) in the Symbol font to Unicode translation table. Important for compatibility with older Symbol font versions. |
LineBreakStyle |
LineBreakStyle |
LineBreakStyle.EnvironmentDefault |
Specifies the line break style (CRLF, LF, or environment default) for the converted plain text output. |
ConvertHiddenText |
bool |
false |
Determines whether text marked as hidden in the RTF file should be included in the plain text output. |
BenchmarkDotNet v0.15.8, Windows 11 (10.0.26200.8457/25H2/2025Update/HudsonValley2)
AMD Ryzen 5 5600 3.50GHz, 1 CPU, 12 logical and 6 physical cores
.NET SDK 10.0.204
[Host] : .NET 10.0.8 (10.0.8, 10.0.826.23019), X64 RyuJIT x86-64-v3
DefaultJob : .NET 10.0.8 (10.0.8, 10.0.826.23019), X64 RyuJIT x86-64-v3
| Method | Mean | Error | StdDev | Speed | |
|---|---|---|---|---|---|
| RichTextBox_FullSet | 3,331.340 ms | 6.2250 ms | 5.5183 ms | 43.59 MB/s | 1x |
| RichTextBox_NoImageSet | 1,432.217 ms | 3.7089 ms | 3.4693 ms | 2.47 MB/s | 1x |
| ReasonableRTF_FullSet | 17.338 ms | 0.0552 ms | 0.0517 ms | 8375.35 MB/s | 192x |
| ReasonableRTF_NoImageSet | 4.087 ms | 0.0113 ms | 0.0100 ms | 867.06 MB/s | 350x |
| ReasonableRTF_FullSet_Streamed | 18.966 ms | 0.0232 ms | 0.0217 ms | 7656.43 MB/s | 176x |
| ReasonableRTF_NoImageSet_Streamed | 4.185 ms | 0.0099 ms | 0.0092 ms | 846.75 MB/s | 342x |
BenchmarkDotNet v0.15.8, Windows 11 (10.0.26200.8457/25H2/2025Update/HudsonValley2)
AMD Ryzen 5 5600 3.50GHz, 1 CPU, 12 logical and 6 physical cores
[Host] : .NET Framework 4.8.1 (4.8.9325.0), X64 RyuJIT VectorSize=256
DefaultJob : .NET Framework 4.8.1 (4.8.9325.0), X64 RyuJIT VectorSize=256
| Method | Mean | Error | StdDev | Speed | |
|---|---|---|---|---|---|
| RichTextBox_FullSet | 2,779.775 ms | 3.9318 ms | 3.2833 ms | 52.24 MB/s | 1x |
| RichTextBox_NoImageSet | 992.237 ms | 2.5478 ms | 2.2585 ms | 3.57 MB/s | 1x |
| ReasonableRTF_FullSet | 22.575 ms | 0.0263 ms | 0.0246 ms | 6432.42 MB/s | 123x |
| ReasonableRTF_NoImageSet | 5.705 ms | 0.0136 ms | 0.0127 ms | 621.15 MB/s | 174x |
| ReasonableRTF_FullSet_Streamed | 25.023 ms | 0.0575 ms | 0.0538 ms | 5803.13 MB/s | 111x |
| ReasonableRTF_NoImageSet_Streamed | 5.805 ms | 0.0134 ms | 0.0126 ms | 610.45 MB/s | 171x |
BenchmarkDotNet v0.15.8, Windows 11 (10.0.26200.8457/25H2/2025Update/HudsonValley2)
AMD Ryzen 5 5600 3.50GHz, 1 CPU, 12 logical and 6 physical cores
[Host] : .NET Framework 4.8.1 (4.8.9325.0), X86 LegacyJIT
DefaultJob : .NET Framework 4.8.1 (4.8.9325.0), X86 LegacyJIT
| Method | Mean | Error | StdDev | Speed | |
|---|---|---|---|---|---|
| RichTextBox_FullSet | 6,932.056 ms | 131.6848 ms | 140.9013 ms | 20.95 MB/s | 1x |
| RichTextBox_NoImageSet | 2,885.139 ms | 57.0121 ms | 81.7651 ms | 1.23 MB/s | 1x |
| ReasonableRTF_FullSet | 41.609 ms | 0.0631 ms | 0.0590 ms | 3489.91 MB/s | 167x |
| ReasonableRTF_NoImageSet | 8.188 ms | 0.0187 ms | 0.0175 ms | 432.79 MB/s | 352x |
| ReasonableRTF_FullSet_Streamed | 46.040 ms | 0.1415 ms | 0.1324 ms | 3154.03 MB/s | 151x |
| ReasonableRTF_NoImageSet_Streamed | 8.319 ms | 0.0313 ms | 0.0293 ms | 425.97 MB/s | 347x |
The original code for this RTF converter was written by Brian Tobin and is licensed under the MIT License (Copyright 2024-2026 Brian Tobin). For the full license text, please refer to the LICENSE file ReasonableRTF.
Flamifly contributed to the readme (installation, quick start, documentation, etc), and created the .NET Standard version.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 1 NuGet packages that depend on ReasonableRTF.Standard:
| Package | Downloads |
|---|---|
|
Toxy
Toxy is a .NET library for extracting data from various document formats |
Showing the top 1 popular GitHub repositories that depend on ReasonableRTF.Standard:
| Repository | Stars |
|---|---|
|
nissl-lab/toxy
.net text extraction & export framework
|