fix(core): update
This commit is contained in:
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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 };
|
||||
|
Reference in New Issue
Block a user