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 various supported Word features in GemBox.Document.

System Requirements

GemBox.Document requires only the .NET Framework version 3.0 or above.

Hello World

The following example creates a simple Word file, with 'Hello World!' text, using C# and VB.NET code. 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
Word and PDF Library for C# / VB.NET Screenshot

See the full code below, use Run Example to execute.

using System;
using GemBox.Document;

class Sample
{
    [STAThread]
    static void Main(string[] args)
    {
        // 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.docx");
    }
}
Imports System
Imports GemBox.Document

Module Samples

    Sub Main()

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

        Dim document As DocumentModel = 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.docx")

    End Sub

End Module

Check next sample.