Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow different label widths (e. g. 88mm labels) #11

Open
mschneider82 opened this issue Oct 6, 2023 · 2 comments
Open

Allow different label widths (e. g. 88mm labels) #11

mschneider82 opened this issue Oct 6, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@mschneider82
Copy link

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
Copy link
Author

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 typingbeaver added the enhancement New feature or request label Nov 24, 2023
@typingbeaver
Copy link
Owner

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).

@typingbeaver typingbeaver changed the title make it compatible with other printers with different label sizes Allow different label widths (e. g. 88mm labels) Nov 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants