Commit 91cf88d6 by anxiaohe

二维码导出

parent 84ef6507
......@@ -243,7 +243,7 @@ public class DrawQrcodeUtil {
QRcodeSize qRcodeSize = null;
qRcodeSize = new QRcodeSize(8,800,1800,78,800,200,1600,1600,new Color(34,25,21));
// BufferedImage bgImage = new BufferedImage(1600, 2400, BufferedImage.TYPE_4BYTE_ABGR);
BufferedImage bgImage = new BufferedImage(3200, 2400, BufferedImage.TYPE_4BYTE_ABGR);
BufferedImage bgImage = new BufferedImage(3200, 2400, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = bgImage.createGraphics();
BufferedImage qrcodeImage = ImageIO.read(qrcodeFile);
......@@ -255,7 +255,7 @@ public class DrawQrcodeUtil {
, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
g2.setRenderingHints(rh);
Font font = new Font("微软雅黑",Font.PLAIN,150);
Font font = new Font("等线",Font.PLAIN,100);
g2.setFont(font); //设置字体:字体、字号、大小
g2.setColor(qRcodeSize.color);//设置背景颜色
......
......@@ -17,7 +17,7 @@ var defPrintOption = {
// usb tcp
protocol: printerProtocolMap.usb,
// 打印机指令
printerDirective: printerDirectiveMap._thermal_zpl_draw_print_
printerDirective: printerDirectiveMap._thermal_tspl_draw_print_
}
var device = '';
......@@ -73,21 +73,21 @@ var Image_style_letType = {
var pageConfig = {
// 纸张宽度
draw_w: '',
draw_w: 90,
// 页长
draw_h: '',
draw_h: 72.5,
// 横向位置
Image_x: '',
Image_x: 0,
// 纵向位置
Image_y: '',
Image_y: 0,
// 图片宽度
Image_w: '',
Image_w: 84,
// 图片高度
Image_h: '',
Image_h: 63,
// 图片阈值
Image_Threshold: '',
Image_Threshold: 170,
// 图片打印模式
Image_style_let: '1',
Image_style_let: 3,
}
//绘图打印图片
......@@ -125,34 +125,63 @@ function printImage (url) {
}
}
var pack = {
command: defPrintOption.printerDirective,
device : device,
printdirectly : 'true',
measurement_mode: 'mm',
canvas_size : {
width: pageConfig.draw_w,
height: pageConfig.draw_h
},
get_base64_img : 'false',
is_label: 'false',
print: [
{
func: "PDSetAddImageMode",
iMode: pageConfig.Image_style_let,
iValueThreshold: pageConfig.Image_Threshold
},
{
func:"PDDrawImage",
iX: pageConfig.Image_x,
iY: pageConfig.Image_y,
iWidth: pageConfig.Image_w,
iHeight: pageConfig.Image_h,
szImageFile: url
url2Base64(url).then(res => {
var pack = {
command: defPrintOption.printerDirective,
device : device,
printdirectly : 'true',
measurement_mode: 'mm',
canvas_size: {
width: pageConfig.draw_w,
height: pageConfig.draw_h
},
]
}
on_link_device(pack, onBack);
get_base64_img : 'false',
is_label: 'false',
print: [
{
func: "PDSetAddImageMode",
iMode: pageConfig.Image_style_let,
iValueThreshold: pageConfig.Image_Threshold
},
{
func:"PDDrawImage",
iX: pageConfig.Image_x,
iY: pageConfig.Image_y,
iWidth: pageConfig.Image_w,
iHeight: pageConfig.Image_h,
szImageFile: res
},
]
}
console.log(pack)
on_link_device(pack, onBack);
})
}
function url2Base64 (url, type = 'image/jpeg') {
return new Promise((resolve, reject) => {
const img = new Image()
const canvas = document.createElement('canvas');
img.crossOrigin = '*';
img.onload = function () {
const width = img.width, height = img.height;
canvas.width = width;
canvas.height = height;
const ctx = canvas.getContext('2d');
ctx.fillStyle = 'white';
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.drawImage(img, 0, 0, width, height);
const base64 = canvas.toDataURL(type);
resolve(base64);
};
img.onerror = function () {
reject(new Error('message'));
};
img.src = url;
});
}
function on_link_device (pack, onBack) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment