We have desktop java swing application which can print some content to a text printer lpt1
try {
FileWriter out = new FileWriter("lpt1");
out.write("Hello world");
out.write(0x0D); // CR
out.close();
}
Now we have a web version of the same program to run on google chrome which is written in javascript/html/react. Because of browser limitations (security) we can not implement same mechanism. HTML5 File api is not enough for a such task I think. (10 years before it would be probably possible using ActiveX controls)
How can we trigger printing a text document to text printer where the client machine has a printer and a chrome browser is running? I have some possibilites/alternatives, any suggestions are appreciated.
1- Build a native java jar file, which encapculates and wraps a webview (an html renderer), run the html based version in the webview and if native operations such as file needed, communicate with the wrapper jar file and implement file operations as before.
2- Run the web based app, and demand the clients that they run a native jar file at the same time and the jar file opens some sockets etc and listens for localhost. The web application communicates with post requests to the local jar file.
3- Write a chrome plugin or extension which can handle java native file operations? Is it possible? Where can I start?
Note: It is enough for us that the web page runs on chrome only, we can also force to latest chrome builds. Cross browser support or support to old browsers is NOT needed.