Skip to content

Commit

Permalink
fix: page 생성시기 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
jcy0308 committed Aug 30, 2024
1 parent fcd4a3c commit 67f225e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/puppeteer/puppeteer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ export class PuppeteerService implements OnModuleInit, OnModuleDestroy {
],
});
console.log('browser launched');
this.page = await this.browser.newPage();
console.log('puppeteer initiated');
}

async onModuleDestroy() {
Expand All @@ -36,7 +34,12 @@ export class PuppeteerService implements OnModuleInit, OnModuleDestroy {
preferCSSPageSize: false,
printBackground: true,
};
this.page = await this.browser.newPage();

await this.page.setContent(htmlContent);
return await this.page.pdf(options);
const pdf = await this.page.pdf(options);
await this.page.close();

return pdf;
}
}

0 comments on commit 67f225e

Please sign in to comment.