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