ReasonableRTF.Standard 2025.11.1

dotnet add package ReasonableRTF.Standard --version 2025.11.1
                    
NuGet\Install-Package ReasonableRTF.Standard -Version 2025.11.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="ReasonableRTF.Standard" Version="2025.11.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ReasonableRTF.Standard" Version="2025.11.1" />
                    
Directory.Packages.props
<PackageReference Include="ReasonableRTF.Standard" />
                    
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 ReasonableRTF.Standard --version 2025.11.1
                    
#r "nuget: ReasonableRTF.Standard, 2025.11.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 ReasonableRTF.Standard@2025.11.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=ReasonableRTF.Standard&version=2025.11.1
                    
Install as a Cake Addin
#tool nuget:?package=ReasonableRTF.Standard&version=2025.11.1
                    
Install as a Cake Tool

ReasonableRTF - Fast RTF to Plain Text Converter 🚀

A lightweight and performant C# library designed for rapidly converting Rich Text Format (RTF) files into plain text.


Installation

Install the library via NuGet:

dotnet add package ReasonableRTF.Standard

Quick Start

Converting an RTF file (as a byte array) to plain text is straightforward. The Convert method returns an RtfResult object, providing the converted text and comprehensive error information, if any.

Basic Conversion

Here is how to convert an RTF byte array 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 (e.g., from a file) and convert
RtfResult result = converter.Convert(File.ReadAllBytes(Context.Path));

if (result.Error == RtfError.None)
{
    // 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 Class

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.None 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.

Conversion Options

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.

Applying Options

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(File.ReadAllBytes(Context.Path), options);
// ... check result

RtfToTextConverterOptions Properties

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.CRLF Specifies the line break style (CRLF or LF) 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.

License and Attribution

Code License

The original code for this RTF converter was written by Brian Tobin and is licensed under the MIT License (Copyright (c) 2024 Brian Tobin). For the full license text, please refer to the LICENSE file ReasonableRTF. This project is a version of that code, adapted and converted to .NET Standard.

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 was computed.  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 was computed.  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 was computed.  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 (1)

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

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2025.11.1 422 10/21/2025
2025.11.0 172 10/21/2025