Convert Word and PDF in C# and VB.NET

GemBox.Document enables you to easily convert documents into different file formats in C# and VB.NET. For example, you can convert Word files into a different Word format or into PDF, XPS, and image formats.

To do this, just load a Word document and save it into another file format as in the following sample. For more details about supported document file formats in GemBox.Document, see Supported File Formats.

Screenshot

Convert Word to PDF Screenshot

See the full code below, use RUN EXAMPLE to execute.

Upload your file (Drag files here)

1using System;
2using System.Linq;
3using System.Text;
4using GemBox.Document;
5using GemBox.Document.Tables;
6using System.Text.RegularExpressions;
7
8class Sample
9{
10    [STAThread]
11    static void Main(string[] args)
12    {
13        // If using Professional version, put your serial key below.
14        ComponentInfo.SetLicense("FREE-LIMITED-KEY");
15
16        DocumentModel document = DocumentModel.Load("Reading.doc");
17
18        // In order to achieve the conversion of a loaded Word file to PDF,
19        // or to some other Word format,
20        // we just need to save a DocumentModel object to desired output file format.
21
22        document.Save("Convert.docx");
23    }
24}
1Imports System
2Imports System.Linq
3Imports System.Text
4Imports GemBox.Document
5Imports GemBox.Document.Tables
6Imports System.Text.RegularExpressions
7
8Module Samples
9
10    Sub Main()
11
12        ' If using Professional version, put your serial key below.
13        ComponentInfo.SetLicense("FREE-LIMITED-KEY")
14
15        Dim document As DocumentModel = DocumentModel.Load("Reading.doc")
16
17        ' In order to achieve the conversion of a loaded Word file to PDF,
18        ' or to some other Word format,
19        ' we just need to save a DocumentModel object to desired output file format.
20        document.Save("Convert.docx")
21
22    End Sub
23
24End Module

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