How to achieve web printing in Andriod POS terminal?

 

Web printing is to display and print the content required by the end customer through the browser on the smart POS machine. Note that this browser needs to support portable POS printing, and when the client prints, the smart POS machine with printing function calls the correct printing interface to realize complete web page printing.

Why do customers in the market need to print web pages? At present, many applications exist in the form of web pages, also known as Web-app. Compared with native apps, this web-app can be compatible with more systems. The version update simply reduces the cost of research and development and maintenance, but relies on the network a little.

Difficulties with website printing

What is the difficulties with website printing on earth?Because it needs the cooperation of the manufacturer, during the development or testing of Web-app, even the manufacturer provide the SDK interface, and the customer cannot use it. Because the programming language of Web-app is different from Java, the common development language of Android POS devices, the customer needs the manufacturer’s help to operate the Android native code in the HTML through JS bridge to realize the printing of the interface.The specific operation method is as follows:

  1. The vendor creates an APK for web page printing and pre-defines the interaction interface (API) for the call within the APK

  2. The developer inserts a section of JS into the HTML, invokes the predefined API interface as needed, and then transfers the printed content and parameters by passing the JsonArray or String format.

  3. Customer provides URL, Datamega will encapsulate a new APK to load this URL, or APK provides input URL input box to visit the website.

At present, what are the feasible schemes for web page printing ?

  1. Save the web page as an image and call the interface to print the image directly.The biggest advantage of this way of printing is that you can print quickly through a command, while the disadvantage of printing is that once the size of the picture and the printer do not match, the printed content is easy to distort and blur.

  2. First convert the content of the web page to a PDF file, download the PDF file, and then convert it to an image for printing.This method of printing has the same advantages and disadvantages as picture printing.

  3. The content that needs to be printed is sent directly to the printer via JSON, and different interfaces are invoked for printing according to different content types.The advantage of this printing method is that the printed content will be automatically adjusted according to the size of the printed paper, there will be no distortion.The downside is that this printing method also requires developers to be able to develop in the JAVA language at a slower pace.

All DataMega products can use the above three methods, supporting pictures, text, PDF, bar code, QR code and other printing formats.

We will show you how to achieve the web printing by a sample DEMO as below:

<head> <meta charset="utf-8"> <title>XXXXXXtitle> <script> //JsonArray format print content
                var value = "
                [{
                data:'ABCdef123+-*/@#$%^&()_=', //character stering
                type:3, //type=3,printing QR code
                align:0, //print position,default 0:center,1:left,2:right
                size: 200, //size=200,the size of printing QR barcode is 200
                wrapPaper:1 //the paper will roll 1 lines after printing finished
                }]" 
             function printData(){
              DM.print(value);
             } script> head> <body> <button style="width:100%;height:100px" type="button" id="button1" onclick="printData()">Click and call Android print databutton> body> html>

Currently all products of Datamega support webprinting, you can find smart android POS device which support webprinting on www.datamega.net.

评论

此博客中的热门博文

What is the working principle of induction cooker?

Coronavirus Statement - Amikon Ltd

The Basic Function and Introduction of Portable Thermal Printer RPP02N