Change PDFPrintServiceFactory.createPrintService to take a parameter object

By "modernizing" the method to use a parameter object instead, we avoid having to pass along the needed parameters individually.
This commit is contained in:
Jonas Jenwald 2024-02-13 21:28:02 +01:00
parent 14874e50b7
commit a204f434f3
3 changed files with 19 additions and 55 deletions

View file

@ -63,14 +63,14 @@ function renderPage(
}
class PDFPrintService {
constructor(
constructor({
pdfDocument,
pagesOverview,
printContainer,
printResolution,
optionalContentConfigPromise = null,
printAnnotationStoragePromise = null
) {
printAnnotationStoragePromise = null,
}) {
this.pdfDocument = pdfDocument;
this.pagesOverview = pagesOverview;
this.printContainer = printContainer;
@ -367,26 +367,11 @@ class PDFPrintServiceFactory {
return shadow(this, "supportsPrinting", true);
}
static createPrintService(
pdfDocument,
pagesOverview,
printContainer,
printResolution,
optionalContentConfigPromise,
printAnnotationStoragePromise
) {
static createPrintService(params) {
if (activeService) {
throw new Error("The print service is created and active.");
}
activeService = new PDFPrintService(
pdfDocument,
pagesOverview,
printContainer,
printResolution,
optionalContentConfigPromise,
printAnnotationStoragePromise
);
return activeService;
return (activeService = new PDFPrintService(params));
}
}