打印优化
This commit is contained in:
+43
-9
@@ -752,13 +752,6 @@
|
||||
ipcRenderer.send('get-scale-rate')
|
||||
const { clipboard } = require('electron')
|
||||
const dpi = 300
|
||||
// 创建 PDF 实例
|
||||
const pdf = new jspdf.jsPDF({
|
||||
orientation: 'landscape',
|
||||
unit: 'px',
|
||||
format: [1012, 648]
|
||||
});
|
||||
|
||||
//var encrypt = new JSEncrypt();
|
||||
//encrypt.setPublicKey(`-----BEGIN PUBLIC KEY-----
|
||||
//MIGdMA0GCSqGSIb3DQEBAQUAA4GLADCBhwKBgQDAbKQ46WevL9PapJ+AlZqSzczkTovu7STH
|
||||
@@ -1166,6 +1159,7 @@
|
||||
$("#set_bg").hide();
|
||||
$('#out_pic_control').hide()
|
||||
$('#text_control').hide()
|
||||
$('#circle_text_control').hide()
|
||||
$('#out_text_control').hide()
|
||||
$('#rect_control').hide()
|
||||
$('#circle_control').hide()
|
||||
@@ -1403,18 +1397,27 @@
|
||||
const buffer4 = Buffer.from(url4.replace(/^data:image\/\w+;base64,/, ""), 'base64');
|
||||
const printPath4 = path.join(exePath, 'print4.png');
|
||||
fs.writeFileSync(printPath4, buffer4);
|
||||
// 创建 PDF 实例
|
||||
const pdf = new jspdf.jsPDF({
|
||||
orientation: 'landscape',
|
||||
unit: 'px',
|
||||
format: [1012, 648]
|
||||
});
|
||||
let btns = [language_str('output')]
|
||||
if ((objs1.length != 0) & (objs2.length == 0)) {
|
||||
//只有正面
|
||||
let img = new Image()
|
||||
img.src = printPath3
|
||||
|
||||
pdf.addImage(img, 'JPEG', 0, 0, 1012, 648)
|
||||
btns.push('打印正面')
|
||||
} else if ((objs1.length == 0) & (objs2.length != 0)) {
|
||||
//只有背面
|
||||
let img = new Image()
|
||||
img.src = printPath4
|
||||
|
||||
pdf.addImage(img, 'JPEG', 0, 0, 1012, 648)
|
||||
btns.push('打印背面')
|
||||
} else {
|
||||
let img = new Image()
|
||||
img.src = printPath3
|
||||
@@ -1425,10 +1428,13 @@
|
||||
let img2 = new Image()
|
||||
img2.src = printPath4
|
||||
pdf.addImage(img2, 'JPEG', 0, 0, 1012, 648)
|
||||
btns.push('打印正面')
|
||||
btns.push('打印背面')
|
||||
}
|
||||
|
||||
var pdfBlob = pdf.output('blob')
|
||||
var pdfBuffer = pdf.output('arraybuffer')
|
||||
|
||||
layer.open({
|
||||
type: 1,
|
||||
area: [w, h],
|
||||
@@ -1451,12 +1457,20 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>`,
|
||||
btn: [language_str('output'), '打印'], //'导出'
|
||||
btn: btns, //'导出'
|
||||
btn1: function (index, layero) {
|
||||
savePdf(Buffer.from(pdfBuffer))
|
||||
},
|
||||
btn2: function () {
|
||||
printJS({ printable: URL.createObjectURL(pdfBlob), type: 'pdf', onPrintDialogClose: () => URL.revokeObjectURL(pdfBlob) })
|
||||
if (btns[1] === '打印正面') {
|
||||
printJS({ printable: printPath3, type: 'image', style: 'img { width: 100%; height: auto; }' })
|
||||
} else {
|
||||
printJS({ printable: printPath4, type: 'image', style: 'img { width: 100%; height: auto; }' })
|
||||
}
|
||||
},
|
||||
btn3: function () {
|
||||
//打印背面
|
||||
printJS({ printable: printPath4, type: 'image', style: 'img { width: 100%; height: auto; }' })
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -1477,6 +1491,7 @@
|
||||
$("#set_bg").hide();
|
||||
$('#out_pic_control').hide()
|
||||
$('#text_control').hide()
|
||||
$("#circle_text_control").hide();
|
||||
$('#out_text_control').hide()
|
||||
$('#rect_control').hide()
|
||||
$('#circle_control').hide()
|
||||
@@ -1971,6 +1986,7 @@
|
||||
$("#set_bg").hide();
|
||||
$('#out_pic_control').hide()
|
||||
$('#text_control').hide()
|
||||
$("#circle_text_control").hide();
|
||||
$('#out_text_control').hide()
|
||||
$('#rect_control').hide()
|
||||
$('#circle_control').hide()
|
||||
@@ -2819,6 +2835,7 @@
|
||||
$("#set_bg").hide();
|
||||
$('#out_pic_control').hide()
|
||||
$('#text_control').hide()
|
||||
$("#circle_text_control").hide();
|
||||
$('#out_text_control').hide()
|
||||
$('#rect_control').hide()
|
||||
$('#circle_control').hide()
|
||||
@@ -2849,6 +2866,7 @@
|
||||
$("#set_bg").hide();
|
||||
$('#out_pic_control').hide()
|
||||
$('#text_control').hide()
|
||||
$("#circle_text_control").hide();
|
||||
$('#out_text_control').hide()
|
||||
$('#rect_control').hide()
|
||||
$('#circle_control').hide()
|
||||
@@ -3177,6 +3195,7 @@
|
||||
$("#set_bg").hide();
|
||||
$('#out_pic_control').hide()
|
||||
$('#text_control').hide()
|
||||
$("#circle_text_control").hide();
|
||||
$('#out_text_control').hide()
|
||||
$('#rect_control').hide()
|
||||
$('#circle_control').hide()
|
||||
@@ -3211,6 +3230,7 @@
|
||||
$("#set_bg").hide();
|
||||
$('#out_pic_control').hide()
|
||||
$('#text_control').hide()
|
||||
$("#circle_text_control").hide();
|
||||
$('#out_text_control').hide()
|
||||
$('#rect_control').hide()
|
||||
$('#circle_control').hide()
|
||||
@@ -4240,6 +4260,7 @@
|
||||
|
||||
$('#out_pic_control').hide()
|
||||
$('#text_control').hide()
|
||||
$("#circle_text_control").hide();
|
||||
$('#out_text_control').hide()
|
||||
$('#rect_control').hide()
|
||||
$('#circle_control').hide()
|
||||
@@ -4278,6 +4299,7 @@
|
||||
$('#pic_control').hide()
|
||||
$("#set_bg").hide();
|
||||
$('#text_control').hide()
|
||||
$("#circle_text_control").hide();
|
||||
$('#out_text_control').hide()
|
||||
$('#rect_control').hide()
|
||||
$('#circle_control').hide()
|
||||
@@ -4344,6 +4366,7 @@
|
||||
$('#pic_control').hide()
|
||||
$("#set_bg").hide();
|
||||
$('#out_pic_control').hide()
|
||||
$("#circle_text_control").hide();
|
||||
$('#out_text_control').hide()
|
||||
$('#rect_control').hide()
|
||||
$('#circle_control').hide()
|
||||
@@ -4544,6 +4567,7 @@
|
||||
$("#set_bg").hide();
|
||||
$('#out_pic_control').hide()
|
||||
$('#text_control').hide()
|
||||
$("#circle_text_control").hide();
|
||||
$('#rect_control').hide()
|
||||
$('#circle_control').hide()
|
||||
$('#line_control').hide()
|
||||
@@ -4581,6 +4605,7 @@
|
||||
$("#set_bg").hide();
|
||||
$('#out_pic_control').hide()
|
||||
$('#text_control').hide()
|
||||
$("#circle_text_control").hide();
|
||||
$('#out_text_control').hide()
|
||||
$('#circle_control').hide()
|
||||
$('#line_control').hide()
|
||||
@@ -4616,6 +4641,7 @@
|
||||
$("#set_bg").hide();
|
||||
$('#out_pic_control').hide()
|
||||
$('#text_control').hide()
|
||||
$("#circle_text_control").hide();
|
||||
$('#out_text_control').hide()
|
||||
$('#rect_control').hide()
|
||||
$('#line_control').hide()
|
||||
@@ -4658,6 +4684,7 @@
|
||||
$("#set_bg").hide();
|
||||
$('#out_pic_control').hide()
|
||||
$('#text_control').hide()
|
||||
$("#circle_text_control").hide();
|
||||
$('#out_text_control').hide()
|
||||
$('#rect_control').hide()
|
||||
$('#circle_control').hide()
|
||||
@@ -4690,6 +4717,7 @@
|
||||
$('#pic_control').hide()
|
||||
$('#out_pic_control').hide()
|
||||
$('#text_control').hide()
|
||||
$("#circle_text_control").hide();
|
||||
$('#out_text_control').hide()
|
||||
$('#rect_control').hide()
|
||||
$('#circle_control').hide()
|
||||
@@ -4728,6 +4756,7 @@
|
||||
$('#pic_control').hide()
|
||||
$('#out_pic_control').hide()
|
||||
$('#text_control').hide()
|
||||
$("#circle_text_control").hide();
|
||||
$('#out_text_control').hide()
|
||||
$('#rect_control').hide()
|
||||
$('#circle_control').hide()
|
||||
@@ -4766,6 +4795,7 @@
|
||||
$('#pic_control').hide()
|
||||
$('#out_pic_control').hide()
|
||||
$('#text_control').hide()
|
||||
$("#circle_text_control").hide();
|
||||
$('#out_text_control').hide()
|
||||
$('#rect_control').hide()
|
||||
$('#circle_control').hide()
|
||||
@@ -5464,6 +5494,7 @@
|
||||
$('#pic_control').hide()
|
||||
$('#out_pic_control').hide()
|
||||
$('#text_control').hide()
|
||||
$("#circle_text_control").hide();
|
||||
$('#out_text_control').hide()
|
||||
$('#rect_control').hide()
|
||||
$('#circle_control').hide()
|
||||
@@ -5562,6 +5593,7 @@
|
||||
$('#pic_control').hide()
|
||||
$('#out_pic_control').hide()
|
||||
$('#text_control').hide()
|
||||
$("#circle_text_control").hide();
|
||||
$('#out_text_control').hide()
|
||||
$('#rect_control').hide()
|
||||
$('#circle_control').hide()
|
||||
@@ -5716,6 +5748,7 @@
|
||||
$('#pic_control').hide()
|
||||
$('#out_pic_control').hide()
|
||||
$('#text_control').hide()
|
||||
$("#circle_text_control").hide();
|
||||
$('#out_text_control').hide()
|
||||
$('#rect_control').hide()
|
||||
$('#circle_control').hide()
|
||||
@@ -6006,6 +6039,7 @@
|
||||
$('#pic_control').hide()
|
||||
$('#out_pic_control').hide()
|
||||
$('#text_control').hide()
|
||||
$("#circle_text_control").hide();
|
||||
$('#out_text_control').hide()
|
||||
$('#rect_control').hide()
|
||||
$('#circle_control').hide()
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 4.6 MiB |
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 24 KiB |
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 16 KiB |
Reference in New Issue
Block a user