DocWright 1.1.1
dotnet add package DocWright --version 1.1.1
NuGet\Install-Package DocWright -Version 1.1.1
<PackageReference Include="DocWright" Version="1.1.1" />
<PackageVersion Include="DocWright" Version="1.1.1" />
<PackageReference Include="DocWright" />
paket add DocWright --version 1.1.1
#r "nuget: DocWright, 1.1.1"
#:package DocWright@1.1.1
#addin nuget:?package=DocWright&version=1.1.1
#tool nuget:?package=DocWright&version=1.1.1
DocWright
Convert, render and edit Word documents from .NET — with no Microsoft Word, no Office interop and no native binaries. This is the main package: install it and you have the whole pipeline.
Convert DOCX and legacy DOC to PDF, PNG/JPEG, HTML, Markdown, RTF, plain text, ODT, EPUB and RDL. Rasterize an existing PDF to page images. Load a document into a mutable model, edit it, and save it back.
Install
dotnet add package DocWright
That is all you need for everything on this page — the format readers, writers, layout engine, font engine and both renderers come with it automatically.
Convert a document to PDF
using DocWright;
var converter = new DocWrightConverter();
using FileStream input = File.OpenRead("report.docx");
using FileStream output = File.Create("report.pdf");
ConversionResult result = converter.Convert(input, output);
Console.WriteLine($"{result.PageCount} pages");
Convert always renders to PDF. The input format is detected automatically; override that
with ConvertOptions.SourceFormat when you are reading from a stream with no file name.
Save to another document format
Converting renders to PDF; saving round-trips an editable format, chosen by extension:
using DocWright;
var converter = new DocWrightConverter();
using var document = converter.Load(File.OpenRead("report.docx"));
using FileStream html = File.Create("report.html");
converter.Save(document, html, ".html");
Writers ship for .docx, .html, .md, .rtf, .txt, .odt, .epub and .rdl.
Readers ship for .docx, .doc, .html, .md, .rtf and .txt.
Convert a document to images
using DocWright;
using DocWright.Renderers.Imaging;
var converter = new DocWrightConverter();
var imageOptions = new ImageRenderOptions
{
Dpi = 150,
Format = ImageOutputFormat.Png,
PageEncoded = (pageNumber, bytes) => File.WriteAllBytes($"page-{pageNumber}.png", bytes),
};
using FileStream input = File.OpenRead("report.docx");
converter.ConvertToImages(input, imageOptions);
Rasterize an existing PDF
using DocWright;
using DocWright.Renderers.Imaging;
var converter = new DocWrightConverter();
var imageOptions = new ImageRenderOptions
{
Dpi = 150,
Format = ImageOutputFormat.Png,
PageEncoded = (pageNumber, bytes) => File.WriteAllBytes($"page-{pageNumber}.png", bytes),
};
using FileStream input = File.OpenRead("statement.pdf");
converter.ConvertPdfToImages(input, imageOptions);
ConvertToImages and ConvertPdfToImages have no output stream of their own, so
ImageRenderOptions must set either PageEncoded or PageStreamFactory to receive the
pages; they throw if neither is set.
PDF is read-and-rasterize only. It is not a document importer, so Load will not accept
a PDF — use ConvertPdfToImages.
Load, edit and save
using DocWright;
using DocWright.Dom;
using DocWright.Dom.Editing;
var converter = new DocWrightConverter();
using WordDocument document = converter.Load(File.OpenRead("template.docx"));
document.ReplacePlaceholders(new Dictionary<string, object?>
{
["CustomerName"] = "Contoso Ltd.",
["InvoiceTotal"] = 1499.00m,
});
using FileStream output = File.Create("filled.docx");
converter.Save(document, output);
Find and replace, {{placeholder}} template filling, bookmarks and ranges, merge and
split, content controls, legacy form fields and custom-XML binding are all included here.
Performance
DocWrightConverter caches its font engine per instance, and building one costs about a
second. Create one converter and reuse it — a converter per document turns a
ten-second batch into a very long one. It is safe to use concurrently.
// Do this once, at startup, and share it.
static readonly DocWrightConverter Converter = new DocWrightConverter();
Optional add-ons
Everything above ships in this package. These are separate installs, added only when you want them:
| Package | Adds |
|---|---|
DocWright.Composition |
Build a document from code with a fluent, declarative API |
DocWright.MailMerge |
Merge fields, repeating regions, conditional records |
DocWright.Compare |
Diff two documents into one with tracked changes |
DocWright.Cryptography |
Open and write password-encrypted documents |
DocWright.Signatures |
Verify and create package and PDF signatures |
DocWright.ComplexText |
HarfBuzz shaping for Arabic, Hebrew and Indic scripts |
DocWright.Ole |
Read compound files and extract embedded OLE payloads |
Requirements
.NET Framework 4.8, .NET Standard 2.0, .NET 8.0 or .NET 10.0. Conversion is stateless and concurrency-safe, and honours cancellation and configurable resource limits.
License
MIT. See LICENSE and THIRD-PARTY-NOTICES.md in the package.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 is compatible. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.8
- DocWright.Core (>= 1.1.1)
- DocWright.Cryptography (>= 1.1.1)
- DocWright.Dom (>= 1.1.1)
- DocWright.Fonts (>= 1.1.1)
- DocWright.Formats.Doc (>= 1.1.1)
- DocWright.Formats.Docx (>= 1.1.1)
- DocWright.Formats.Epub (>= 1.1.1)
- DocWright.Formats.Html (>= 1.1.1)
- DocWright.Formats.Markdown (>= 1.1.1)
- DocWright.Formats.Odt (>= 1.1.1)
- DocWright.Formats.Pdf (>= 1.1.1)
- DocWright.Formats.Rdl (>= 1.1.1)
- DocWright.Formats.Rtf (>= 1.1.1)
- DocWright.Formats.Text (>= 1.1.1)
- DocWright.Layout (>= 1.1.1)
- DocWright.Renderers.Imaging (>= 1.1.1)
- DocWright.Renderers.Pdf (>= 1.1.1)
- Microsoft.Bcl.HashCode (>= 1.1.1)
- System.Buffers (>= 4.6.1)
- System.Memory (>= 4.6.3)
- System.Runtime.CompilerServices.Unsafe (>= 6.1.2)
-
.NETStandard 2.0
- DocWright.Core (>= 1.1.1)
- DocWright.Cryptography (>= 1.1.1)
- DocWright.Dom (>= 1.1.1)
- DocWright.Fonts (>= 1.1.1)
- DocWright.Formats.Doc (>= 1.1.1)
- DocWright.Formats.Docx (>= 1.1.1)
- DocWright.Formats.Epub (>= 1.1.1)
- DocWright.Formats.Html (>= 1.1.1)
- DocWright.Formats.Markdown (>= 1.1.1)
- DocWright.Formats.Odt (>= 1.1.1)
- DocWright.Formats.Pdf (>= 1.1.1)
- DocWright.Formats.Rdl (>= 1.1.1)
- DocWright.Formats.Rtf (>= 1.1.1)
- DocWright.Formats.Text (>= 1.1.1)
- DocWright.Layout (>= 1.1.1)
- DocWright.Renderers.Imaging (>= 1.1.1)
- DocWright.Renderers.Pdf (>= 1.1.1)
- Microsoft.Bcl.HashCode (>= 1.1.1)
- System.Buffers (>= 4.6.1)
- System.Memory (>= 4.6.3)
- System.Runtime.CompilerServices.Unsafe (>= 6.1.2)
-
net10.0
- DocWright.Core (>= 1.1.1)
- DocWright.Cryptography (>= 1.1.1)
- DocWright.Dom (>= 1.1.1)
- DocWright.Fonts (>= 1.1.1)
- DocWright.Formats.Doc (>= 1.1.1)
- DocWright.Formats.Docx (>= 1.1.1)
- DocWright.Formats.Epub (>= 1.1.1)
- DocWright.Formats.Html (>= 1.1.1)
- DocWright.Formats.Markdown (>= 1.1.1)
- DocWright.Formats.Odt (>= 1.1.1)
- DocWright.Formats.Pdf (>= 1.1.1)
- DocWright.Formats.Rdl (>= 1.1.1)
- DocWright.Formats.Rtf (>= 1.1.1)
- DocWright.Formats.Text (>= 1.1.1)
- DocWright.Layout (>= 1.1.1)
- DocWright.Renderers.Imaging (>= 1.1.1)
- DocWright.Renderers.Pdf (>= 1.1.1)
-
net8.0
- DocWright.Core (>= 1.1.1)
- DocWright.Cryptography (>= 1.1.1)
- DocWright.Dom (>= 1.1.1)
- DocWright.Fonts (>= 1.1.1)
- DocWright.Formats.Doc (>= 1.1.1)
- DocWright.Formats.Docx (>= 1.1.1)
- DocWright.Formats.Epub (>= 1.1.1)
- DocWright.Formats.Html (>= 1.1.1)
- DocWright.Formats.Markdown (>= 1.1.1)
- DocWright.Formats.Odt (>= 1.1.1)
- DocWright.Formats.Pdf (>= 1.1.1)
- DocWright.Formats.Rdl (>= 1.1.1)
- DocWright.Formats.Rtf (>= 1.1.1)
- DocWright.Formats.Text (>= 1.1.1)
- DocWright.Layout (>= 1.1.1)
- DocWright.Renderers.Imaging (>= 1.1.1)
- DocWright.Renderers.Pdf (>= 1.1.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on DocWright:
| Package | Downloads |
|---|---|
|
DocWright.Composition
Build a document from code with a fluent, declarative API for DocWright — pages, headers and footers, columns, tables and text styling — then render it to PDF, images or .docx through the same pipeline as a loaded document. A composition is ordinary C#, so loops, conditionals and your own data just work. |
GitHub repositories
This package is not used by any popular GitHub repositories.
See https://github.com/albahadly/DocWright/releases for release notes.