三行代码  ›  专栏  ›  技术社区  ›  bruceyyy_12

如何使用'bwip-js-min.js'添加右侧安静区域指示符'>'

  •  0
  • bruceyyy_12  · 技术社区  · 3 周前

    我想使用“bwip-js-min.js”提供我的代码

    <!DOCTYPE html>
    <html>
    <head>
      <title>EAN13 Barcode Generator</title>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/bwip-js/3.1.0/bwip-js-min.js"></script>
    </head>
    <body>
        <div class="size">
            <canvas id="canvas" width="500"></canvas>
    
        </div>
      
      <script>
        // Get the canvas element
        var canvas = document.getElementById('canvas');
    
        // Generate the barcode
        bwipjs.toCanvas(canvas, {
          bcid: 'ean13', // Barcode type
          text: '883123456789', // Barcode data
          scale: 2, // Scale factor
          height: 25, // Barcode height in mm
          paddingright: 10,
          includetext: true, // Show human-readable text
          
       
        });
      </script>
    </body>
    </html>
    
    

    我想问的主要原因是添加了右侧安静区域指示器'>'在“text:”883123456789“”的边缘

    1 回复  |  直到 3 周前
        1
  •  0
  •   Mark Warren    3 周前

    使用特定条形码类型时,请务必查看BWIPP文档,了解可用的选项。对于EAN-13: https://github.com/bwipp/postscriptbarcode/wiki/EAN-13

    您想要的选项是 guardwhitespace:true