How to Print Unsupported Character Sets with a POS Printer: Difference between revisions
No edit summary |
|||
Line 8: | Line 8: | ||
The app declares the android.permission.SYSTEM_ALERT_WINDOW in the manifest. This is required by printHTML utility to use a hidden HTML rendering window. | The app declares the android.permission.SYSTEM_ALERT_WINDOW in the manifest. This is required by printHTML utility to use a hidden HTML rendering window. | ||
== '''By Java API''' == | |||
Please refer to java [http://{{SERVERNAME}}/wizarposapi/ API Spec]. | |||
in APIDemoForAar from SDK folder \cloudpos_SDK\device\apidemo\, there is a printHtml method in com.wizarpos.apidemo.action.PrinterAction.java, you can call it like this. | |||
== By JNI API == | == '''By JNI API''' == | ||
=== API Overview === | === API Overview === | ||
==== <big>PrintHtmlInterface.printHTML</big>==== | ==== <big>PrintHtmlInterface.printHTML</big>==== | ||
Line 66: | Line 69: | ||
=== Sample === | === Sample === | ||
Please find the sample in SDK folder, [ftp://sdkuser:wizsdkar@ftp.wizarpos.com/device/c/apidemo_c_1.5.0.2.zip apidemo] | Please find the sample in SDK folder, [ftp://sdkuser:wizsdkar@ftp.wizarpos.com/device/c/apidemo_c_1.5.0.2.zip apidemo] | ||
Revision as of 08:40, 10 July 2019
The font of the printer only support ISO8859-1 and GBK character set.
But you can still print other language by using HTML content printing.
Please add WebView.enableSlowWholeDocumentDraw() in your APP source code, because we use android WebView to print html content.
Permission
The app declares the android.permission.SYSTEM_ALERT_WINDOW in the manifest. This is required by printHTML utility to use a hidden HTML rendering window.
By Java API
Please refer to java API Spec. in APIDemoForAar from SDK folder \cloudpos_SDK\device\apidemo\, there is a printHtml method in com.wizarpos.apidemo.action.PrinterAction.java, you can call it like this.
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. It's used by method to create the hidden window. |
htmlcontent | String : The HTML content for printing. |
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);
This callback will return the bitmap if you invoke the convert2Image method of the PrintHtmlInterface.
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);
This callback will be callled after printing if you invoke the printHTML method of the PrintHtmlInterface.
Returns | |
---|---|
result | int : The result of the print,"0:" PRINT_ERROR, "1:" PRINT_SUCCESS,"2:" BITMAP_ERROR, "3:" BITMAP_SUCCESS,"4:" DEVICE_NOT_OPEN. |
Sample
Please find the sample in SDK folder, apidemo