Add-On View preferences
Informations
Author: Michel PoulainLicense: FPDF
Description
This script allows to set some viewer preferences.DisplayPreferences(string preferences)
The available settings are (case-sensitive):
FullScreen
: displays the document full-screenHideMenubar
: hides the menuHideToolbar
: hides all toolbarsHideWindowUI
: hides all window elements (scrollbars, navigation controls, bookmarks...)DisplayDocTitle
: displays the title of the document instead of the file nameCenterWindow
: centers the windowFitWindow
: sizes the window (when not maximized) to fit the page
Source
<?php
require('fpdf.php');
class PDF_ViewPref extends FPDF {
protected $DisplayPreferences = '';
function DisplayPreferences($preferences) {
$this->DisplayPreferences = $preferences;
}
function _putcatalog()
{
parent::_putcatalog();
if(is_int(strpos($this->DisplayPreferences, 'FullScreen')))
$this->_put('/PageMode /FullScreen');
if($this->DisplayPreferences) {
$this->_put('/ViewerPreferences<<');
if(is_int(strpos($this->DisplayPreferences, 'HideMenubar')))
$this->_put('/HideMenubar true');
if(is_int(strpos($this->DisplayPreferences, 'HideToolbar')))
$this->_put('/HideToolbar true');
if(is_int(strpos($this->DisplayPreferences, 'HideWindowUI')))
$this->_put('/HideWindowUI true');
if(is_int(strpos($this->DisplayPreferences, 'DisplayDocTitle')))
$this->_put('/DisplayDocTitle true');
if(is_int(strpos($this->DisplayPreferences, 'CenterWindow')))
$this->_put('/CenterWindow true');
if(is_int(strpos($this->DisplayPreferences, 'FitWindow')))
$this->_put('/FitWindow true');
$this->_put('>>');
}
}
}
?>
Example
<?php
require('viewpref.php');
$pdf=new PDF_ViewPref();
$pdf->SetDisplayMode('fullpage');
$pdf->DisplayPreferences('HideMenubar, HideToolbar, HideWindowUI');
$pdf->AddPage();
$pdf->SetFont('Arial', '', 16);
$pdf->Write(6, 'Only the document should appear, no interface elements.');
$pdf->Output();
?>