DRIT.Document 26.9.1376

dotnet add package DRIT.Document --version 26.9.1376
                    
NuGet\Install-Package DRIT.Document -Version 26.9.1376
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DRIT.Document" Version="26.9.1376" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DRIT.Document" Version="26.9.1376" />
                    
Directory.Packages.props
<PackageReference Include="DRIT.Document" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DRIT.Document --version 26.9.1376
                    
#r "nuget: DRIT.Document, 26.9.1376"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DRIT.Document@26.9.1376
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DRIT.Document&version=26.9.1376
                    
Install as a Cake Addin
#tool nuget:?package=DRIT.Document&version=26.9.1376
                    
Install as a Cake Tool

DRIT.Document

Pure-Managed .NET Document Library

Create, Read, Manipulate, Sign, and Convert Documents

DRIT.Document is a pure-managed, cross-platform .NET library for document creation, word processing, conversion, and automation across DOCX, DOCM, DOC, ODT, and HTML — with full support for tables, lists, styles, charts, mail merge, track changes, form fields, footnotes and endnotes, comments, content controls, digital signatures (XAdES-BES), AES-256 encryption, VBA macros, and PDF export — without relying on any external software dependencies.

Key Benefits

  • Pure managed C# implementation with minimal NuGet dependencies
  • Consistent rendering results across Windows, Linux, macOS
  • Seamless migration path from GemBox.Document and other .NET document libraries
  • Full mail merge engine with scalar fields, range blocks, and nested collections
  • XAdES-BES digital signatures and AES-256 (ECMA-376 Agile) encryption
  • Integrated with DRIT.Pdf for PDF export and DRIT.Drawing for advanced graphics

Cross-Platform Document Library

DRIT.Document targets .NET Framework 4.8 and .NET Standard 2.0, so it runs on:

  • Operating Systems: Windows, Linux, macOS
  • Frameworks: .NET Framework 4.8, .NET Standard 2.0
  • Dependencies: DRIT.Pdf; DRIT.Drawing; System.Drawing.Common; System.Text.Encoding.CodePages

Features

Document I/O

  • Create — generate new documents from scratch
  • Load/Save — read from and write to file or stream (DOCX, DOCM, DOC, ODT, HTML), with load options (password, encryption expectation) and cancellation support
  • Merge & Split — combine the body content of two documents into one with conflict policies for styles and lists
  • Cross-format conversion — load DOCX, save as ODT or HTML (and vice-versa) with round-trip fidelity
  • Preservation — unknown and unmapped OpenXml elements are preserved for round-trip fidelity

Text and Formatting

  • Character formatting — font name, size, bold, italic, underline, strikethrough, color, all-caps, superscript, and subscript via Font
  • Paragraph formatting — alignment, left/right/first-line indentation, line spacing, space before/after, and paragraph borders with background color via ParagraphFormat
  • Styles — built-in paragraph styles (Heading 1, Heading 2, Normal) and custom character styles via StyleCollection
  • Rich text — inline formatting across multiple runs within a single paragraph
  • Breaks — line breaks, column breaks, and page breaks in multi-column sections

Document Structure

  • Sections — add, reorder, and remove sections with section breaks
  • Page setup — page size, orientation, margins, multi-column layout, and line numbering via PageSetup
  • Headers and footers — default, first-page-only, and odd/even page headers and footers with page numbering
  • Lists — bullet lists and numbered lists with multi-level indentation via List and ListFormat
  • Tables — create tables, set cell text, configure column widths, apply borders, merge cells, and shade header cells
  • Text columns — multi-column section layout with column count, spacing, and separators

Tables

  • Create — Body.AddTable(rows, cols) with header and data rows
  • Cell merging — horizontal and vertical merge via CellFormat.HorizontalMerge / VerticalMerge
  • Formatting — cell vertical alignment, table alignment, row heights, and preferred widths
  • Borders — table borders, cell borders, and shading
  • Bookmarks — insert bookmarks into paragraphs and locate them by name
  • Hyperlinks — external URL and email hyperlinks, and internal document references
  • Footnotes and endnotes — Document.AddFootnote / AddEndnote with reference insertion from paragraph runs
  • Table of contents — Paragraph.AppendTableOfContents with heading-style round-trip and field update settings

