@@ -171,6 +171,7 @@ var html2pdf = (function(html2canvas, jsPDF) {
171
171
// Create a one-page canvas to split up the full image.
172
172
var pageCanvas = document . createElement ( 'canvas' ) ;
173
173
var pageCtx = pageCanvas . getContext ( '2d' ) ;
174
+ var pageHeight = pageSize . inner . height ;
174
175
pageCanvas . width = canvas . width ;
175
176
pageCanvas . height = pxPageHeight ;
176
177
@@ -179,7 +180,10 @@ var html2pdf = (function(html2canvas, jsPDF) {
179
180
180
181
for ( var page = 0 ; page < nPages ; page ++ ) {
181
182
// Trim the final page to reduce file size.
182
- if ( page === nPages - 1 ) pageCanvas . height = pxFullHeight % pxPageHeight ;
183
+ if ( page === nPages - 1 ) {
184
+ pageCanvas . height = pxFullHeight % pxPageHeight ;
185
+ pageHeight = pageCanvas . height * pageSize . inner . width / pageCanvas . width ;
186
+ }
183
187
184
188
// Display the page.
185
189
var w = pageCanvas . width ;
@@ -191,7 +195,8 @@ var html2pdf = (function(html2canvas, jsPDF) {
191
195
// Add the page to the PDF.
192
196
if ( page ) pdf . addPage ( ) ;
193
197
var imgData = pageCanvas . toDataURL ( 'image/' + opt . image . type , opt . image . quality ) ;
194
- pdf . addImage ( imgData , opt . image . type , opt . margin [ 1 ] , opt . margin [ 0 ] ) ;
198
+ pdf . addImage ( imgData , opt . image . type , opt . margin [ 1 ] , opt . margin [ 0 ] ,
199
+ pageSize . inner . width , pageHeight ) ;
195
200
196
201
// Add hyperlinks.
197
202
if ( opt . enableLinks ) {
0 commit comments