How to Print Images with a POS Printer: Difference between revisions

From wizarPOS
No edit summary
Line 3: Line 3:
# Image width should less then or equal to 384 dots.
# Image width should less then or equal to 384 dots.
# Image height should be a multiple of 24. If the height is not a multiple of 24, please notice that the remainder dots will print blank.  
# Image height should be a multiple of 24. If the height is not a multiple of 24, please notice that the remainder dots will print blank.  
* Call print image API to print, snippet code(java API) is as follows:
* Call the print image API to print. The code snippet (Java API) is as follows:
<syntaxhighlight lang="java">
<syntaxhighlight lang="java">
     public void printBitmap(Map<String, Object> param, ActionCallback callback) {
     public void printBitmap(Map<String, Object> param, ActionCallback callback) {

Revision as of 08:55, 25 March 2020

  • Put image to the assets folder of the application project.

About the image:

  1. Image width should less then or equal to 384 dots.
  2. Image height should be a multiple of 24. If the height is not a multiple of 24, please notice that the remainder dots will print blank.
  • Call the print image API to print. The code snippet (Java API) is as follows:
    public void printBitmap(Map<String, Object> param, ActionCallback callback) {
        Bitmap bitmap =null;
        try {
            bitmap = BitmapFactory.decodeStream(mContext.getResources().getAssets()
                    .open("photo.bmp"));
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        try {
            device.printBitmap(bitmap);
            sendSuccessLog(mContext.getString(R.string.operation_succeed));
        } catch (DeviceException e) {
            e.printStackTrace();
            sendFailedLog(mContext.getString(R.string.operation_failed));
        }
    }