Skip to content

Commit 635ddf4

Browse files
committed
chore: Updated deps
1 parent fe9dbab commit 635ddf4

File tree

3 files changed

+9
-300
lines changed

3 files changed

+9
-300
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"test": "jest --passWithNoTests"
3838
},
3939
"dependencies": {
40-
"canvas": "^3.1.0",
40+
"@napi-rs/canvas": "^0.1.66",
4141
"node-addon-api": "^8.3.0",
4242
"node-gyp": "^11.0.0",
4343
"pdfjs-dist": "4.10.38"

src/pdf-to-png.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/**
22
* https://github.com/mozilla/pdf.js/blob/3b94e9fdce616a9b4899800559cbca15169acca6/examples/node/pdf2png/pdf2png.mjs
33
*/
4-
import * as Canvas from 'canvas'
54
import { readFileSync } from 'node:fs'
65
import { dirname, join } from 'node:path'
76
import { getDocument } from 'pdfjs-dist'
@@ -33,10 +32,11 @@ export async function pdfToPng(
3332
const pdfPage = await pdfDocument.getPage(page)
3433

3534
const viewport = pdfPage.getViewport({ scale: 1.0 })
36-
const canvasAndContext = Canvas.createCanvas(viewport.width, viewport.height)
35+
// @ts-expect-error unknown method on Object
36+
const canvasAndContext = pdfDocument.canvasFactory.create(viewport.width, viewport.height)
3737

3838
await pdfPage.render({
39-
canvasContext: canvasAndContext.getContext('2d') as never,
39+
canvasContext: canvasAndContext.context,
4040
viewport
4141
}).promise
4242

0 commit comments

Comments
 (0)