@@ -22,12 +22,17 @@ let overlayManager = null;
22
22
23
23
// Renders the page to the canvas of the given print service, and returns
24
24
// the suggested dimensions of the output page.
25
- function renderPage ( activeServiceOnEntry , pdfDocument , pageNumber , size ) {
25
+ function renderPage (
26
+ activeServiceOnEntry ,
27
+ pdfDocument ,
28
+ pageNumber ,
29
+ size ,
30
+ printResolution
31
+ ) {
26
32
const scratchCanvas = activeService . scratchCanvas ;
27
33
28
34
// The size of the canvas in pixels for printing.
29
- const PRINT_RESOLUTION = AppOptions . get ( "printResolution" ) || 150 ;
30
- const PRINT_UNITS = PRINT_RESOLUTION / 72.0 ;
35
+ const PRINT_UNITS = printResolution / 72.0 ;
31
36
scratchCanvas . width = Math . floor ( size . width * PRINT_UNITS ) ;
32
37
scratchCanvas . height = Math . floor ( size . height * PRINT_UNITS ) ;
33
38
@@ -61,10 +66,17 @@ function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size) {
61
66
} ) ;
62
67
}
63
68
64
- function PDFPrintService ( pdfDocument , pagesOverview , printContainer , l10n ) {
69
+ function PDFPrintService (
70
+ pdfDocument ,
71
+ pagesOverview ,
72
+ printContainer ,
73
+ printResolution ,
74
+ l10n
75
+ ) {
65
76
this . pdfDocument = pdfDocument ;
66
77
this . pagesOverview = pagesOverview ;
67
78
this . printContainer = printContainer ;
79
+ this . _printResolution = printResolution || 150 ;
68
80
this . l10n = l10n || NullL10n ;
69
81
this . disableCreateObjectURL = AppOptions . get ( "disableCreateObjectURL" ) ;
70
82
this . currentPage = - 1 ;
@@ -154,7 +166,13 @@ PDFPrintService.prototype = {
154
166
}
155
167
const index = this . currentPage ;
156
168
renderProgress ( index , pageCount , this . l10n ) ;
157
- renderPage ( this , this . pdfDocument , index + 1 , this . pagesOverview [ index ] )
169
+ renderPage (
170
+ this ,
171
+ this . pdfDocument ,
172
+ /* pageNumber = */ index + 1 ,
173
+ this . pagesOverview [ index ] ,
174
+ this . _printResolution
175
+ )
158
176
. then ( this . useRenderedPage . bind ( this ) )
159
177
. then ( function ( ) {
160
178
renderNextPage ( resolve , reject ) ;
@@ -347,14 +365,21 @@ function ensureOverlay() {
347
365
PDFPrintServiceFactory . instance = {
348
366
supportsPrinting : true ,
349
367
350
- createPrintService ( pdfDocument , pagesOverview , printContainer , l10n ) {
368
+ createPrintService (
369
+ pdfDocument ,
370
+ pagesOverview ,
371
+ printContainer ,
372
+ printResolution ,
373
+ l10n
374
+ ) {
351
375
if ( activeService ) {
352
376
throw new Error ( "The print service is created and active." ) ;
353
377
}
354
378
activeService = new PDFPrintService (
355
379
pdfDocument ,
356
380
pagesOverview ,
357
381
printContainer ,
382
+ printResolution ,
358
383
l10n
359
384
) ;
360
385
return activeService ;
0 commit comments