[Research] Browser Direct/Slient Print and Local Hardware Access Possible Solutions (2016)

Web App is the big trend since SaaS grow these years.
But local hardware access for browsers is always major headache compared to traditional apps.
Especially direct print, a essential function for any traditional app is always missing piece of Web App.
COM port access is another missing feature, you need it to open drawer from POS, get readings from a digital scale… etc

I have researched and found four major possible directions

  • Tweak browser to support it
  • Enhance existing browser to support it
  • Build a browser that support it
  • Use/Create external service that handle it

A. Tweak browser to support it

A1. Outdated methods

Use <object>, <embed>, VB Script, this.print(true) that have very bad to non-existing compatibility

Feasibility: NO, @2016
Functionality: Direct print to default printer
Simplicity: Extremely easy

A2. Chrome Kiosk Print

Require to close Chrome completely and launch it again with  --kiosk-printing

http://www.shoptill-e.com/support/48

Feasibility: Yes
Functionality: Direct print to default printer
Simplicity: Easy

A3. Firefox “Always print slient

about:config and enable print.always_print_silent

https://support.mozilla.org/en-US/questions/1021071

Feasibility: Yes
Functionality: Direct print to default printer
Simplicity: Easy

B. Enhance existing browser to support it

B1. NSAPI / ActiveX
NSAPI have had its day… but now all major browser are removing support of it.
So for new project, there are no reason to use it again
ActiveX is Internet Explorer only and have bad reputation nowaways

Feasibility: Almost No, @2016
Functionality: Full access to system resources
Simplicity: Hard

B2. Other Web Plugins (Java Applet / Flash / Silverlight…etc)

Java Applet and Flash are fading out too…
Sliverlight have poor support for non-Windows OS

Feasibility: Maybe? @2016
Functionality: Full access to system resources
Simplicity: Medium to Hard

B3. Firefox + Extension

Enhance Firefox to print directly.

There are extension that suppress print dialog to just by toggling print.always_print_silent config by white-listing

https://addons.mozilla.org/en-US/firefox/addon/seamless-print/

XUL seems capable for more power.
But Firefox is removing XUL extension support soon so I gave up.

Feasibility: Yes
Functionality: Direct print to default printer
Simplicity: Very Easy

4. Chrome + Extension

Enhance Chrome to print directly.
Unfortunately Chrome Platform API do not provide enough privilege to print directly.
There are a Native Messaging API that allow to invoke local process (i.e. .exe)
So it’s possible but rather complicated.

Feasibility: Yes
Functionality: Full access to system resources
Simplicity: Very Hard

C. Build a browser that support it

C1. JavaFX + WebView

Create a enhanced browser that have access to local resources
WebView in JavaFX support modern HTML5 web features well.
It’s possible to create JS-to-Java bridge that allow JavaScript to share Java’s privilege

I have made test implementation on this approach.
But found that WebView itself lack of many common functionality that user may complain.
Example: HTTP digest authentication, File download, back/next mouse button

Feasibility: Yes
Functionality: Full access to system resources
Simplicity: Hard to Very Hard

C2. .NET + WebView

Similar to JavaFX but for .NET.
I am not a fan of Microsoft stuff haven’t dig into it.

Feasibility: Yes
Functionality: Full access to system resources
Simplicity: Hard to Very Hard

D. Use/Create external service that handle it

D1. Any Browser + Google Cloud Print

Install Google Cloud Print on local machine.
Then the Web App use JavaScript to submit print job to Google Cloud Print

http://stackoverflow.com/questions/31888183/chrome-extensions-for-silent-print

Feasibility: Yes
Functionality: Able to select printers
Simplicity: Easy

D2. Any Browser + Custom Local Service

Use any language able to access local resources,  create a Service/Daemon listening on local port as REST API.
Then the Web App call the API using Cross-Origin AJAX / JSONP

http://stackoverflow.com/questions/15171522/how-can-a-web-page-read-from-the-users-serial-port#answer-15226241

Feasibility: Yes
Functionality: Full access to system resources
Simplicity: Hard to Very Hard

E. Other tweaks

E1. Acrobat Reader with JavaScript

http://londonwebdev.com/2010/09/14/silent-pdf-printing-from-a-php-based-web-application/

Feasibility: Unknown (Not tested)
Functionality: Able to select printers
Simplicity: Medium

E2. Execute print command / Write print job directly to local printer

http://stackoverflow.com/questions/13415948/how-to-silent-print-with-fpdf-and-php

Feasibility: Only if server and client on same place
Functionality: Able to select printers
Simplicity: Easy

Any other ideas? Please comment 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.