Document .Net - Create a new document

Create a document

Document .Net supports these formats:

Let's create a simple document with "Hello World!" text:

A simple document - Hello World!

Main steps

  1. Notice you are importing the SautinSoft.Document namespace.
    using SautinSoft.Document;
  2. First of all, create an instance of DocumentCore.
    DocumentCore dc = new DocumentCore();
    DocumentCore is root class, it represents a document itself.
  3. Add text "Hello World!" into our document.
    dc.Content.End.Insert("Hello World!");
    ContentRange represents an area in document as a contiguous sequence of characters boundend by start and end positions. It allows to insert and extract data in a streaming manner in(from) desired positions.

Complete code

using SautinSoft.Document;

namespace Example
    class Program
        static void Main(string[] args)
        /// <summary>
        /// Creates a new document and saves it in a desired format.
        /// </summary>
        /// <remarks>
        /// Details:
        /// </remarks>
        static void CreateDocument()
            DocumentCore dc = new DocumentCore();
            dc.Content.End.Insert("Hello World!", new CharacterFormat() { FontName = "Verdana", Size = 65.5f, FontColor = Color.Orange });

            // Save a document to a file in DOCX format.
            string filePath = @"Result.docx";

            // Open the result for demonstration purposes.
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(filePath) { UseShellExecute = true });


            Imports SautinSoft.Document

Module Sample
    Sub Main()
    End Sub

    ''' <summary>
    ''' Creates a new document and saves it in a desired format.
    ''' </summary>
    ''' <remarks>
    ''' Details:
    ''' </remarks>
    Sub CreateDocument()
        Dim dc As New DocumentCore()
        dc.Content.End.Insert("Hello World!", New CharacterFormat() With {
                .FontName = "Verdana",
                .Size = 65.5F,
                .FontColor = Color.Orange

        ' Save a document to a file in DOCX format.
        Dim filePath As String = "Result.docx"

        ' Open the result for demonstration purposes.
        System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(filePath) With {.UseShellExecute = True})
    End Sub
End Module


If you need a new code example or have a question: email us at or ask at Online Chat (right-bottom corner of this page) or use the Form below:

Questions and suggestions from you are always welcome!

We are developing .Net components since 2002. We know PDF, DOCX, RTF, HTML, XLSX and Images formats. If you need any assistance with creating, modifying or converting documents in various formats, we can help you. We will write any code example for you absolutely free.

© SautinSoft 2002 - 2020