使用 Android 在 android MZ320 中使用 cpcl 将图像和文本打印到收据
print an image and text to receipt using cpcl in android MZ320 using Android
我尝试像那个模板一样使用 Cpcl 格式在收据中打印图像和文本。我有一个示例将徽标设置为变量并使用函数将图像读取为字符串但示例中的图像是 CPCL 格式将我的图像徽标设置为 cpcl 格式或以其他方式设置像该模板一样的图像和文本。
============================================= =======
press here to see the image, this image have the ticket printed from worked example and that is what i need exactly but i can't change image to new one.
//this template used to design my ticket which it has image and text in the same ticket like what i need.
! 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}
/* the line below is used to set image as a string variable initialized
in code from image i have in the worked example which its extension
logo.cpcl" I don't know how it comes? and i need to change new logo to
Cpcl from png too "newlogo.png -> newlogo.cpcl" "pcx" x, y, data"*/
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 line I use to call the function to read cpcl image!
//and here we got the image from resources
result = StringUtils.replace(result, "${Logo}", PrinterUtil.readFormat(context, R.raw.logo));
//this is the code used to read image as a string and it works perfectly with the example.
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) {
}
}
}
}][1]
我尝试了很多解决方案,但都不起作用。
我有旧代码在 cpcl 扩展名中使用图像作为 aلاfile 而不是 png 或 jpg 我不知道它是怎么来的?
但是当我在文档中搜索时我创建了新的解决方案我找到了那个命令并且我使用打击步骤完成了它。
如何在 Android 应用程序中使用 CPCL 更改 Ticket 中的徽标?
1.You 必须按照以下步骤进行更改并使其适用于 Zebra 打印机 MZ320 和 iMZ320:
首先,您必须使用此 link 将图像更改为黑白图像。 https://pinetools.com/threshold-image.
之后,您必须从其像素中将其作为二进制文本获取,并使用此 link https://www.dcode.fr/binary-image.
[ 使用自定义宽度 =120 调整其大小=60=]
- 复制从图像中导出的二进制文本并将其粘贴到文本编辑器(如 notebad++)中。
2.Change图中所有(1)都(F)大写.
3.your_ticket.cpcl那你得用这个命令进去
`EXPANDED-GRAPHICS [ByteWidth] [Height] [X] [Y] [Data]<CR><LF>`.
4.ByteWidth 是数据中第一行的字节大小,如下例所示。
5.Height 是你数据中的行数
6.Data是从文本编辑器中复制出来的图像数据,然后像那个例子一样写。
7.Example:
扩展图形 10 6 30 30
FFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFF
FF0000FFFFFFF00000FF
FF00000FFFFF000000FF
FF000000FFF0000000FF
FFFFFFFFFFFFFFFFFFFF
- 测试您的图像数据并打印票证,如果您发现您的图像不清晰,请尝试像该图像一样向右旋转 35 度。
我尝试像那个模板一样使用 Cpcl 格式在收据中打印图像和文本。我有一个示例将徽标设置为变量并使用函数将图像读取为字符串但示例中的图像是 CPCL 格式将我的图像徽标设置为 cpcl 格式或以其他方式设置像该模板一样的图像和文本。
============================================= =======
press here to see the image, this image have the ticket printed from worked example and that is what i need exactly but i can't change image to new one.
//this template used to design my ticket which it has image and text in the same ticket like what i need.
! 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}
/* the line below is used to set image as a string variable initialized
in code from image i have in the worked example which its extension
logo.cpcl" I don't know how it comes? and i need to change new logo to
Cpcl from png too "newlogo.png -> newlogo.cpcl" "pcx" x, y, data"*/
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 line I use to call the function to read cpcl image!
//and here we got the image from resources
result = StringUtils.replace(result, "${Logo}", PrinterUtil.readFormat(context, R.raw.logo));
//this is the code used to read image as a string and it works perfectly with the example.
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) {
}
}
}
}][1]
我尝试了很多解决方案,但都不起作用。 我有旧代码在 cpcl 扩展名中使用图像作为 aلاfile 而不是 png 或 jpg 我不知道它是怎么来的? 但是当我在文档中搜索时我创建了新的解决方案我找到了那个命令并且我使用打击步骤完成了它。
如何在 Android 应用程序中使用 CPCL 更改 Ticket 中的徽标?
1.You 必须按照以下步骤进行更改并使其适用于 Zebra 打印机 MZ320 和 iMZ320:
首先,您必须使用此 link 将图像更改为黑白图像。 https://pinetools.com/threshold-image.
之后,您必须从其像素中将其作为二进制文本获取,并使用此 link https://www.dcode.fr/binary-image.
[ 使用自定义宽度 =120 调整其大小=60=]- 复制从图像中导出的二进制文本并将其粘贴到文本编辑器(如 notebad++)中。
2.Change图中所有(1)都(F)大写.
3.your_ticket.cpcl那你得用这个命令进去
`EXPANDED-GRAPHICS [ByteWidth] [Height] [X] [Y] [Data]<CR><LF>`.
4.ByteWidth 是数据中第一行的字节大小,如下例所示。
5.Height 是你数据中的行数
6.Data是从文本编辑器中复制出来的图像数据,然后像那个例子一样写。
7.Example:
扩展图形 10 6 30 30 FFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFF
FF0000FFFFFFF00000FF
FF00000FFFFF000000FF
FF000000FFF0000000FF
FFFFFFFFFFFFFFFFFFFF
- 测试您的图像数据并打印票证,如果您发现您的图像不清晰,请尝试像该图像一样向右旋转 35 度。