InvenTree 兼容 Brother-QL 的 62x27mm 库位标签模板
另请参阅本标签的大号版本(140x62mm)
这款 InvenTree 库位标签模板完全兼容 Brother 62mm QL 系列标签打印机。我在 Linux 上使用 BrotherQLLabelPrintService 来打印这些标签。

stock_location_62x27.html
{% extends "label/label_base.html" %}
{% load l10n i18n barcode %}
{% block style %}
{% localize off %}
@page {
size: {{ width }}mm {{ height }}mm;
margin: 2mm; /* 四周统一的 2mm 安全边距 */
}
body {
margin: 0;
padding: 0;
}
/* 表格布局确保精确定位,并修复 WeasyPrint 的多页 bug */
.label-table {
display: table;
width: calc({{ width }}mm - 4mm); /* 总宽度减去左右各 2mm 边距 */
height: calc({{ height }}mm - 4mm); /* 总高度减去上下各 2mm 边距 */
table-layout: fixed;
page-break-inside: avoid;
break-inside: avoid;
}
.label-row {
display: table-row;
}
.qr-cell {
display: table-cell;
width: calc({{ height }}mm - 4mm); /* 保持 QR 单元格为完美的正方形 */
height: calc({{ height }}mm - 4mm);
vertical-align: middle; /* 垂直居中 QR 码 */
}
.qr {
width: calc({{ height }}mm - 4mm);
height: calc({{ height }}mm - 4mm);
display: block;
}
.text-cell {
display: table-cell;
width: calc({{ width }}mm - {{ height }}mm); /* 动态填充剩余空间 */
height: calc({{ height }}mm - 4mm);
vertical-align: middle; /* 完美垂直居中 */
padding-left: 3mm; /* QR 码与文字之间的清晰间距 */
box-sizing: border-box;
overflow: hidden;
}
{% endlocalize %}
.loc {
font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
line-height: 1.05;
margin: 0;
padding: 0;
/* 原生布局处理会遵循你的 UTF-8 软连字符 */
white-space: normal;
word-wrap: break-word;
overflow-wrap: break-word;
}
/* 自动字体调整步骤(从原始 21pt 缩小) */
.loc.large { font-size: 21pt; }
.loc.medium { font-size: 15pt; }
.loc.small { font-size: 11pt; }
{% endblock style %}
{% block content %}
<div class="label-table">
<div class="label-row">
<div class="qr-cell">
<img class='qr' alt="{% trans 'QR code' %}" src='{% qrcode qr_data %}'>
</div>
<div class="text-cell">
<div class="loc {% if location.name|length > 20 %}small{% elif location.name|length > 10 %}medium{% else %}large{% endif %}">
{{ location.name }}
</div>
</div>
</div>
</div>
{% endblock content %}Check out similar posts by category:
InvenTree
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow