View preferences

This script allows to set some viewer preferences

Informations

Author: Michel Poulain
License: FPDF

Description

This script allows to set some viewer preferences.

DisplayPreferences(string preferences)

Available options are (case-sensitive):
  • FullScreen: displays the document full-screen (escape key to restore the normal view)
  • HideMenubar: hides the menu
  • HideToolbar: hides all toolbars
  • HideWindowUI: hides all window elements (scroll bars, navigation controls, bookmarks...)
  • DisplayDocTitle: displays the title of the document instead of the file name (no effect inside browser plug-in)
  • CenterWindow: centers the window (no effect inside browser plug-in)
  • FitWindow: sizes the window (if it's not maximized) to fit the page (no effect inside browser plug-in)

Source

<?php require('fpdf.php'); class PDF_ViewPref extends FPDF { var $DisplayPreferences=''; function DisplayPreferences($preferences) { $this->DisplayPreferences.=$preferences; } function _putcatalog() { parent::_putcatalog(); if(is_int(strpos($this->DisplayPreferences, 'FullScreen'))) $this->_out('/PageMode /FullScreen'); if($this->DisplayPreferences) { $this->_out('/ViewerPreferences<<'); if(is_int(strpos($this->DisplayPreferences, 'HideMenubar'))) $this->_out('/HideMenubar true'); if(is_int(strpos($this->DisplayPreferences, 'HideToolbar'))) $this->_out('/HideToolbar true'); if(is_int(strpos($this->DisplayPreferences, 'HideWindowUI'))) $this->_out('/HideWindowUI true'); if(is_int(strpos($this->DisplayPreferences, 'DisplayDocTitle'))) $this->_out('/DisplayDocTitle true'); if(is_int(strpos($this->DisplayPreferences, 'CenterWindow'))) $this->_out('/CenterWindow true'); if(is_int(strpos($this->DisplayPreferences, 'FitWindow'))) $this->_out('/FitWindow true'); $this->_out('>>'); } } } ?>

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(); ?>
View the result here.

Download

ZIP | TGZ

Quelle

http://www.fpdf.org/en/script/script51.php, zuletzt abgerufen 02.10.2016 15:10