Comments and Review

  • Comments — attach reviewer comments to paragraph ranges with author, initials, and date
  • Track changes — DocumentSettings.TrackRevisions with RevisionCollection and AcceptAll / RejectAll

Fields and Forms

  • Fields — DocumentFieldInfo with FieldInstruction, IsLocked, and IsDirty (AUTHOR, DATE, IF, and more)
  • Form fields — text, check box, and drop-down form fields via AppendFormText / AppendFormCheckBox / AppendFormDropDown
  • Form data — read and update form field values via Document.FormFieldsData
  • Content controls — round-trip preservation of structured document tags (w:sdt)

Pictures, Shapes, and Charts

  • Pictures — embed images as inline shapes with Shape.SetImage
  • Shapes — drawing shapes with outline color, fill, and rotation via Shape
  • Text boxes — inline text-box shapes with body text via TextBoxShape
  • Watermarks — TextWatermark with diagonal layout, color, and semi-transparency
  • Charts — BarChart, LineChart, PieChart, ScatterChart, BubbleChart, AreaChart, RadarChart, StockChart, TreemapChart, SunburstChart, BoxWhiskerChart, FunnelChart, HistogramChart, MapChart, ParetoChart, WaterfallChart, and 3-D variants; titles, legends, axes, and data labels

Mail Merge

  • Scalar fields — Document.Merge(data) with {{FieldName}} token replacement
  • Range blocks — {{#Range}}...{{/Range}} block expansion for IEnumerable data sources
  • Nested collections — nested {{#Collection}}...{{/Collection}} block expansion
  • Callbacks — FieldMergingEventArgs and ImageFieldMergingEventArgs events for custom merge logic
  • Cleanup — MailMergeCleanupOptions for removing unused fields after merge

Find and Replace

  • Find — Document.Find(text) with StringComparison and FindReplaceOptions
  • Replace — Document.Replace(old, new) with plain-text, case-insensitive, and regex modes
  • Regex — Document.Find(Regex) and Document.Replace(Regex, replacement) with direction and options

Protection and Security

  • Restrict editing — DocumentSettings.Protection.StartEnforcingProtection with granular DocumentProtectionType and password
  • Write protection — DocumentSettings.WriteProtection.SetPassword / Recommended with SHA-512 hash round-trip
  • Encryption — AES-256 (ECMA-376 Agile) DOCX encryption with password-protected opening
  • Digital signatures — XAdES-BES with commitment type and signer role; SaveSigned, AppendDigitalSignature, ListDigitalSignatures, and RemoveDigitalSignatures

Macros and Automation

  • VBA macros — VbaProject with modules (AddModule / AddClass / AddDocument), references, and code read/write; save as .docm

Metadata

  • Document properties — built-in summary (Title, Author, Subject, Keywords, Company) and statistics via BuiltInDocumentProperties and Properties
  • Custom properties — user-defined key/value pairs via Properties.Custom
  • Document variables — string name/value pairs via Variables
  • Custom XML parts — persist custom XML in the package via CustomXmlParts

Conversion

  • PDF export — export documents to PDF with bookmarks, document properties, and font fallback via DocumentPdfExporter.SaveAsPdf
  • HTML export — flow-layout and fixed-layout HTML via HtmlSaveOptions and HtmlFixedSaveOptions
  • ODT — cross-format save to OpenDocument Text
  • Plain text — Document.GetText() for full-text extraction

Supported File Formats

Format Description Read Write
DOCX Microsoft Word Document ✔️ ✔️
DOCM Word Macro-Enabled Document ✔️ ✔️
DOC Legacy Word Binary Format ✔️ Preservation-only
ODT OpenDocument Text ✔️ ✔️
HTML HyperText Markup Language ✔️ ✔️
PDF Portable Document Format — ✔️

PDF export is provided via the integrated DRIT.Pdf companion.


Installation

1. Install via NuGet

  • Open Microsoft Visual Studio and the NuGet package manager
  • Search for "DRIT.Document"
  • Click Install to download and reference it in your project

2. Install via Package Manager Console

Install-Package DRIT.Document

3. Install via .NET CLI

dotnet add package DRIT.Document

Code Examples

Create a Document

using DRIT.Document;

// Initialize a new document
var doc = new Document();
var section = doc.AddSection();

// Add content
section.AddParagraph("NovaEdge Technologies — Employee Handbook 2026");
section.AddParagraph("This handbook sets out the company's policies and guidelines.");

// Save the document
doc.Save("output.docx");

Load and Iterate Document Content

using DRIT.Document;

// Load an existing document
var doc = new Document("input.docx");

// Iterate all body paragraphs
foreach (var para in doc.Sections[0].Body.Paragraphs)
{
    Console.WriteLine($"[Para] \"{para.GetText()}\"");
    foreach (var run in para.Runs)
    {
        Console.WriteLine($"  [Run] \"{run.Text}\" " +
            $"Bold={run.Font.Bold} Italic={run.Font.Italic} Size={run.Font.Size}");
    }
}

Apply Character Formatting

using DRIT.Document;

var doc = new Document();
var section = doc.AddSection();
var para = section.AddParagraph();

para.AppendRun("NovaEdge Technologies").Font.Bold = true;
para.AppendBreak(BreakType.LineBreak);

var italicRun = para.AppendRun("Employee Handbook 2026");
italicRun.Font.Italic = true;
italicRun.Font.Size = 16;

doc.Save("formatted.docx");

Create a Table

using DRIT.Document;
using DRIT.Document.Tables;

var doc = new Document();
var section = doc.AddSection();

// Create a 5-column table
var table = section.Body.AddTable(5, 5);
table.Alignment = TableAlignment.Center;

// Header row
string[] headers = { "SKU", "Product", "Category", "Unit Price", "Stock" };
for (int col = 0; col < headers.Length; col++)
{
    var cell = table.Rows[0].Cells[col];
    cell.SetText(headers[col]);
    cell.Paragraphs[0].Runs[0].Font.Bold = true;
}

// Data rows
string[][] data =
{
    new[] { "NE-SRV-001", "NebulaCore Server", "Servers", "4 899.00", "42" },
    new[] { "NE-MON-002", "ArcLight Monitor", "Displays", "649.00", "135" },
};
for (int r = 0; r < data.Length; r++)
    for (int c = 0; c < data[r].Length; c++)
        table.Rows[r + 1].Cells[c].SetText(data[r][c]);

doc.Save("table.docx");

Create a Chart

using DRIT.Document;
using DRIT.Document.Chart;

var doc = new Document();
var section = doc.AddSection();
var para = section.AddParagraph();

// Create a bar chart
var chart = new BarChart(doc);

// Set category labels
chart.Data.Categories.Add("Q1");
chart.Data.Categories.Add("Q2");
chart.Data.Categories.Add("Q3");
chart.Data.Categories.Add("Q4");

// Add series
chart.DataSeries.Add("Orion", "cache:[Q1|Q2|Q3|Q4]", "cache:[4200|5100|4800|6300]");
chart.DataSeries.Add("Vega",  "cache:[Q1|Q2|Q3|Q4]", "cache:[3100|2900|3600|4200]");
chart.DataSeries.Add("Lyra",  "cache:[Q1|Q2|Q3|Q4]", "cache:[1800|2400|3100|3900]");
chart.Data.ApplyCategoriesToSeries();

// Set the chart title and legend
chart.AddTitle();
chart.Title.FormattedText.Text = "Quarterly Revenue by Product";
chart.AddLegend();

// Append the chart to the paragraph
para.AppendChart(chart, 22, 14);

doc.Save("chart.docx");

Mail Merge

using DRIT.Document;

// Load a template with merge fields
var doc = new Document("template.docx");

// Perform merge with a dictionary data source
doc.Merge(new Dictionary<string, object>
{
    ["CustomerName"] = "Aiko Tanaka",
    ["ProductName"] = "NebulaCore Server",
    ["OrderDate"] = "2026-05-12",
    ["Quantity"] = "1",
    ["TotalPrice"] = "4 899.00"
});

doc.Save("merged.docx");

Find and Replace

using DRIT.Document;

var doc = new Document("input.docx");

// Find all occurrences
var matches = doc.Find("NovaEdge Technologies");
Console.WriteLine($"Found {matches.Count} occurrence(s).");

// Replace across the whole document
int replaced = doc.Replace("NovaEdge Technologies", "NovaEdge Technologies Ltd.");
Console.WriteLine($"Replaced {replaced} occurrence(s).");

doc.Save("updated.docx");

Add Headers and Footers

using DRIT.Document;

var doc = new Document();
var section = doc.AddSection();
section.PageSetup.DifferentFirstPageHeaderFooter = true;

// First-page header
var firstHeader = section.AddHeaderFooter(HeaderFooterType.HeaderFirst);
firstHeader.AddParagraph("NovaEdge Technologies — Employee Handbook");

// Default footer with page number
var footer = section.AddHeaderFooter(HeaderFooterType.FooterPrimary);
footer.AddParagraph("Page [page] of [numpages]");

doc.Save("headers.docx");

Track Changes

using DRIT.Document;

var doc = new Document("input.docx");

// Enable revision tracking
doc.DocumentSettings.TrackRevisions = true;

// Make an edit — it will be recorded as a revision
doc.Sections[0].Body.AddParagraph("Revised section added during review.");

// Accept or reject all tracked changes
doc.Revisions.AcceptAll();
// doc.Revisions.RejectAll();

doc.Save("tracked.docx");

Export to PDF

using DRIT.Document;
using DRIT.Document.Export.Pdf;

var doc = new Document("input.docx");

// Export entire document to PDF
doc.SaveAsPdf("output.pdf", new DocumentPdfSaveOptions
{
    IncludeBookmarks = true,
    CopyDocumentProperties = true
});

// Export specific sections only
doc.SaveAsPdf("sections.pdf", new DocumentPdfSaveOptions
{
    SectionIndexes = new[] { 0, 1 }
});

Encrypt a Document

using DRIT.Document;

var doc = new Document();
doc.Sections[0].Body.AddParagraph("Confidential content");

// Save with AES-256 encryption
doc.Save("encrypted.docx", new DocumentSaveOptions
{
    EncryptionMode = DocxEncryptionMode.Ecma376Agile,
    Password = "open-password"
});

// Open with the correct password
var loaded = new Document("encrypted.docx",
    new DocumentLoadOptions { Password = "open-password" });
Console.WriteLine($"Paragraphs: {loaded.Sections[0].Body.Paragraphs.Count}");

Add a Digital Signature

using System.Security.Cryptography.X509Certificates;
using DRIT.Document;

var doc = new Document();
doc.Sections[0].Body.AddParagraph("Signed content");

// Sign with a PFX certificate (XAdES-BES)
var certificate = new X509Certificate2("certificate.pfx", "password");
doc.SaveSigned("signed.docx", new DocxDigitalSignatureSaveOptions
{
    Certificate = certificate,
    SignerRole = "Author"
});

// Validate on reload
var signatures = Document.ListDigitalSignatures("signed.docx");
Console.WriteLine($"Signatures: {signatures.Count}");

Create a Macro-Enabled Document

using DRIT.Document;

var doc = new Document();
doc.Sections[0].Body.AddParagraph("Macro-enabled document");

// Add a VBA module
var module = doc.VbaProject.Modules.AddModule("HandbookHelpers");
module.Code = @"
Sub InsertDisclaimer()
    Selection.TypeText ""Confidential — NovaEdge Technologies""
End Sub";

// Save as .docm
doc.Save("macros.docm");

// Edit existing code
var loaded = new Document("macros.docm");
var existing = loaded.VbaProject.Modules["HandbookHelpers"];
existing.Code = existing.Code.Replace("InsertDisclaimer", "InsertConfidential");
loaded.Save("macros_edited.docm");

System Requirements

  • Target Frameworks: .NET Framework 4.8, .NET Standard 2.0
  • Dependencies: DRIT.Pdf; DRIT.Drawing; System.Drawing.Common; System.Text.Encoding.CodePages
  • Optional: DRIT.Pdf for PDF export (bundled)

Documentation


© 2021-2026 DR-IT Ltd. All Rights Reserved.

Product 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 was computed.  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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
26.9.1376 69 9/19/2026

-Initial release.
     -Binary DOC read support with preservation for roundtrip fidelity.
     -ODT format support with conversion-first mapping and preserve-first passthrough.