Skip to content

Commit 6702db0

Browse files
authored
Merge pull request #9 from Doczilla-APP/improvements
Refactor PDF.js import to use dynamic import.
2 parents 75a8d86 + e31eac7 commit 6702db0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/pdf-to-png.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
*/
44
import { readFileSync } from 'node:fs'
55
import { dirname, join } from 'node:path'
6-
import { getDocument } from 'pdfjs-dist/legacy/build/pdf.mjs'
76

87
const PDFJS_DIR = join(dirname(require.resolve('pdfjs-dist')), '..')
98

109
export async function pdfToPng(
1110
pdf: string | Buffer
1211
): Promise<Buffer[]> {
12+
const { getDocument } = await import('pdfjs-dist/legacy/build/pdf.mjs')
1313

1414
// Load PDF
1515
const data = new Uint8Array(Buffer.isBuffer(pdf) ? pdf : readFileSync(pdf))

0 commit comments

Comments
 (0)