This is a prerelease version of DDDN.OdtToHtml.
Install-Package DDDN.OdtToHtml -Version
dotnet add package DDDN.OdtToHtml --version
<PackageReference Include="DDDN.OdtToHtml" Version="" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DDDN.OdtToHtml --version
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: DDDN.OdtToHtml,"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install DDDN.OdtToHtml as a Cake Addin
#addin nuget:?package=DDDN.OdtToHtml&version=

// Install DDDN.OdtToHtml as a Cake Tool
#tool nuget:?package=DDDN.OdtToHtml&version=
The NuGet Team does not provide support for this client. Please contact its maintainers for support.


OdtToHtml is a .NET Standard/Core library for converting ODT documents (Open Document Text Format) into responsive HTML/CSS.

It should be understand as a more comfortable way of writing HTML articles. You can use all the editing/correcting features of Microsoft Office Word, LibreOffice or other editors for a better writing and reviewing experience, for example compared to the markdown approach.

OdtToHtml has been developed as a part of the CrossBlog ASP.NET Core blog engine, but it can also be used otherwise/standalone.

How to get OdtToHtml

Nuget package

Simply add the DDDN.OdtToHtml nuget package reference to your project using Visual Studio or by downloading it manually.

Get it from here

You can pull the code form Github and compile the solution using Visual studio 2017 and the .NET Core 2.x SDK. The solution contains a sample web application with some example ODT documents that can be converted to HTML with a single click. You can also simply add your own ODT documents under the sample applications wwwroot\odt folder to see how OdtToHtml will convert the documents into HTML.

How to use the library

Please have a look at the DDDN.OdtToHtml.Samples ASP.NET Core 2.0 sample web application that contains the following code:

Convert call inside a MVC controller action method

The following example shows how to call the Convert method within a MVC controller action method in order to get the HTML/CSS from an ODT document saved somewhere under the wwwroot folder.

// the odtDocFileName parameter contains the filename that is stored under the wwwroot\odt folder
public IActionResult Open(string odtDocFileName)
	// holds the wwwroot subdirectory name where the ODT document content like images will be saved
	const string contentSubDirname = "content";

	// structure will contain all the data returned form the ODT to HTML conversion
	OdtConvertedData convertedData = null;

	// builds the path to the ODT document. "odt" is a wwwroot subfolder
	var odtFileInfo = _hostingEnvironment.WebRootFileProvider.GetFileInfo(Path.Combine("odt", odtDocFileName));

	// providing settings for the ODT to HTML conversion call
	var odtConvertSettings = new OdtConvertSettings
		RootElementTagName = "article", // root HTML tag that will contain the converted HTML
		RootElementId = "article_id", // the id attribute value of the root HTML tag (optional)
		RootElementClassNames = "article_class", // the class attribute value of the root HTML tag (optional)
		LinkUrlPrefix = $"/{contentSubDirname}", // here you can provide a partial path directly under the wwwroot folder content (images) link generation
		DefaultTabSize = "2rem" // the default value for tabs (not tab stops)

	// open the ODT document on the file system and call the Convert method to convert the document to HTML
	using (IOdtFile odtFile = new OdtFile(odtFileInfo.PhysicalPath))
		convertedData = new OdtConvert().Convert(odtFile, odtConvertSettings);
	// write the content (like images) of the ODT document to the file system to make it available to the web browser requests
	foreach (var articleContent in convertedData.EmbedContent)
		var contentLink = Path.Combine(_hostingEnvironment.WebRootPath, contentSubDirname, articleContent.LinkName);
		System.IO.File.WriteAllBytes(contentLink, articleContent.Data);

	ViewData["ArticleHtml"] = convertedData.Html; // move the generated HTML to the razor view
	ViewData["ArticleCss"] = convertedData.Css; // move the generated CSS to the razor view
	// additional usefull data returned for conversion
	var usedFontFamilies = convertedData.UsedFontFamilies; // all font families used, useful for font links
	var pageInfo = convertedData.PageInfo; // contains the document sheet's dimensions and margins
	var documentFirstHeader = convertedData.DocumentFirstHeader; // the "text only" content of the first document header for preview/teaser purposes
	var documentFirstParagraph = convertedData.DocumentFirstParagraph; // the "text only" content of the first document paragraph for preview/teaser purposes

	return View();

// That’s all! You have successfully created a web page from an office document! :)

The Razor View part

This is how the MCV Razor view, that uses the _ViewStart.cshtml/_Layout.cshtml files, can looks like:

@section Styles


and this is an example of the the _Layout.cshtml part:

<!DOCTYPE html>
<html lang="en">
	<meta charset="utf-8" />
	<title>@ViewData["Title"] - DDDN.OdtToHtml.Samples</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
		@RenderSection("styles", required: false)
	<div class="container">
			<a asp-controller="Home" asp-action="Index">Your converted ODT document</a>
	<script src="~/js/site.js" asp-append-version="true"></script>
	@RenderSection("scripts", required: false)

OdtToHtml library Dependencies

There are no package or code dependencies other than the .NETStandard 2.0 libraries.

Missing features

Some of the features of the ODT format (some listed below) are not implemented by the converter because they are not that usefull for displaying HTML pages. Please feel free to contact me if something important is missing or doesn't work properly.

  • all canvas/shapes features
  • outline functionality (only lists at the moment)
  • TOC formatting partially works
  • correct text flow around images and other content


The source code is mostly licensed under GNU General Public License, version 2 of the license. Please refer to the source code file headers for detailed licensing information.

Version history (alpha)

  • improved list and overall rendering (alpha)

  • bug fixes (alpha)

  • improved rendering of lists/tables
  • minor rendering improvements (alpha)

  • improved rendering of list styles and list fonts
  • improved text decorations
  • added anchor links for the document TOC
  • the conversion now also returns a CSS property value list with all used font families (alpha)

  • first alpha release
  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated 464 10/30/2018 592 2/11/2018 576 2/10/2018 2,052 1/21/2018 744 1/18/2018

alpha release