fix(core): update

This commit is contained in:
2021-10-14 10:59:45 +02:00
parent 56fa53b701
commit 8a308fa9e3
6 changed files with 18022 additions and 2453 deletions

View File

@@ -3,7 +3,7 @@ import * as paths from './smartpdf.paths';
import { Server } from 'http';
import { PdfCandidate } from './smartpdf.classes.pdfcandidate';
declare const document;
declare const document: any;
import * as interfaces from './interfaces';
@@ -19,7 +19,7 @@ export class SmartPdf {
this._readyDeferred = new plugins.smartpromise.Deferred();
}
async start(headlessBrowserArg?) {
async start(headlessBrowserArg?: plugins.smartpuppeteer.puppeteer.Browser) {
// lets set the external browser in case one is provided
this.headlessBrowser = headlessBrowserArg;
// setup puppeteer
@@ -80,7 +80,7 @@ export class SmartPdf {
}
const pdfBuffer = await page.pdf({
format: 'A4',
format: 'a4',
printBackground: true,
displayHeaderFooter: false,
preferCSSPageSize: true,
@@ -108,7 +108,7 @@ export class SmartPdf {
};
});
const pdfBuffer = await page.pdf({
format: 'A4',
format: 'a4',
height: documentWidth,
width: documentWidth,
printBackground: true,
@@ -135,7 +135,7 @@ export class SmartPdf {
};
});
const pdfBuffer = await page.pdf({
format: 'A4',
format: 'a4',
height: documentWidth,
width: documentWidth,
printBackground: true,
@@ -149,4 +149,12 @@ export class SmartPdf {
buffer: pdfBuffer,
};
}
public async mergePdfBuffers(pdfBuffers: Buffer[]): Promise<Buffer> {
const merger = new plugins.pdfMerger();
for (const buffer of pdfBuffers) {
merger.add(buffer);
}
return merger.saveAsBuffer();
}
}