Get Viewer Preference of an existing PDF File

Get Viewer Preference of an existing PDF File

ViewerPreference class represents display modes of PDF files; for example, positioning the document window in the center of the screen, hiding viewer application’s menu bar etc.

In order to read the settings we use ‘getViewerPreference’. This method returns a variable where all settings are saved.

 public static void GetViewerPreference()
        {
            var document = new Document(_dataDir + "PdfContentEditorDemo_SetViewerPreference.pdf");
            PdfContentEditor editor = new PdfContentEditor(document);

            // Change Viewer Preferences
            var preferences = editor.getViewerPreference();
            if ((preferences & ViewerPreference.CENTER_WINDOW) != 0)
                System.out.println("CenterWindow");
            if ((preferences & ViewerPreference.HIDE_MENUBAR) != 0)
                System.out.println("Menu bar hided");
        }