1

I try to print a pdf with --kiosk-printing enabled in chrome. The pdf is local available.

Here is my test-code:

<button onClick="printJS('assets/pdf-sample.pdf')">
    Print
</button>

When i run the print, Chrome is showing the message

Print Failed

Something went wrong when trying to print. Please check your printer and try again.

I use the newest version of Chrome: 91.0.4472.164 (Offizieller Build) (64-Bit)

Does anyone know what could be the problem here and how I could solve it?

BennoDual
  • 5,865
  • 15
  • 67
  • 153
  • 1
    This is happening for kiosk mode only, please post the solution if you come across any, I am also facing the same issue. – Shreyansh Jul 17 '21 at 07:04

1 Answers1

3

This worked for me,

I applied a patch, in the print-js module.

For applying the patch,

In node_modules/print-js/dist/print.js line number 259, replace the line

iframe.remove()

to

setTimeout(()=>{iframe.remove()},10000); // you can change the delay.

Now, to apply the patch,

 npx patch-package print-js

Also, add the following in the script section of your package.json to automatically patch the dependency when you execute "npm install".

"postinstall": "npx patch-package" 

Ref: https://stackoverflow.com/a/62567504/7092628

Shreyansh
  • 458
  • 4
  • 11