fix(core): update

This commit is contained in:
2019-05-29 00:27:43 +02:00
parent 20847362a1
commit e981d61a54
10 changed files with 578 additions and 343 deletions

View File

@ -3,6 +3,8 @@ import * as paths from './smartpdf.paths';
import { Server } from 'http';
import { PdfCandidate } from './smartpdf.classes.pdfcandidate';
declare const document;
export class SmartPdf {
htmlServerInstance: Server;
serverPort: number;
@ -85,4 +87,26 @@ export class SmartPdf {
});
await page.close();
}
async getFullWebsiteAsSinglePdf(websiteUrl: string) {
const page = await this.headlessBrowser.newPage();
const response = await page.goto(websiteUrl, { waitUntil: 'networkidle2' });
const pdfId = plugins.smartunique.shortId();
const {documentHeight, documentWidth} = await page.evaluate(() => {
return {
documentHeight: document.height,
documentWidth: document.width
};
});
await page.pdf({
path: plugins.path.join(paths.pdfDir, `${pdfId}.pdf`),
height: documentWidth,
width: documentWidth,
printBackground: true,
displayHeaderFooter: false,
preferCSSPageSize: true
});
await page.close();
}
}

View File

@ -13,7 +13,7 @@ import * as smartunique from '@pushrocks/smartunique';
export { smartfile, smartpromise, smartunique, smartnetwork };
// thirdparty
import * as express from 'express';
import * as puppeteer from 'puppeteer';
import express from 'express';
import puppeteer from 'puppeteer';
export { express, puppeteer };