Skip to content

Commit 5f916b9

Browse files
committed
Added custom height
1 parent c49e1f1 commit 5f916b9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/commands/GeneratePDF.ts

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

44
let document: any;
55

6-
function getMaxHeight() {
7-
return Array.from<any>(document.all).reduce((a, c) => Math.max(c.scrollHeight , a) , 0);
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";
810
}
911

1012
export default class GeneratePDF extends Command {
1113
async render({ outputFile: path, page, output, pdf }: IEvent) {
1214

13-
// find div with maximum scroll height
14-
const maxHeight = await page.evaluate(getMaxHeight);
15+
await page.evaluate(updatePageSize);
1516

1617
const pf = typeof pdf === "object"
1718
? { ... pdf, path}
1819
: { path };
1920

2021
pf.format ??= "A4";
21-
pf.height = maxHeight + "px";
2222

2323
await page.pdf(pf);
2424

0 commit comments

Comments
 (0)