如何实现条形码的恒定宽度;无论条形码数据如何

时间:2012-12-07 18:10:36

标签: label barcode barcode-scanner barcode-printing

目前我正在编写一个标签编写者(兄弟QL-570,如果重要的话,用Java编写)来打印具有不同ID的条形码。条形码数据的长度可以从~17个字符到~3个不等。

然而,鉴于我已正确理解条形码概念,数据越多 - 条形码就越宽。

如果所有条形码具有相同的恒定大小,我更喜欢:无论数据长度如何。 (如果条形码没有填满标签,它看起来不太好,如果条形码太大也不会(工作))

当标签尺寸固定(即29mm x 90mm)时,如何处理?您/贵公司是如何解决这个问题的? 2D条形码不是一种选择。不幸的是

enter image description here

2 个答案:

答案 0 :(得分:4)

我认为最好的做法是填充数据,即

123

变为

00000000000000123

仅仅考虑其他地方如何做到这一点,我在日常生活中肯定看到零填充条形码。我认为最好的办法就是选择一些您认为足够多年的数字,并将您的应用程序编码为该数字。如果你最终不得不超越它,那么,这是一个很好的问题,不是吗?

答案 1 :(得分:3)

如果你不得不并排比较不同宽度的条形码,它看起来会很有趣,但是我的公司通过用1x来定义每个符号来解决它?位图并将其扩展到应用程序所需的大小。例如,除了Stop之外,每个代码128符号的宽度为11个像素。我们的"字体"然后定义了107个字符,每个字符为1x11黑白位图(PNG)。

如果你对垂直和水平尺寸有很大的控制,它可以使条形码适合更简单的空间。

这是一个类似于上图的快速示例:



    <img 
    alt="104,{Start B}" title="104,{Start B}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/AC3gAT0BDuLeG4IAAAAASUVORK5CYII=" width="30" height="30"><img
    alt=" 17,A:{1},B:{1}" title=" 17,A:{1},B:{1}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/AGMgAOkAhBjTObMAAAAASUVORK5CYII=" width="30" height="30"><img
    alt=" 18,A:{2},B:{2}" title=" 18,A:{2},B:{2}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/ADGgAQUA0nI/mr0AAAAASUVORK5CYII=" width="30" height="30"><img
    alt=" 19,A:{3},B:{3}" title=" 19,A:{3},B:{3}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/ADRgAMsAlQDS68kAAAAASUVORK5CYII=" width="30" height="30"><img
    alt=" 08,A:{(},B:{(}" title=" 08,A:{(},B:{(}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/AHNgAUkA1ElZCJAAAAAASUVORK5CYII=" width="30" height="30"><img
    alt="106,{Stop}"title="106,{Stop}"src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAABAQMAAAA/57ZEAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/ADigARMA2dpJzT8AAAAASUVORK5CYII=" width="30" height="30">
    <p/>
    123
    <br>
    <p>&nbsp;</p>
    <img 
    alt="104,{Start B}" title="104,{Start B}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/AC3gAT0BDuLeG4IAAAAASUVORK5CYII=" width="9" height="30"><img
    alt=" 17,A:{1},B:{1}" title=" 17,A:{1},B:{1}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/AGMgAOkAhBjTObMAAAAASUVORK5CYII=" width="9" height="30"><img
    alt=" 18,A:{2},B:{2}" title=" 18,A:{2},B:{2}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/ADGgAQUA0nI/mr0AAAAASUVORK5CYII=" width="9" height="30"><img
    alt=" 19,A:{3},B:{3}" title=" 19,A:{3},B:{3}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/ADRgAMsAlQDS68kAAAAASUVORK5CYII=" width="9" height="30"><img
    alt=" 20,A:{4},B:{4}" title=" 20,A:{4},B:{4}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/ADYgAI8AVxcQlAsAAAAASUVORK5CYII=" width="9" height="30"><img
    alt=" 21,A:{5},B:{5}" title=" 21,A:{5},B:{5}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/ACNgAKkAhD/i5lYAAAAASUVORK5CYII=" width="9" height="30"><img
    alt=" 22,A:{6},B:{6}" title=" 22,A:{6},B:{6}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/ADFgAMUAksTlwtMAAAAASUVORK5CYII=" width="9" height="30"><img
    alt=" 23,A:{7},B:{7}" title=" 23,A:{7},B:{7}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/ABIgAEcAM15OsZIAAAAASUVORK5CYII=" width="9" height="30"><img
    alt=" 24,A:{8},B:{8}" title=" 24,A:{8},B:{8}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/ABZgAI8Ad3Mh6bwAAAAASUVORK5CYII=" width="9" height="30"><img
    alt=" 25,A:{9},B:{9}" title=" 25,A:{9},B:{9}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/ABpgAJcAex9glyQAAAAASUVORK5CYII=" width="9" height="30"><img
    alt=" 16,A:{0},B:{0}" title=" 16,A:{0},B:{0}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/AGJgAScAw0BJukMAAAAASUVORK5CYII=" width="9" height="30"><img
    alt=" 17,A:{1},B:{1}" title=" 17,A:{1},B:{1}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/AGMgAOkAhBjTObMAAAAASUVORK5CYII=" width="9" height="30"><img
    alt=" 18,A:{2},B:{2}" title=" 18,A:{2},B:{2}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/ADGgAQUA0nI/mr0AAAAASUVORK5CYII=" width="9" height="30"><img
    alt=" 19,A:{3},B:{3}" title=" 19,A:{3},B:{3}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/ADRgAMsAlQDS68kAAAAASUVORK5CYII=" width="9" height="30"><img
    alt=" 20,A:{4},B:{4}" title=" 20,A:{4},B:{4}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/ADYgAI8AVxcQlAsAAAAASUVORK5CYII=" width="9" height="30"><img
    alt=" 21,A:{5},B:{5}" title=" 21,A:{5},B:{5}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/ACNgAKkAhD/i5lYAAAAASUVORK5CYII=" width="9" height="30"><img
    alt=" 22,A:{6},B:{6}" title=" 22,A:{6},B:{6}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/ADFgAMUAksTlwtMAAAAASUVORK5CYII=" width="9" height="30"><img
    alt=" 23,A:{7},B:{7}" title=" 23,A:{7},B:{7}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/ABIgAEcAM15OsZIAAAAASUVORK5CYII=" width="9" height="30"><img
    alt=" 64,A:{NUL},B:{`}" title=" 64,A:{NUL},B:{`}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/AF5gAR8Av0A69KoAAAAASUVORK5CYII=" width="9" height="30"><img
    alt="106,{Stop}"title="106,{Stop}"src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAABAQMAAAA/57ZEAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/ADigARMA2dpJzT8AAAAASUVORK5CYII=" width="9" height="30">
    <p/>
    12345678901234567
&#13;
&#13;
&#13;

请注意,为每个字符指定尺寸,条形码通常扫描宽度为8或更高(取决于打印质量)。条形码中的所有字符都需要相同的宽度。请记住,您的水平静区是条宽的函数,因此请尽量在标签的每一侧保留至少两个字符宽度。