Skip to content

Commit 03931a3

Browse files
committed
Increase height
1 parent e21a949 commit 03931a3

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

src/commands/GeneratePDF.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,31 @@ import Command from "./Command";
33

44
let document: any;
55

6-
function updatePageSize() {
7-
const maxHeight = Array.from<any>(document.all).reduce((a, c) => Math.max(c.scrollHeight , a) , 0);
8-
document.body.style.height = `${maxHeight}px`;
9-
document.body.style.overflow = "auto";
6+
function getMaxPageSize() {
7+
return Array.from<any>(document.all).reduce((a, c) => Math.max(c.scrollHeight , a) , 0);
108
}
119

1210
export default class GeneratePDF extends Command {
1311
async render({ outputFile: path, page, output, pdf }: IEvent) {
1412

15-
await page.evaluate(updatePageSize);
13+
const height = await page.evaluate(getMaxPageSize);
14+
15+
const {
16+
width,
17+
isMobile,
18+
deviceScaleFactor,
19+
hasTouch,
20+
isLandscape
21+
} = page.viewport();
22+
23+
page.setViewport({
24+
width,
25+
height,
26+
isMobile,
27+
deviceScaleFactor,
28+
hasTouch,
29+
isLandscape
30+
})
1631

1732
const pf = typeof pdf === "object"
1833
? { ... pdf, path}

0 commit comments

Comments
 (0)