SkillAgentSearch skills...

DocSharp

Pure C# library to convert between document formats (Office 97-2003, Open XML, RTF, Markdown)

Install / Use

/learn @manfromarce/DocSharp
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

DocSharp

DocSharp is a pure C# library to convert between document formats without Office interop or native dependencies (except for some special packages, see requirements).

The following packages are currently available:

  • DocSharp.Binary: convert Office 97-2003 binary documents (doc, xls, ppt) to OpenXML documents (docx, xlsx, pptx). This is a fork of the abandoned b2xtranslator project which provides critical fixes.
    Note: pre-97 formats (not documented) and XLSB (very different) are not supported.
  • DocSharp.Docx: convert DOCX to RTF, HTML, Markdown and plain text (.txt), and RTF to DOCX. Possible applications include generating Open XML documents in C# and exporting for other editors/services, or loading and saving Microsoft Word documents into/from a RichTextBox/RichEditBox control.
  • DocSharp.Markdown: convert Markdown to DOCX or RTF using custom Markdig renderers.
  • DocSharp.Renderer: provides basic DOCX to PDF/images/SVG/XPS conversion using QuestPDF.

Packages can be installed via NuGet:
NuGet NuGet NuGet NuGet NuGet NuGet

The optional extra packages DocSharp.ImageSharp, DocSharp.SystemDrawing, DocSharp.SkiaSharp, DocSharp.MagickNET allow to convert unsupported images (e.g. GIF / TIFF for DOCX -> RTF or WMF / EMF / TIFF for DOCX -> Markdown/HTML). Each of these has pros and cons, the choice depends on your requirements. More information can be found in the Wiki.

There is no common DOM to manipulate or generate documents, this library is mainly for conversion. Some helper methods on top of the Open XML SDK and format-specific writers are available, but they are mostly intended for internal use; however they could be extended/improved in the future.
You can consider using the Open XML SDK itself or other <a href="#recommended_libraries">recommended libraries</a> for documents creation and manipulation. Some of these are used in the sample app to test two-steps conversions, compare results, or generate documents in multiple formats with the same code.
DocSharp provides methods to accept/return a WordprocessingDocument directly (in addition to file path / Stream / byte array), and a SaveTo extension method for WordprocessingDocument.

Supported features

Supported elements vary depending on input and output formats, see Supported features for an overview.

<a id="Requirements"></a>

Requirements

  • Supported targets are .NET 8, 9, 10 and .NET Framework 4.6.2 (minimum netfx version still supported).
  • DocSharp.SystemDrawing is for Windows only (.NET Framework or net*-windows), as System.Drawing.Common is based on GDI+ and only supported on Windows since .NET 6.
  • DocSharp.ImageSharp is cross-platform for .NET 8+, as ImageSharp is fully managed C# code but does not support .NET Framework.
  • DocSharp.MagickNET is cross-platform for both .NET and .NET Framework, but Magick.NET bundles many native libraries that might not work on non-desktop platforms (Android / iOS / WASM)
  • DocSharp.Renderer depends on QuestPDF, which currently supports Windows x64 / x86, macOS x64 / ARM64, Linux x64 / ARM64. Windows ARM64, Android, iOS are not supported yet, due to a custom Skia build. Plus, the XPS generation is only supported on Windows.

Usage

You can refer to the project Wiki or sample apps.

Roadmap

  • Finish and publish experimental converters
  • Support more elements and attributes, and fix issues on edge cases
  • Reduce code duplication, cleanup
  • Async functions/progress callback (some tasks such as downloading images referenced in Markdown may take some time)
  • Improve support for right-to-left and complex script languages
  • Evaluate feasibility of making converters thread-safe and totally NativeAOT-compatible

Credits

Dependencies:

Forked:

Others (credits for parts of the logic, not direct dependencies):

<a id="recommended_libraries"></a> Other recommended libraries (some of these are used in the sample app, not dependencies when installing packages):

Related Skills

View on GitHub
GitHub Stars48
CategoryDevelopment
Updated1d ago
Forks12

Languages

C#

Security Score

95/100

Audited on Apr 9, 2026

No findings