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

GemBox.Document is a C# / VB.NET library that 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 the need for Microsoft Word on either the developer's or the client's machine.

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

GemBox.Document examples are listed on the right side of the page. Use the list to explore the supported features.

Below the example description, there are run options, which are used to specify the output file format and execute the example using GemBox.Document in Professional mode (without any limitations). For more information about GemBox.Document modes (Free, Trial, Time Limited, and Professional), see the Evaluation and Licensing help page.

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.


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.