Hello World

GemBox.Document is a .NET component that enables developers to read, write, convert and print document files (DOCX, DOC, PDF, HTML, XPS, RTF and TXT) from .NET applications in a simple and efficient way without a need for Microsoft Word on either the developer or client machines.

Following sample creates a simple file with 'Hello World!' text using GemBox.Document component.

It shows how to initialize our object model, populate common document elements - Section, Paragraph and Run, and then save it to a file.

Screenshot

Hello World 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.