Broken node support? (CanvasPattern.setTransform)
See original GitHub issueAttach (recommended) or Link to PDF file here https://github.com/mozilla/pdf.js/blob/8ab65ed32d0f99a5fd5bf6ce302acb25082910c0/test/pdfs/issue7847_radial.pdf
Configuration:
- Web browser and its version: NodeJS v14.17.1, node-canvas v2.8.0
- Operating system and its version: Windows v10.0.18363
- PDF.js version: 0afc785c7d0de39ab79f6bb60d8f60daa3f8477b
- Is a browser extension: no
Steps to reproduce the problem:
$ npm install
$ gulp dist-install
$ npm install canvas
$ cd examples/node/pdf2png
$ node pdf2png.js ../../../test/pdfs/issue7847_radial.pdf
What is the expected behavior? (add screenshot)
As of ac44afa70e06d103633727a3249cf049c00d3fd0, pattern_helper.js
makes use of CanvasPattern.setTransform(...)
, which has unfortunately not been implemented yet in the node canvas (https://github.com/Automattic/node-canvas/issues/1411). Previously I’ve been able to use the pattern helper from within Node contexts.
What went wrong? (add screenshot)
# PDF document loaded.
(node:1608) UnhandledPromiseRejectionWarning: TypeError: pattern.setTransform is not a function
at RadialAxialShadingPattern.getPattern (/tmp/pdf.js/build/dist/legacy/build/pdf.js:15919:15)
at CanvasGraphics.fill (/tmp/pdf.js/build/dist/legacy/build/pdf.js:14612:37)
at CanvasGraphics.executeOperatorList (/tmp/pdf.js/build/dist/legacy/build/pdf.js:14116:24)
at InternalRenderTask._callee4$ (/tmp/pdf.js/build/dist/legacy/build/pdf.js:12335:51)
at tryCatch (/tmp/pdf.js/build/dist/legacy/build/pdf.js:832:17)
at Generator.invoke [as _invoke] (/tmp/pdf.js/build/dist/legacy/build/pdf.js:1005:22)
at Generator.next (/tmp/pdf.js/build/dist/legacy/build/pdf.js:875:21)
at asyncGeneratorStep (/tmp/pdf.js/build/dist/legacy/build/pdf.js:9508:103)
at _next (/tmp/pdf.js/build/dist/legacy/build/pdf.js:9510:194)
at /tmp/pdf.js/build/dist/legacy/build/pdf.js:9510:364
(Use `node --trace-warnings ...` to show where the warning was created)
(node:1608) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:1608) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
CanvasPattern.setTransform() - Web APIs | MDN
This is just a simple code snippet which uses the setTransform method to create a CanvasPattern with the specified pattern transformation ...
Read more >canvas | Yarn - Package Manager
Breaking. Drop support for Node.js <6.x; Remove sync stream functions (bc53059). Note that most streams are still synchronous (run in the main thread);...
Read more >Canvas Element - HTML Standard - whatwg
Returns an object that exposes an API for drawing on the canvas. contextId specifies the desired API: " 2d ", " bitmaprenderer ",...
Read more >HTML Canvas 2D Context - W3C
Abstract. This specification defines the 2D Context for the HTML canvas element. The 2D Context provides objects, methods, and properties to ...
Read more >https://raw.githubusercontent.com/Automattic/node-...
CanvasPattern's `setTransform` method is no longer missing ### Fixed * Fix BMP ... new ``` ### Breaking * Drop support for Node.js <6.x...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I can confirm that running with a local build of Automattic/node-canvas#1623 resolves this.
Closing this issue, since there’s not much more we can do here now, given that:
node-canvas
PR, see https://github.com/Automattic/node-canvas/pull/1623, was just merged; hence this should thus be completely fixed with a future release of that package.