From 96e0a3aedeed4dfe7ed1120bdd9cd6c0f78d4d3c Mon Sep 17 00:00:00 2001 From: geoffreychen777 Date: Wed, 31 Aug 2022 23:59:51 +0100 Subject: [PATCH] + fix rendering bug --- packages/preload/interactors/render-interactor.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/preload/interactors/render-interactor.ts b/packages/preload/interactors/render-interactor.ts index 8f93bcf0..760e66ce 100644 --- a/packages/preload/interactors/render-interactor.ts +++ b/packages/preload/interactors/render-interactor.ts @@ -18,12 +18,14 @@ export class RenderInteractor { markdownIt: MarkdownIt; pdfWorker: Worker | null; renderingPage: PDFPageProxy | null; + renderingPDF: pdfjs.PDFDocumentProxy | null; constructor(preference: Preference) { this.preference = preference; this.pdfWorker = null; this.renderingPage = null; + this.renderingPDF = null; this.createPDFWorker(); this.markdownIt = new MarkdownIt().use(tm, { @@ -47,8 +49,12 @@ export class RenderInteractor { async render(fileURL: string) { this.createPDFWorker(); - // @ts-ignore + if (this.renderingPDF) { + this.renderingPDF.destroy(); + } const pdf = await pdfjs.getDocument(fileURL).promise; + this.renderingPDF = pdf; + const page = await pdf.getPage(1); this.renderingPage = page; var scale = 0.25;