Index
- Installation
- Getting Started
- Memory Usage
- Readers and Writers
- The Document Class
- Metadata
- Pages
- Canvas
- Page Layout and Mode
- Viewer Preferences
- Document Outline
- Page Labels
- Actions
- Destinations
- Annotations
- Embedded File Streams
- Colors and Color Spaces
- Page Formats and Boundaries
- Standard and Public Key Encryption
- Fonts and Encodings
- Corrupted Documents
- Reader Enabled Documents
- Refactor Old SetaPDF Code
- API Reference
Viewer Preferences Control the way the document shall be presented on screen or in print.
Table of Contents
Introduction
The viewer preferences dictionary of a PDF document allows you to control the way the document shall be presented on the screen or in print. This preferences are available through the SetaPDF_Core_Document_Catalog_ViewerPreferences
class.
The Viewer Preferences Class
To get access to the viewer preferences the SetaPDF-Core component offers a helper method on the catalog instance of a document:
$viewerPreferences = $document->getCatalog()->getViewerPreferences();
Methods
The class offers following public methods:
__construct()
The constructor.
cleanUp()
Release memory and cycled references.
getCenterWindow()
Get the flag specifying whether to position the document’s window in the center of the screen.
getDirection()
Get the predominant reading order for text.
getDisplayDocTitle()
Get the flag whether the title or the filename of the document should be displayed in the window’s title bar.
getDocument()
Get the document instance.
getDuplex()
Get the paper handling option that shall be used when printing the file from the print dialog.
getFitWindow()
Get the flag specifying whether to resize the document’s window to fit the size of the first displayed page.
getHideMenubar()
Get the flag specifying whether to hide the conforming reader’s menu bar when the document is active.
getHideToolbar()
Get the flag specifying whether to hide the conforming reader’s tool bars when the document is active.
getHideWindowUI()
Get flag specifying whether to hide user interface elements in the document’s window (such as scroll bars and navigation controls), leaving only the document’s contents displayed.
getNonFullScreenPageMode()
Get the document's page mode, specifying how to display the document on exiting full-screen mode.
getNumCopies()
Get the number of copies that shall be printed when the print dialog is opened.
getPickTrayByPdfSize()
Get the flag specifying whether the PDF page size shall be used to select the input paper tray.
getPrintArea()
Get the name of the page boundary representing the area of a page that shall be rendered when printing the document.
getPrintClip()
Get the name of the page boundary to which the contents of a page shall be clipped when printing the document.
getPrintPageRange()
Get the page numbers used to initialize the print dialog box when the file is printed.
getPrintScaling()
Get the page scaling option that shall be selected when a print dialog is displayed for this document.
getViewArea()
Get the page boundary representing the area of a page that shall be displayed when viewing the document on the screen.
getViewClip()
Get the name of the page boundary to which the contents of a page shall be clipped when viewing the document on the screen.
setCenterWindow()
Set the flag specifying whether to position the document’s window in the center of the screen.
setDirection()
Set the predominant reading order for text.
setDisplayDocTitle()
Set the flag whether the title or the filename of the document should be displayed in the window’s title bar.
setDuplex()
Set the paper handling option that shall be used when printing the file from the print dialog.
setFitWindow()
Set the flag specifying whether to resize the document’s window to fit the size of the first displayed page.
setHideMenubar()
Set the flag specifying whether to hide the conforming reader’s menu bar when the document is active.
setHideToolbar()
Set the flag specifying whether to hide the conforming reader’s tool bars when the document is active.
setHideWindowUI()
Set flag specifying whether to hide user interface elements in the document’s window (such as scroll bars and navigation controls), leaving only the document’s contents displayed.
setNonFullScreenPageMode()
Set the document's page mode, specifying how to display the document on exiting full-screen mode.
setNumCopies()
Set the number of copies that shall be printed when the print dialog is opened for this file.
setPickTrayByPdfSize()
Set the flag specifying whether the PDF page size shall be used to select the input paper tray.
setPrintArea()
Set the name of the page boundary representing the area of a page that shall be rendered when printing the document.
setPrintClip()
Set the name of the page boundary to which the contents of a page shall be clipped when printing the document.
setPrintPageRange()
Set the page numbers used to initialize the print dialog box when the file is printed.
setPrintScaling()
Set the page scaling option that shall be selected when a print dialog is displayed for this document.
setViewArea()
Set the page boundary representing the area of a page that shall be displayed when viewing the document on the screen.
setViewClip()
Set the name of the page boundary to which the contents of a page shall be clipped when viewing the document on the screen.
Constants
For specific keywords/names or values the class offer pre-defined constants which could be used as method arguments:
Constant value for predominant reading order for text.
Left to right.
Constant value for predominant reading order for text.
Right to left.
Constant value of the paper handling option that shall be used when printing the file from the print dialog.
Duplex and flip on the long edge of the sheet.
Constant value of the paper handling option that shall be used when printing the file from the print dialog.
Duplex and flip on the short edge of the sheet.
Constant value of the paper handling option that shall be used when printing the file from the print dialog.
Print single-sided.
Constant value specifying how to display the document on exiting full-screen mode.
Neither document outline nor thumbnail images visible.
Constant value specifying how to display the document on exiting full-screen mode.
Optional content group panel visible.
Constant value specifying how to display the document on exiting full-screen mode.
Document outline visible.
Constant value specifying how to display the document on exiting full-screen mode.
Thumbnail images visible.
Constant value of the the page scaling option that shall be selected when a print dialog is displayed for this document.
Reader’s default print scaling.
Constant value of the the page scaling option that shall be selected when a print dialog is displayed for this document.
No page scaling.
Examples
$viewerPreferences = $document->getCatalog()->getViewerPreferences(); // define that the document title should be displayed in the window title $viewerPreferences->setDisplayDocTitle(); // set print scaling to none $viewerPreferences->setPrintScaling( SetaPDF_Core_Document_Catalog_ViewerPreferences::PRINT_SCALING_NONE ); // set duplex mode $viewerPreferences->setDuplex( SetaPDF_Core_Document_Catalog_ViewerPreferences::DUPLEX_FLIP_SHORT_EDGE ); // print only pages 2-4, 6-8 $viewerPreferences->setPrintPageRange(array(2, 4, 6, 8)); // set number of copies $viewerPreferences->setNumCopies(2);