Viewer preferences

Docotic.Pdf Library Help > Samples > Display options > Viewer preferences

This sample shows how to specify a PDF viewer application preferences using PdfDocument.ViewerPreferences property.

A PDF viewer application preferences specify the way the document is to be displayed on the screen.

CopyC#
using System.Diagnostics;

namespace BitMiracle.Docotic.Pdf.Samples
{
    public static class ViewerPreferences
    {
        public static void Main()
        {
            // NOTE: 
            // When used in trial mode, the library imposes some restrictions.
            // Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx
            // for more information.

            PdfDocument pdf = new PdfDocument();

            pdf.ViewerPreferences.CenterWindow = true;
            pdf.ViewerPreferences.FitWindow = true;
            pdf.ViewerPreferences.HideMenuBar = true;
            pdf.ViewerPreferences.HideToolBar = true;
            pdf.ViewerPreferences.HideWindowUI = true;

            string pathToFile = "ViewerPreferences.pdf";
            pdf.Save(pathToFile);
            pdf.Dispose();

            Process.Start(pathToFile);
        }
    }
}
CopyVB.NET
Imports System.Diagnostics

Imports BitMiracle.Docotic.Pdf

Namespace BitMiracle.Docotic.Pdf.Samples
    Public NotInheritable Class ViewerPreferences
        Public Shared Sub Main()
            ' NOTE: 
            ' When used in trial mode, the library imposes some restrictions.
            ' Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx
            ' for more information.


            Dim pdf As New PdfDocument()

            pdf.ViewerPreferences.CenterWindow = True
            pdf.ViewerPreferences.FitWindow = True
            pdf.ViewerPreferences.HideMenuBar = True
            pdf.ViewerPreferences.HideToolBar = True
            pdf.ViewerPreferences.HideWindowUI = True

            Dim pathToFile As String = "ViewerPreferences.pdf"
            pdf.Save(pathToFile)
            pdf.Dispose()

            Process.Start(pathToFile)
        End Sub
    End Class
End Namespace