“Chrome Direct Print” is abandoned in favor of “WebApp Hardware Bridge“
Which support all modern browsers (Chrome, Firefox, Edge),
with better compatibility, performance and serial port support.
Example Usage to call “Chrome Direct Print”
If the extension is not installed, it will fallback to view the PDF.
<!DOCTYPE html> <html> <head> <title>Printing...</title> <link rel="chrome-webstore-item" href="https://chrome.google.com/webstore/detail/fnfkcaeloalplnglklappfjfjeafakeo"> </head> <body> <h1>Printing...</h1> <script> var url = 'https://tcpdf.org/files/examples/example_001.pdf'; var type = 'RECEIPT'; function directPrint() { var evt = document.createEvent('CustomEvent'); evt.initCustomEvent('chromeHardwareEvent', true, false, {action: 'print', type: type, 'url': url}); document.dispatchEvent(evt); window.close(); } function downloadPDF() { document.location.href = url; } function start() { var testImage = document.createElement("img"); testImage.setAttribute("onload", 'directPrint()'); testImage.setAttribute("onerror", 'downloadPDF()'); testImage.setAttribute("src", "chrome-extension://fnfkcaeloalplnglklappfjfjeafakeo/icon-128.png"); document.body.appendChild(testImage); } setTimeout(start, 100); </script> </body> </html>
Getting Error
“Chrome Direct Print
Failed to connect to host:Error when communicating with the native messaging host
Have you installed host?”
I have installed host….
Don’t working page.
no working, it shows the image but no printing
Not working