@@ -162,12 +162,11 @@ var html2pdf = (function(html2canvas, jsPDF) {
162162 } ;
163163
164164 html2pdf . makePDF = function ( canvas , pageSize , opt ) {
165- // Calculate the number of pages and get the full canvas image .
165+ // Calculate the number of pages.
166166 var ctx = canvas . getContext ( '2d' ) ;
167167 var pxFullHeight = canvas . height ;
168168 var pxPageHeight = Math . floor ( canvas . width * pageSize . inner . ratio ) ;
169169 var nPages = Math . ceil ( pxFullHeight / pxPageHeight ) ;
170- var imgFull = ctx . getImageData ( 0 , 0 , canvas . width , canvas . height ) ;
171170
172171 // Create a one-page canvas to split up the full image.
173172 var pageCanvas = document . createElement ( 'canvas' ) ;
@@ -182,10 +181,12 @@ var html2pdf = (function(html2canvas, jsPDF) {
182181 // Trim the final page to reduce file size.
183182 if ( page === nPages - 1 ) pageCanvas . height = pxFullHeight % pxPageHeight ;
184183
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 ) ;
189190
190191 // Add the page to the PDF.
191192 if ( page ) pdf . addPage ( ) ;
0 commit comments