Code Examples
Save as
API Reference
Version History

"How programmatically create DOCX in C# using Document .Net library?"


If you are looking for a solution to programmatically create DOCX in C# or VB.Net, you are in the right place!

How programmatically create DOCX in C# using Document .Net library?

Document .Net is 100% managed C# assembly (SautinSoft.Document.dll) which gives you API to generate Office Open XML (DOCX) documents.

Your .Net app will be able to create DOCX documents with any desired formatting, such as:

  • Insert formatted text, paragraphs, images, plain and nested tables.
  • Set page size and orientation (height, width, margin vals).
  • Set font type/name, style, and size.
  • Add page numbering and page breaks, headers and footers.
  • Add sections and pages, bookmarks, Table of contents.
  • Full Unicode support.

The library is absolutely standalone and does not require Microsoft Office or any others.


At a machine with Intel Core i5-3337U and 4GB of RAM the Document .Net generates a simple DOCX document (one page filled by formatted text) without saving it to HDD:

  • 1000 documents by 0.45 sec.
  • 10000 documents by 3.61 sec.

Implementation and code samples

To get the full set of API to operate with DOCX, you have to only add a reference to "SautinSoft.Document.dll".

It's easy to add reference to SautinSoft.Document.dll

1. Let's see how easy to create DOCX document in C# application:

Hello My Friend.docx
            // Let's create a simple DOCX document.
            DocumentCore docx = new DocumentCore();
            docx.Content.End.Insert("Hello my Friend!", new CharacterFormat() { Size = 14, FontName = "Arial"});

2. Let's add a table (2x3) in DOCX using for-loop:

            // Let's create a simple DOCX document.
            DocumentCore docx = new DocumentCore();

            // Add a new section
            Section s = new Section(docx);

            // Let's create a plain table: 2x3.
            Table t = new Table(docx);            

            // Add 2 rows.
            for (int r = 0; r < 2; r++)
                TableRow row = new TableRow(docx);
                // Add 3 columns.
                for (int c = 0; c < 3; c++)
                    TableCell cell = new TableCell(docx);

                    // Set some cell formatting
                    cell.CellFormat.Borders.SetBorders(MultipleBorderTypes.Outside, BorderStyle.Single, Color.Blue, 1.0);
                    cell.CellFormat.PreferredWidth = new TableWidth(60, TableWidthUnit.Point);


                    cell.Content.Start.Insert(String.Format("[{0}, {1}]", r, c));
            // Add this table to the current section.

3. If you want to add an image in DOCX in your .Net app:

            // Let's create a simple DOCX document.
            DocumentCore docx = new DocumentCore();

            // Add a new section
            Section s = new Section(docx);

            // Add the image as a shape with coordinates.
            Picture pict1 = new Picture(docx, "image1.jpg");

            FloatingLayout fl = new FloatingLayout(
                new HorizontalPosition(10, LengthUnit.Millimeter, HorizontalPositionAnchor.Page),
                new VerticalPosition(10, LengthUnit.Millimeter, VerticalPositionAnchor.TopMargin),
                new Size(70, 70));
            DrawingElement drawingElement = new DrawingElement(docx, fl, pict1);

Requrements and Technical Information

Document .Net is compatible with all .Net languages and supports all OS (Windows, MacOS and Linux) where .Net Framework or .Net Core can be used. It's entirely written in managed C#, which makes it absolutely standalone and independent.

.Net Framework 4.0 and higher and .Net Core 1.1 and higher

.Net Framework 4.0, 4.5, 4.6.1 and higher.

.Net Core 2.0 and higher.

Reasonable prices

     The library offers for developers comprehensive API to do all what they want with DOCX, RTF, HTML, PDF and Text formats at reasonably prices. The main point of interest is that «Document .Net» is less expensive than all of its more or less popular counterparts. For example, a single license of Document .Net - Standard Edition starts from $530.


To see this functionality firsthand, download the freshest «Document .Net» with code examples, 22.0 Mb.


Products Downloads Support Company
Buy now
Follow us on Google Plus SautinSoft on Facebook SautinSoft on Twitter SautinSoft on Youtube Our Blog
Copyright © 2002 - 2018 SautinSoft (started from All rights reserved.