@@ -186,6 +186,9 @@ var jsPDF = (function(global) {
186186 content_length = 0 ,
187187 pageWidth ,
188188 pageHeight ,
189+ pageMode ,
190+ zoomMode ,
191+ layoutMode ,
189192 documentProperties = {
190193 'title' : '' ,
191194 'subject' : '' ,
@@ -609,8 +612,39 @@ var jsPDF = (function(global) {
609612 out ( '/Type /Catalog' ) ;
610613 out ( '/Pages 1 0 R' ) ;
611614 // @TODO : Add zoom and layout modes
612- out ( '/OpenAction [3 0 R /FitH null]' ) ;
613- out ( '/PageLayout /OneColumn' ) ;
615+ // PDF13ref Section 7.2.1
616+ if ( ! zoomMode ) zoomMode = 'fullwidth' ;
617+ switch ( zoomMode ) {
618+ case 'fullwidth' : out ( '/OpenAction [3 0 R /FitH null]' ) ; break ;
619+ case 'fullheight' : out ( '/OpenAction [3 0 R /FitV null]' ) ; break ;
620+ case 'fullpage' : out ( '/OpenAction [3 0 R /Fit]' ) ; break ;
621+ case 'original' : out ( '/OpenAction [3 0 R /XYZ null null 1]' ) ; break ;
622+ default :
623+ var pcn = '' + zoomMode ;
624+ if ( pcn . substr ( pcn . length - 1 ) === '%' )
625+ zoomMode = parseInt ( zoomMode ) / 100 ;
626+ if ( typeof zoomMode === 'number' ) {
627+ out ( '/OpenAction [3 0 R /XYZ null null ' + f2 ( zoomMode ) + ']' ) ;
628+ }
629+ }
630+ if ( ! layoutMode ) layoutMode = 'continuous' ;
631+ switch ( layoutMode ) {
632+ case 'continuous' : out ( '/PageLayout /OneColumn' ) ; break ;
633+ case 'single' : out ( '/PageLayout /SinglePage' ) ; break ;
634+ case 'two' :
635+ case 'twoleft' : out ( '/PageLayout /TwoColumnLeft' ) ; break ;
636+ case 'tworight' : out ( '/PageLayout /TwoColumnRight' ) ; break ;
637+ }
638+ if ( pageMode ) {
639+ /**
640+ * A name object specifying how the document should be displayed when opened:
641+ * UseNone : Neither document outline nor thumbnail images visible -- DEFAULT
642+ * UseOutlines : Document outline visible
643+ * UseThumbs : Thumbnail images visible
644+ * FullScreen : Full-screen mode, with no menu bar, window controls, or any other window visible
645+ */
646+ out ( '/PageMode /' + pageMode ) ;
647+ }
614648 events . publish ( 'putCatalog' ) ;
615649 } ,
616650 putTrailer = function ( ) {
@@ -642,8 +676,8 @@ var jsPDF = (function(global) {
642676 outToPages = true ;
643677 pages [ ++ page ] = [ ] ;
644678 pagedim [ page ] = {
645- width : ( pageWidth = Number ( width ) || pageWidth ) ,
646- height : ( pageHeight = Number ( height ) || pageHeight )
679+ width : Number ( width ) || pageWidth ,
680+ height : Number ( height ) || pageHeight
647681 } ;
648682 _setPage ( page ) ;
649683 } ,
@@ -927,6 +961,12 @@ var jsPDF = (function(global) {
927961 _setPage . apply ( this , arguments ) ;
928962 return this ;
929963 } ;
964+ API . setDisplayMode = function ( zoom , layout , pmode ) {
965+ zoomMode = zoom ;
966+ layoutMode = layout ;
967+ pageMode = pmode ;
968+ return this ;
969+ } ,
930970
931971 /**
932972 * Adds text to page. Supports adding multiline text when 'text' argument is an Array of Strings.
0 commit comments