Skip to content

Commit

Permalink
Increase height
Browse files Browse the repository at this point in the history
  • Loading branch information
ackava committed Jul 18, 2023
1 parent e21a949 commit 03931a3
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/commands/GeneratePDF.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,31 @@ import Command from "./Command";

let document: any;

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

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

await page.evaluate(updatePageSize);
const height = await page.evaluate(getMaxPageSize);

const {
width,
isMobile,
deviceScaleFactor,
hasTouch,
isLandscape
} = page.viewport();

page.setViewport({
width,
height,
isMobile,
deviceScaleFactor,
hasTouch,
isLandscape
})

const pf = typeof pdf === "object"
? { ... pdf, path}
Expand Down

0 comments on commit 03931a3

Please sign in to comment.