How to Print Unsupported Character Sets with a POS Printer: Difference between revisions

From wizarPOS
(Created page with "There are two ways to print html content, if your app is using our C SDK, please use the java method in JNI API, and if using our Java SDK, please use the Java method. Please...")
 
No edit summary
Line 1: Line 1:
There are two ways to print html content, if your app is using our C SDK, please use the java method in JNI API, and if using our Java SDK, please use the Java method.
There are two ways to print html content, if your app is using our C SDK, please use the java method in JNI API, and if using our Java SDK, please use the Java method.
Please add WebView.enableSlowWholeDocumentDraw() in your APP source code, because we use android webview to print html content.
Please add WebView.enableSlowWholeDocumentDraw() in your APP source code, because we use android webview to print html content.
== by JNI API ==
== Permission ==
== Permission ==
  android.permission.SYSTEM_ALERT_WINDOW
android.permission.SYSTEM_ALERT_WINDOW
The app declares the permission in the manifest.  
The app declares the permission in the manifest.  


== API Overview ==
== by JNI API ==
=== <big>PrintHtmlInterface.printHTML</big>===
=== API Overview ===
==== <big>PrintHtmlInterface.printHTML</big>====
   <syntaxhighlight lang="java">void printHTML(Context context, String htmlcontent, PrinterHtmlListener listener);</syntaxhighlight>
   <syntaxhighlight lang="java">void printHTML(Context context, String htmlcontent, PrinterHtmlListener listener);</syntaxhighlight>
Print HTML content.
Print HTML content.
Line 22: Line 22:
|}
|}


=== <big>PrintHtmlInterface.convert2Image</big>===
==== <big>PrintHtmlInterface.convert2Image</big>====
   <syntaxhighlight lang="java">void convert2Image(Context context, String htmlContent, PrinterHtmlListener listener);</syntaxhighlight>
   <syntaxhighlight lang="java">void convert2Image(Context context, String htmlContent, PrinterHtmlListener listener);</syntaxhighlight>
Convert the html content to a image, if want print, please call print api of the printer.
Convert the html content to a image, if want print, please call print api of the printer.
Line 37: Line 37:
|}
|}


=== <big>PrinterHtmlListener.onGet</big>===
==== <big>PrinterHtmlListener.onGet</big>====
   <syntaxhighlight lang="java">void onGet(Bitmap returbitmap, int result);</syntaxhighlight>
   <syntaxhighlight lang="java">void onGet(Bitmap returbitmap, int result);</syntaxhighlight>
Get returned bitmap.
Get returned bitmap.
Line 50: Line 50:
|}
|}


=== <big>PrinterHtmlListener.onFinishPrinting</big>===
==== <big>PrinterHtmlListener.onFinishPrinting</big>====
   <syntaxhighlight lang="java">void onFinishPrinting(int result);</syntaxhighlight>
   <syntaxhighlight lang="java">void onFinishPrinting(int result);</syntaxhighlight>
Return after print.
Return after print.

Revision as of 03:12, 7 November 2018

There are two ways to print html content, if your app is using our C SDK, please use the java method in JNI API, and if using our Java SDK, please use the Java method. Please add WebView.enableSlowWholeDocumentDraw() in your APP source code, because we use android webview to print html content.

Permission

android.permission.SYSTEM_ALERT_WINDOW The app declares the permission in the manifest.

by JNI API

API Overview

PrintHtmlInterface.printHTML

void printHTML(Context context, String htmlcontent, PrinterHtmlListener listener);

Print HTML content.

Returns
context Context : The activity or application context of the APP, Not null.
htmlcontent String : The html content, Not null.
listener PrinterHtmlListener : the callback listener to process the print result, Not null.

PrintHtmlInterface.convert2Image

void convert2Image(Context context, String htmlContent, PrinterHtmlListener listener);

Convert the html content to a image, if want print, please call print api of the printer.

Returns
context Context : The activity or application context of the APP, Not null.
htmlcontent String : The html content, Not null.
listener PrinterHtmlListener : the callback listener to process the print result, Not null.

PrinterHtmlListener.onGet

void onGet(Bitmap returbitmap, int result);

Get returned bitmap.

Returns
returbitmap Bitmap : The returned bitmap.
result int: The result of get image, "2:" BITMAP_ERROR, "3:" BITMAP_SUCCESS.

PrinterHtmlListener.onFinishPrinting

void onFinishPrinting(int result);

Return after print.

Returns
result int : The result of the print,"0:" PRINT_ERROR, "1:" PRINT_SUCCESS,"2:" BITMAP_ERROR, "3:" BITMAP_SUCCESS,"4:" DEVICE_NOT_OPEN.

by Java API

Please refer to java API Spec. in our demo from SDK folder \cloudpos_SDK\device\java\sample\APIDemoForAar\app\src\main\java\com\wizarpos\apidemo\action\PrinterAction.java, there is a printHtml method, you can call like it.