hand-dot / labelmake

labelmake has moved and now available at pdfme / https://github.com/pdfme/pdfme

Home Page:https://labelmake.jp/javascript-pdf-generator-library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Barcode doesn't works on browser with CDN

koramit opened this issue · comments

Hello, Thanks for this package. It's very useful.

I have a problem with barcode when use plain JS with CDN.

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'toBuffer')

Code to reproduce error.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Labelmake QRCODE</title>
    <script src="https://cdn.jsdelivr.net/npm/labelmake@2.0.19/dist/labelmake.min.js"></script>
</head>
<body>
    <iframe id="iframe" src="" frameborder="0" style="width: 100%; height: 100vh;"></iframe>

    <script>
        (async () => {
            const template = {
                basePdf: { width: 210, height: 297 },
                schemas: [
                    {
                        qrcode: {
                            type: "qrcode",
                            position: { x: 5, y: 5 },
                            width: 30,
                            height: 30
                        }
                    }
                ]
            };
            // Please omit the barcode checksum.
            const inputs = [
                { qrcode: "test" }
            ];
            const pdf = await labelmake({ template, inputs });
            const blob = new Blob([pdf.buffer], { type: "application/pdf" });
            document.getElementById("iframe").src = URL.createObjectURL(blob);
        })();
    </script>
</body>
</html>

I tested on chrome/firefox/safari, same error.
This environment work perfectly with type text.

Thanks

Thanks, bug report.
this bug comes from bwip-js.
ref #64

I'll handle in #64.