Allow different label widths (e. g. 88mm labels)
Opened this issue · 2 comments
mschneider82 commented
currently the 62mm is hardcoded, i have a 88mm printer, i would like to scale up the labels to 88mm
e.g. DHL would be 62mm -> 88mm (x1,41)
mschneider82 commented
i have fixed it by hardcoding a *1.41 factor and changing the 62 to 88 on the other functions, a cleaner way would be nice.
const dhlPrivat = {
file: {
type: 'pdf',
page: 1,
rotation: 90
},
width: 2324, // 139mm (=> 145mm)
crop(outputCanvas, ctx, image) {
ctx.drawImage(image, // Kopf
1964, 106, 1124, 94,
0, 0, 890 * 1.41, 74 * 1.41);
ctx.drawImage(image, // Adresse
1964, 210, 785, 625,
0, 95*1.41, 580 * 1.41, 465 * 1.41);
let scSize = 296;
ctx.drawImage(image, // Sicherheitscode
2763, 215, scSize, scSize,
594*1.41, 90*1.41, scSize * 1.41, scSize * 1.41);
ctx.rotate(-Math.PI / 2);
ctx.drawImage(image, // Sicherheitscode Text
3075, 244, 20, 194,
-395 * 1.41, 645 * 1.41, -20 * 1.41, 194 * 1.41);
ctx.rotate(Math.PI / 2);
ctx.drawImage(image, // Bahntransport
2802, 679, 234, 154,
666 * 1.41, 465 * 1.41, 152 * 1.41, 100 * 1.41);
ctx.drawImage(image, // Sendungsdaten
1964, 933, 1124, 152,
0 * 1.41, 576 * 1.41, 890 * 1.41, 120 * 1.41);
ctx.beginPath(); ctx.moveTo(910 * 1.41, 0); ctx.lineTo(910 * 1.41, outputCanvas.height); ctx.stroke();
let barcodeSizeX = 710,
barcodeSizeY = 320;
ctx.drawImage(image, // Leitcode/Routingcode
2181, 1526, barcodeSizeX, barcodeSizeY,
930 * 1.41, 20 * 1.41, barcodeSizeX*1.41, barcodeSizeY*1.41);
ctx.drawImage(image, // Identcode/Sendungsnummer
2181, 1940, barcodeSizeX, barcodeSizeY,
930 * 1.41, 376 * 1.41, barcodeSizeX*1.41, barcodeSizeY*1.41);
}
};
typingbeaver commented
Thanks for your issue!
I will take it into consideration for the future, but this won't be any of my main goals right now, as it is a "more special" use case. I might have some concerns regarding upscaling the images in regards of quality (despite the many downscales except the barcodes).