@@ -162,12 +162,11 @@ var html2pdf = (function(html2canvas, jsPDF) {
162
162
} ;
163
163
164
164
html2pdf . makePDF = function ( canvas , pageSize , opt ) {
165
- // Calculate the number of pages and get the full canvas image .
165
+ // Calculate the number of pages.
166
166
var ctx = canvas . getContext ( '2d' ) ;
167
167
var pxFullHeight = canvas . height ;
168
168
var pxPageHeight = Math . floor ( canvas . width * pageSize . inner . ratio ) ;
169
169
var nPages = Math . ceil ( pxFullHeight / pxPageHeight ) ;
170
- var imgFull = ctx . getImageData ( 0 , 0 , canvas . width , canvas . height ) ;
171
170
172
171
// Create a one-page canvas to split up the full image.
173
172
var pageCanvas = document . createElement ( 'canvas' ) ;
@@ -182,10 +181,12 @@ var html2pdf = (function(html2canvas, jsPDF) {
182
181
// Trim the final page to reduce file size.
183
182
if ( page === nPages - 1 ) pageCanvas . height = pxFullHeight % pxPageHeight ;
184
183
185
- // Display the page (fill with white a bit past the render edge just in case).
186
- pageCtx . fillStyle = '#FFFFFF' ;
187
- pageCtx . fillRect ( - 10 , - 10 , pageCanvas . width + 20 , pageCanvas . height + 20 ) ;
188
- pageCtx . putImageData ( imgFull , 0 , - page * pxPageHeight ) ;
184
+ // Display the page.
185
+ var w = pageCanvas . width ;
186
+ var h = pageCanvas . height ;
187
+ pageCtx . fillStyle = 'white' ;
188
+ pageCtx . fillRect ( 0 , 0 , w , h ) ;
189
+ pageCtx . drawImage ( canvas , 0 , page * pxPageHeight , w , h , 0 , 0 , w , h ) ;
189
190
190
191
// Add the page to the PDF.
191
192
if ( page ) pdf . addPage ( ) ;
0 commit comments