Print Unsupported Character Sets
POS Printer Character Set Support
Overview:
The POS printer is equipped to support the GB2312 character set by default, which is predominantly used for simplified Chinese characters. Additionally, it accommodates various Latin character sets, including but not limited to ISO8859-1.
Changing Character Sets:
To modify the printer's character set, developers can use ESC (Escape) commands. Detailed guidance on printer technical document.
Advanced Printing Options Using HTML
Context:
In scenarios where the default character sets do not meet your requirements, or if you desire a more aesthetically pleasing font, printing via HTML content is a viable option.
Implementing HTML Printing:
To enable HTML printing, the following steps are required:
WebView Configuration:
Integrate the WebView.enableSlowWholeDocumentDraw() method into your application's source code. This step is crucial as the printing functionality utilizes Android WebView to process HTML content for printing.
Permission Requirements:
Your application must declare the android.permission.SYSTEM_ALERT_WINDOW permission in its manifest file. This permission is essential for the printHTML utility to effectively render windows using off-screen HTML content.
Java SDK API
API Overview
printHTML
Print html content, add WebView.enableSlowWholeDocumentDraw() in the calling app, and add this permission android.permission.SYSTEM_ALERT_WINDOW in manifest file.
Parameters | |
---|---|
context | Context: context. |
htmlContent | String: html content. |
listener | PrinterHtmlListener: PrinterHtmlListener. |
convertHTML2image
convertHTML2image, add WebView.enableSlowWholeDocumentDraw() in the calling app, and add this permission android.permission.SYSTEM_ALERT_WINDOW in manifest file.
Parameters | |
---|---|
context | Context: context. |
htmlContent | String: html content. |
listener | PrinterHtmlListener: PrinterHtmlListener. |
PrinterHtmlListener.onGet
Parameters | |
---|---|
bitmap | Bitmap : generated bitmap. |
errorCode | int: returned value:PRINT_ERROR = 0;PRINT_SUCCESS = 1;BITMAP_ERROR = 2;BITMAP_SUCCESS = 3;DEVICE_NOT_OPEN = 4. |
PrinterHtmlListener.onFinishPrinting
Parameters | |
---|---|
errorCode | int: returned value:PRINT_ERROR = 0;PRINT_SUCCESS = 1;BITMAP_ERROR = 2;BITMAP_SUCCESS = 3;DEVICE_NOT_OPEN = 4. |
Sample with Java SDK API
Please refer to java API Spec. Download API demo, there is a printHtml method in com.wizarpos.apidemo.action.PrinterAction.java, you can call it like this:
Last updated