目前,我正在编写一个标签写入器(Brother QL-570,如果重要的话,用 Java)来打印具有不同 ID 的条码。条形码数据的长度可以从 ~17 个字符到 ~3 个字符不等。
但是,鉴于我已经正确理解了条形码概念,数据越多 - 条形码将变得越宽。
如果所有条形码都具有相同的恒定大小,我更喜欢:无论数据长度如何。 (条码不填标签就不好看,太大也不行)
当标签为固定尺寸(即 29mm x 90mm)时,如何处理? 您/您的公司是如何解决这个问题的?二维条码不是一种选择。可悲。
最佳答案
如果您必须并排比较不同宽度的条形码,这看起来会有点有趣,但我公司通过将每个符号定义为 1x??位图并将其缩放到应用程序所需的大小。例如,每个代码为 128 的符号,除了 Stop 之外,都是 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> </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
请注意,每个字符的尺寸都是指定的,条形码通常以 8 或更高的宽度扫描(取决于打印质量)。条码内的所有字符都需要相同的宽度。请记住,您的水平静区是条宽的函数,因此尽量在标签的每一侧保持至少两个字符宽度。
关于label - 如何实现条码宽度恒定;不管条码数据,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13768651/