Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular printjs: ERROR TypeError: Object(...) is not a function

I'm trying to use printJS in Angular and print an image (PNG). I did the import:

    import { printJS } from "print-js/dist/print.min.js";

Then I execute this printing code in function, according to the documentation:

    printJS('no-image.png', 'image');

I got following error: enter image description here

I can't find solution to fix this.

like image 436
XardasLord Avatar asked Mar 21 '26 16:03

XardasLord


1 Answers

I think you need to use default import for this library:

import printJS from "print-js";

Also, for NPM packages you should never import directly from js path. Usually you would just import from package itself, in your case print-js.

like image 182
dfsq Avatar answered Mar 23 '26 05:03

dfsq