Skip to content

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

License

MIT, Apache-2.0 licenses found

Licenses found

MIT
LICENSE
Apache-2.0
LICENSE-Apache
Notifications You must be signed in to change notification settings

manfromarce/DocSharp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DocSharp

DocSharp is a pure C# library to convert between document formats without Office interop or native dependencies.

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.
  • DocSharp.Docx: convert DOCX to Markdown, RTF and plain text (.txt). Possible applications include generating Open XML documents in C# and exporting for other editors, or loading Word documents in a RichTextBox / RichEditBox control.
  • DocSharp.Markdown: convert Markdown to DOCX using a custom Markdig renderer.

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

The optional extra packages DocSharp.ImageSharp and DocSharp.SystemDrawing allow to convert unsupported images (e.g. GIF / TIFF for DOCX -> RTF or WMF / EMF / TIFF for DOCX -> MD).

There is no common DOM to manipulate or generate documents, this library is mainly for conversion. However, the Docx package provides some helper methods on top of the Open XML SDK that may be extended in the future.
If your main purpose is creating documents from scratch you can consider the following libraries: OfficeIMO, OpenXML-Office, ClosedXML, ShapeCrawler, QuestPDF, MigraDoc.

Supported features

  • Binary formats: most doc/xls/ppt features were supported by the original project, but exceptions occurred when using .NET (rather than .NET Framework) or loading specific documents. The most noticeable issues have been fixed, but more work is needed to make the library reliable; if you find other bugs, you are welcome to open an issue (please attach a sample file if the issue only occurs for specific documents).
  • DOCX, RTF, Markdown: supported elements vary depending on input and output formats, see Supported features for an overview.

Requirements

.NET 6, 8, 9 and .NET Framework 4.6.2 and higher are supported, but tests are mostly performed on .NET 8 and above.

Usage

You can refer to the project Wiki or sample app.

Roadmap

  • Support more elements and attributes, and fix issues on edge cases
  • Reverse RTF to DOCX conversion
  • 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

Credits

Dependencies:

Forked:

Others:

License

DocSharp is licensed under MIT license and can be used for both open source and commercial projects.

DocSharp.ImageSharp is licensed under Apache 2.0 license; ImageSharp and VectSharp have their own licenses, please visit their repositories for more information.

If you find the library useful, adding a star is highly appreciated.

About

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

Topics

Resources

License

MIT, Apache-2.0 licenses found

Licenses found

MIT
LICENSE
Apache-2.0
LICENSE-Apache

Stars

Watchers

Forks

Packages

No packages published

Languages