Set PDF View Preference in C#/VB.NET

PDF view preference allows users to view PDF with specified view mode or display layout. In order to have a more comfortable reading effect, users can set view preference according to own reading custom, for example, hiding menu bar or tool bar, two page view, full screen etc.

Spire.PDF for .NET, the stand-alone .NET PDF component to create and write PDF documents, enables users to set PDF view preference by using C#, VB.NET. And this guide will introduce a method to set via Spire.PDF for .NET.

After loading PDF document which you want to set view preference, then set properties of ViewerPreference class, including CenterWindow, HideMenubar, PageLayout and PageMode. The following screenshot shows PDF document with the following result:

Set PDF View Preference

Download and install Spire.PDF for .NET and then use the following code to set PDF preference with C#, VB.NET.

using System;
using Spire.Pdf;

namespace ViewPreference
    class View
        static void Main(string[] args)
            PdfDocument doc = new PdfDocument(); ;
            doc.LoadFromFile(@"E:\New Zealand.pdf");

            doc.ViewerPreferences.CenterWindow = true;
            doc.ViewerPreferences.HideMenubar = true;
            doc.ViewerPreferences.PageLayout = PdfPageLayout.TwoPageLeft;
            doc.ViewerPreferences.PageMode = PdfPageMode.FullScreen;

            //Save and Launch
Imports System
Imports Spire.Pdf

Namespace ViewPreference
    Friend Class View
        Shared Sub Main(ByVal args() As String)
            Dim doc As New PdfDocument()

            doc.LoadFromFile("E:\New Zealand.pdf")

            doc.ViewerPreferences.CenterWindow = True
            doc.ViewerPreferences.HideMenubar = True
            doc.ViewerPreferences.PageLayout = PdfPageLayout.TwoPageLeft
            doc.ViewerPreferences.PageMode = PdfPageMode.FullScreen

            'Save and Launch
        End Sub
    End Class
End Namespace

Spire.PDF for is a professional PDF component applied to create, read, write, edit and handle PDF documents without any external dependencies within .NET, WPF and Silverlight application.