Word and PDF Library for C# and VB.NET applications

The fastest way how you can get started with GemBox.Document library is by exploring our collection of C# and VB.NET examples. These are live examples that demonstrate the supported features and APIs that can be used to achieve various Word and PDF related tasks with the GemBox.Document component.

System Requirements

GemBox.Document works on .NET Framework 3.5 or higher and platforms that implement .NET Standard 2.0 or higher. It doesn't have any other dependency.

Hello World

The first step in using the GemBox.Document library is to add a reference to GemBox.Document.dll within your C# or VB.NET project. There are three ways to do that.

a) Add from NuGet.

You can add GemBox.Document as a package using the following command from the NuGet Package Manager Console: Install-Package GemBox.Document

Or you can search and add GemBox.Document from the NuGet Package Manager.

Adding GemBox.Document library from NuGet

b) Add from Setup.

You can download the GemBox.Document Setup from this page. After installing the setup, you can add a reference to GemBox.Document.dll from the Global Assembly Cache (GAC).

Adding GemBox.Document library from GAC

c) Add from a DLL file.

You can download a GemBox.Document.dll file from this page and add a reference by browsing to it.

Adding GemBox.Document library from DLL

The second step is to add a directive for the GemBox.Document namespace.
For a C# project, use: using GemBox.Document;
For a VB.NET project, use: Import GemBox.Document

The third step is to set the license key to use GemBox.Document in one of its working modes.
To use a Free mode in a C# project, use: ComponentInfo.SetLicense("FREE-LIMITED-KEY");
To use a Free mode in a VB.NET project, use: ComponentInfo.SetLicense("FREE-LIMITED-KEY")
You can read more about GemBox.Document's working modes on the Evaluation and Licensing help page.

The last step is to write your application-specific Word code, like the following example code that shows how to create a simple document. It shows how to initialize the GemBox.Document content model, populate common document elements (Section, Paragraph and Run, and then save a DocumentModel instance to a Word or PDF file.

Screenshot of simple Word file created with GemBox.Document
Simple Word file created with GemBox.Document
using GemBox.Document;

class Program
{
    static void Main()
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        DocumentModel document = new DocumentModel();

        Section section = new Section(document);
        document.Sections.Add(section);

        Paragraph paragraph = new Paragraph(document);
        section.Blocks.Add(paragraph);

        Run run = new Run(document, "Hello World!");
        paragraph.Inlines.Add(run);

        document.Save("Hello World.%OutputFileType%");
    }
}
Imports GemBox.Document

Module Program

    Sub Main()

        ' If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY")

        Dim document As New DocumentModel()

        Dim section As New Section(document)
        document.Sections.Add(section)

        Dim paragraph As New Paragraph(document)
        section.Blocks.Add(paragraph)

        Dim run As New Run(document, "Hello World!")
        paragraph.Inlines.Add(run)

        document.Save("Hello World.%OutputFileType%")

    End Sub

End Module

Check next example or download examples from GitHub.