Easy API to create ODT documents in .NET
// Needed imports
using NetOdt;
using NetOdt.Enumerations;
using System.Drawing;
// Create document (C# 8.0 syntax)
using var odtDocument = new OdtDocument(path: "E:/MyDocument.odt");
// Set global font for the all text passages for complete document
odtDocument.SetGlobalFont("Liberation Serif", FontSize.Size12);
// Set global colors for the all text passages for the complete document
odtDocument.SetGlobalFont(Color.Red, Color.Transparent);
// Set header and footer
odtDocument.SetHeader("Extend documentation", TextStyle.Center | TextStyle.Bold);
odtDocument.SetFooter("Page 2/5", TextStyle.Right | TextStyle.Italic, Color.Gray, Color.Transparent);
// Append a title
odtDocument.AppendLine("My document", TextStyle.Title, Color.Blue, Color.Black);
// Append a centered bold text
odtDocument.AppendLine("This is a bold text", TextStyle.Center | TextStyle.Bold);
// Append ten empty lines
odtDocument.AppendEmptyLines(lines: 10);
// Append a 3x3 table and fill all cells with "Fill me"
odtDocument.AppendTable(rows: 3, columns: 3, content: "Fill me");
// Append a image with a width of 22.5 cm and a height of 14.1 cm
odtDocument.AppendImage(path: "E:/picture1.jpg", width: 22.5, height: 14.1);
// The automatic dispose call (from the using syntax) do the rest of the work
// (save document, delete temporary folder, free all used resources)
// thats it :-)
All supported styles can find here
Please use the GitHub issues tracker
- Simple to use API
- Full document API and source-code
- Accept always primitive data-types,
string
andStringBuilder
to write a value - Use
enum
when only specific values are except - Use
EnumFlag
for combinations ofenum
values (bold, italic, ...) - Use build-in
DataTable
for tables - No new data-types, use only build-in data-types
- .Net Standard 2.0, C# 8.0