unjs / unpdf

📄 Utilities to work with PDFs in Node.js, browser and workers
MIT License
438 stars 12 forks source link

Unpdf can't render pages with images #4

Closed DemoMacro closed 9 months ago

DemoMacro commented 9 months ago

Environment

Node.js v20.9.0 PNPM v8.10.0 UnPDF v0.10.0

Reproduction

Example Code: CodeSandBox

Describe the bug

When I am ready to render a page with unpdf, renderPageAsImage will report an error if there is an image embedded in the pdf.

Additional context

No response

Logs

TypeError: r.createCanvas is not a function
    at NodeCanvasFactory._createCanvas (file:///workspaces/workspace/node_modules/.pnpm/unpdf@0.10.0/node_modules/unpdf/dist/pdfjs.mjs:1:1316062)
    at NodeCanvasFactory.create (file:///workspaces/workspace/node_modules/.pnpm/unpdf@0.10.0/node_modules/unpdf/dist/pdfjs.mjs:1:1153693)
    at CachedCanvases.getCanvas (file:///workspaces/workspace/node_modules/.pnpm/unpdf@0.10.0/node_modules/unpdf/dist/pdfjs.mjs:1:1163909)
    at CanvasGraphics.paintInlineImageXObject (file:///workspaces/workspace/node_modules/.pnpm/unpdf@0.10.0/node_modules/unpdf/dist/pdfjs.mjs:1:1198408)
    at CanvasGraphics.paintImageXObject (file:///workspaces/workspace/node_modules/.pnpm/unpdf@0.10.0/node_modules/unpdf/dist/pdfjs.mjs:1:1197232)
    at CanvasGraphics.executeOperatorList (file:///workspaces/workspace/node_modules/.pnpm/unpdf@0.10.0/node_modules/unpdf/dist/pdfjs.mjs:1:1172983)
    at InternalRenderTask._next (file:///workspaces/workspace/node_modules/.pnpm/unpdf@0.10.0/node_modules/unpdf/dist/pdfjs.mjs:1:1152632)
johannschopplich commented 9 months ago

Thanks a lot for the reproduction. Merry Christmas, still! 🎄