Compare commits

..

4 Commits

Author SHA1 Message Date
18c8ef9606 1.0.26 2019-11-12 15:45:26 +01:00
6766a3d0dc fix(core): update 2019-11-12 15:45:26 +01:00
d16f447048 1.0.25 2019-11-12 15:41:58 +01:00
37c752c2ae fix(core): update 2019-11-12 15:41:58 +01:00
3 changed files with 15 additions and 3 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartpdf", "name": "@pushrocks/smartpdf",
"version": "1.0.24", "version": "1.0.26",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartpdf", "name": "@pushrocks/smartpdf",
"version": "1.0.24", "version": "1.0.26",
"private": false, "private": false,
"description": "create pdfs on the fly", "description": "create pdfs on the fly",
"main": "dist/index.js", "main": "dist/index.js",

View File

@ -78,7 +78,10 @@ export class SmartPdf {
} }
const pdfBuffer = await page.pdf({ const pdfBuffer = await page.pdf({
format: 'A4' format: 'A4',
printBackground: true,
displayHeaderFooter: false,
preferCSSPageSize: true
}); });
await page.close(); await page.close();
delete this._candidates[pdfCandidate.pdfId]; delete this._candidates[pdfCandidate.pdfId];
@ -96,8 +99,16 @@ export class SmartPdf {
page.emulateMedia('screen'); page.emulateMedia('screen');
const response = await page.goto(websiteUrl, { waitUntil: 'networkidle2' }); const response = await page.goto(websiteUrl, { waitUntil: 'networkidle2' });
const pdfId = plugins.smartunique.shortId(); const pdfId = plugins.smartunique.shortId();
const { documentHeight, documentWidth } = await page.evaluate(() => {
return {
documentHeight: document.height,
documentWidth: document.width
};
});
const pdfBuffer = await page.pdf({ const pdfBuffer = await page.pdf({
format: 'A4', format: 'A4',
height: documentWidth,
width: documentWidth,
printBackground: true, printBackground: true,
displayHeaderFooter: false, displayHeaderFooter: false,
preferCSSPageSize: true preferCSSPageSize: true
@ -122,6 +133,7 @@ export class SmartPdf {
}; };
}); });
const pdfBuffer = await page.pdf({ const pdfBuffer = await page.pdf({
format: 'A4',
height: documentWidth, height: documentWidth,
width: documentWidth, width: documentWidth,
printBackground: true, printBackground: true,