From 67f225edc1ddf6f1912ad4df83c3283034f96ace Mon Sep 17 00:00:00 2001 From: chanyeong Date: Fri, 30 Aug 2024 10:43:37 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20page=20=EC=83=9D=EC=84=B1=EC=8B=9C?= =?UTF-8?q?=EA=B8=B0=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/puppeteer/puppeteer.service.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/puppeteer/puppeteer.service.ts b/src/puppeteer/puppeteer.service.ts index 257720e..9e04dcc 100644 --- a/src/puppeteer/puppeteer.service.ts +++ b/src/puppeteer/puppeteer.service.ts @@ -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() { @@ -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; } }