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

GemBox.Document is a C# / VB.NET library which provides a simple and efficient way to process Word files. It enables developers to read, write, convert and print document files (DOCX, DOC, PDF, HTML, XPS, RTF and TXT) from .NET applications without a need for Microsoft Word on either the developer or client machines.

GemBox.Document for .NET 3.0 - 4.6 requires .NET Framework version 3.0 or above.

Notice that on the right side you have GemBox.Document Examples section with which you can navigate through examples and explore supported features.

Also below the example description you have Run options where you can choose output file format and execute the example using GemBox.Document in Professional mode. GemBox.Document also offers Free and Trial modes, see Evaluation and Licensing.

Hello World

Following sample creates a simple Word file, with 'Hello World!' text, in C# and VB.NET code. It shows how to initialize GemBox.Document content model, populate common document elements - Section, Paragraph and Run, and then save DocumentModel 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.


1using System;
2using GemBox.Document;
3
4class Sample
5{
6    [STAThread]
7    static void Main(string[] args)
8    {
9        // If using Professional version, put your serial key below.
10        ComponentInfo.SetLicense("FREE-LIMITED-KEY");
11
12        DocumentModel document = new DocumentModel();
13
14        Section section = new Section(document);
15        document.Sections.Add(section);
16
17        Paragraph paragraph = new Paragraph(document);
18        section.Blocks.Add(paragraph);
19
20        Run run = new Run(document, "Hello World!");
21        paragraph.Inlines.Add(run);
22
23        document.Save("Hello World.docx");
24    }
25}
1Imports System
2Imports GemBox.Document
3
4Module Samples
5
6    Sub Main()
7
8        ' If using Professional version, put your serial key below.
9        ComponentInfo.SetLicense("FREE-LIMITED-KEY")
10
11        Dim document As DocumentModel = New DocumentModel
12
13        Dim section As New Section(document)
14        document.Sections.Add(section)
15
16        Dim paragraph As New Paragraph(document)
17        section.Blocks.Add(paragraph)
18
19        Dim run As New Run(document, "Hello World!")
20        paragraph.Inlines.Add(run)
21
22        document.Save("Hello World.docx")
23
24    End Sub
25
26End Module

Check next sample or find out more about GemBox.Document and GemBox Software.