Set View Options in Word Documents Using C# and VB.NET

View options are used to define document view and zoom when a document is viewed in an application such as Microsoft Word or Adobe Reader. GemBox.Document represents them with the ViewOptions class.

Note, the ViewType.FullScreen option is only supported for PDF files.

The following example shows how you can set the document view type and zoom.

Word document with set view options like zoom
Screenshot of Word file with specified view options
using GemBox.Document;

class Program
{
    static void Main()
    {
        // If using the Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");
        
        var document = new DocumentModel();

        document.Sections.Add(
            new Section(document,
                new Paragraph(document, " ")));

        var viewOptions = document.ViewOptions;
        viewOptions.ViewType = ViewType.Web;
        viewOptions.Zoom = %Zoom%;

        document.Save("View Options.%OutputFileType%");
    }
}
Imports GemBox.Document

Module Program

    Sub Main()

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

        Dim document As New DocumentModel()

        document.Sections.Add(
            New Section(document,
                New Paragraph(document, " ")))

        Dim viewOptions = document.ViewOptions
        viewOptions.ViewType = ViewType.Web
        viewOptions.Zoom = %Zoom%

        document.Save("View Options.%OutputFileType%")

    End Sub
End Module

See also


Next steps

GemBox.Document is a .NET component that enables you to read, write, edit, convert, and print document files from your .NET applications using one simple API. How about testing it today?

Download Buy