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

From wizarPOS
No edit summary
No edit summary
Line 1: Line 1:
* Put image to the assets folder of the application project.
== Preparing the Image ==
About the image:
'''Location:''' Place the image in the ''''assets'''' folder of your application project.
# 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 Specifications:'''
* Call the print image API to print. The code snippet (Java API) is as follows:
* '''Width:''' The width of the image should be 384 dots or less.
* '''Height:''' The height should be a multiple of 24 dots. If the height is not a multiple of 24, the excess will result in blank printing at the bottom of the image.
== Printing the Image ==
'''Using the Print Image API:''' To print the image, call the print image API provided in the Java API. The necessary code snippet for this process 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 01:19, 22 December 2023

Preparing the Image

Location: Place the image in the 'assets' folder of your application project.

Image Specifications:

  • Width: The width of the image should be 384 dots or less.
  • Height: The height should be a multiple of 24 dots. If the height is not a multiple of 24, the excess will result in blank printing at the bottom of the image.

Printing the Image

Using the Print Image API: To print the image, call the print image API provided in the Java API. The necessary code snippet for this process 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));
        }
    }