Set Viewer Preference of an existing PDF File
Set 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.
ChangeViewerPreference method in PdfContentEditor class allows you to change the viewer preference. In order to do that, you need to create an object of PdfContentEditor class and bind the input PDF file using bindPdf method.
Ater that, you can call ChangeViewerPreference method to set any preference. Finally, you have to save the updated PDF file using Save method. The following code snippet shows you how to change viewer preference in an existing PDF file.
For example, we specify the parameter CENTER WINDOW with which we center the window, after remove the top toolbar with HIDE MENUBAR and with PAGE MODE USE NONE open full-screen mode.
public static void SetViewerPreference()
{
var document = new Document(_dataDir + "Sample.pdf");
PdfContentEditor editor = new PdfContentEditor(document);
// Change Viewer Preferences
editor.changeViewerPreference(ViewerPreference.CENTER_WINDOW);
editor.changeViewerPreference(ViewerPreference.HIDE_MENUBAR);
editor.changeViewerPreference(ViewerPreference.PAGE_MODE_USE_NONE);
editor.save(_dataDir + "PdfContentEditorDemo_SetViewerPreference.pdf");
GetViewerPreference();
}