@@ -177,6 +177,7 @@ var jsPDF = (function(global) {
177
177
k , // Scale factor
178
178
tmp ,
179
179
page = 0 ,
180
+ currentPage ,
180
181
pages = [ ] ,
181
182
pagedim = { } ,
182
183
content = [ ] ,
@@ -210,7 +211,7 @@ var jsPDF = (function(global) {
210
211
out = function ( string ) {
211
212
if ( outToPages ) {
212
213
/* set by beginPage */
213
- pages [ page ] . push ( string ) ;
214
+ pages [ currentPage ] . push ( string ) ;
214
215
} else {
215
216
// +1 for '\n' that will be used to join 'content'
216
217
content_length += string . length + 1 ;
@@ -644,6 +645,7 @@ var jsPDF = (function(global) {
644
645
width : ( pageWidth = Number ( width ) || pageWidth ) ,
645
646
height : ( pageHeight = Number ( height ) || pageHeight )
646
647
} ;
648
+ _setPage ( page ) ;
647
649
} ,
648
650
_addPage = function ( ) {
649
651
beginPage . apply ( this , arguments ) ;
@@ -660,6 +662,13 @@ var jsPDF = (function(global) {
660
662
}
661
663
events . publish ( 'addPage' , { pageNumber : page } ) ;
662
664
} ,
665
+ _setPage = function ( n ) {
666
+ if ( n > 0 && n <= page ) {
667
+ currentPage = n ;
668
+ pageWidth = pagedim [ n ] . width ;
669
+ pageHeight = pagedim [ n ] . height ;
670
+ }
671
+ } ,
663
672
/**
664
673
* Returns a document-specific font key - a label assigned to a
665
674
* font name + font type combination at the time the font was added
@@ -914,6 +923,10 @@ var jsPDF = (function(global) {
914
923
_addPage . apply ( this , arguments ) ;
915
924
return this ;
916
925
} ;
926
+ API . setPage = function ( ) {
927
+ _setPage . apply ( this , arguments ) ;
928
+ return this ;
929
+ } ;
917
930
918
931
/**
919
932
* Adds text to page. Supports adding multiline text when 'text' argument is an Array of Strings.
0 commit comments