Table of Contents

Introduction to DocWright

DocWright is a .NET library for Word documents. It reads DOCX and legacy DOC files, lets you edit them or build new ones in code, and writes PDF, page images, or eight other document formats. Its PDF and images are laid out the way Microsoft Word lays out the same document. It runs entirely in managed code, with no Office, no COM interop and no native binaries.

DocWright net48netstandard2.0net8.0net10.0

What you can do with it

You want to… Start here
Turn a .docx or .doc into a PDF Your first conversion
Make thumbnails or page previews Load once, render many
Fill a template with data, or run a mail merge Tutorials
Edit a document: replace text, fill forms, add content Find and replace, Forms
Build a document from scratch in C# Build a report in code
Merge, split or reorder existing PDF files Assemble a board pack
Run an SSRS .rdl report and export it Run an SSRS report

How it is organised

Almost everything goes through one class, DocWrightConverter, in the DocWright namespace. It reads a document into an editable model called WordDocument, lays it out, and writes it out again:

 .docx .doc .rtf .html .md .txt
              │
              ▼  converter.Load(...)
        WordDocument  ── edit it: find & replace, fields, forms, tables …
              │
              ├─▶ converter.Convert(...)          → PDF
              ├─▶ converter.ConvertToImages(...)  → PNG / JPEG, one per page
              └─▶ converter.Save(..., ".html")    → DOCX, HTML, RTF, Markdown, text, ODT, EPUB, RDL

Convert and ConvertToImages also accept a stream directly, so a plain conversion never needs to see the model at all. Features you only need sometimes, such as mail merge, document comparison, fluent composition, digital signatures and reporting, ship as separate packages that attach to the same model. Choose your packages lists them.

Three promises worth knowing up front

  • Deterministic output. The same input and options produce byte-identical output on every framework, operating system and architecture. You can hash a PDF in a test and it stays stable.
  • Safe to share. A DocWrightConverter holds no per-conversion state. Create one and use it from every thread in your application. The document model is the exception: one WordDocument, one thread.
  • Nothing is fetched. No reader, writer or renderer reaches the network or the file system for a document. Where you want that, as with images for HTML import or merge images, you supply the callback.

Next steps

Support and contact

Questions, feedback, support or licensing: email salwan@albahadly.com or visit www.albahadly.com.