print an image and text to receipt using cpcl in android MZ320

m mahmoud zahran 3 years 7 months ago
201 0 0

Dear all,I tried to print image and text in receipt using Cpcl format like that template. I have an example set logo as a variable and use function to read the image as string but that image in example is CPCL format I tried a lot  to get my logo as a cpcl format but i can't so I need to know how to get my image logo as cpcl format or another way to set image and text like that templete.
====================================================
! 0 200 200 1050 1
PW 575
TONE 0
SPEED 3
ON-FEED IGNORE
NO-PACE
BAR-SENSE
BT 0 4 6
B 128 3 30 120 20 0 ${barcode}

PCX 420 790 ${Logo}

ML 32
T270 7 0 550 170 ${typeTicket}
ENDML

ML 32
T270 7 0 498 170 ${validPeriod}
ENDML

ML 25
T270 7 0 446 170 ${park}
ENDML

ML 32
T270 7 0 370 170 ${price}
ENDML

ML 25
T270 7 0 300 170 ${termsOfUse}
ENDML

PRINT
=================================
this is the code used to read image as a string and it works perfectly with the example.

this line how to use !
result = StringUtils.replace(result, "${Logo}", PrinterUtil.readFormat(context, R.raw.logo));

public static String readFormat(Context context, int formatRes) {
  InputStream is = null;
   try {
  is = context.getResources().openRawResource(formatRes);
   try {
   return readString(is);
  } catch (IOException e) {
   return null;
  }
  } finally {
   if (is != null) {
   try {
  is.close();
  } catch (IOException e) {
  }
  }
  }
}

CONTACT
Can’t find what you’re looking for?