Skip to content

ifmelate/Html2OpenRtf

Repository files navigation

Html2OpenRtf

Free, open-source .NET library for converting HTML to RTF (Rich Text Format).

Build NuGet License: MIT

Installation

dotnet add package Html2OpenRtf

Usage

using Html2OpenRtf;

// HTML string to RTF string
string rtf = HtmlToRtfConverter.ConvertHtmlToRtf("<p>Hello <b>World</b></p>");

// HTML to RTF bytes (ASCII)
byte[] rtfBytes = HtmlToRtfConverter.ConvertHtmlToRtfBytes(html);

// HTML to Base64-encoded RTF (useful for APIs)
string base64Rtf = HtmlToRtfConverter.ConvertHtmlToBase64Rtf(html);

Supported HTML

Category Tags
Block p, div, br, h1-h6, blockquote, hr, pre
Inline b/strong, i/em, u, s/strike/del, sub, sup
Lists ul, ol, li (including nested)
Tables table, tr, td, th (equal-width cells)
Links a (clickable RTF hyperlinks)
Images img (placeholder [image: alt])
Code code, kbd, samp (monospace font)
Highlight mark (yellow background)
Styles color, font-size, background-color, text-align, font-weight, font-style, text-decoration via style attribute
Unicode Full support (Cyrillic, CJK, etc. via \uN? escapes)
Entities Full HTML entity decoding

Target

  • .NET Standard 2.0 (compatible with .NET Framework 4.6.1+, .NET Core 2.0+, .NET 5-9)
  • Single dependency: HtmlAgilityPack (MIT)
  • Cross-platform: Windows, Linux, macOS

Contributing

PRs welcome. Run tests with:

dotnet test

License

MIT

About

Free, open-source HTML to RTF converter for .NET

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages