常见问题 TBarCode DLL / TBarCode Library
如何为 ITF-14 添加保护条(Bearer Bar)?
如何为 ITF-14 添加保护条(Bearer Bar)?
保护条的形状和尺寸取决于打印表面和应用场景。模块宽度、条码高度及保护条的可选尺寸可参见 GS1 规范图 5.3.6-1。
为保持最小静区为模块宽度的 10 倍,需要在考虑保护条尺寸的基础上,在 TBarCode API 中调整左右静区。
下面展示两种条码和保护条尺寸不同的情况:
顶部和底部保护条
如果使用标签(而非印刷版)打印,ITF-14 可以带有顶部和底部保护条。这种情况下保护条可以更小,但至少要达到模块宽度的 2 倍。
BCSetBCType(m_pbarCode, eBC_ITF14);
// #1 print on label
// 203 dpi ➞ Module Width = 0.5005 mm = 4 Pixel per Module
double const dModuleWidth = 0.5004926F; // use exact value
// 300/600/1200 dpi ➞ Module Width = 0.508 mm
// double const dModuleWidth = 0.508F;
BCSetModWidthN(m_pbarCode, dModuleWidth * 1000); // set in 0.001 mm units
double const dModulesBearerBar = 2.0F; // 2 times the module width
BCSetBearerBarType(m_pbarCode, eBearerBar_TopAndBottom);
BCSetBearerBarWidth(m_pbarCode, static_cast<int> (dModulesBearerBar * dModuleWidth * 1000)); // set in 0.001 mm units
RECTD QZRect = { 10, 0, 10, 0 };
BCSetQuietZone(m_pbarCode, &QZRect, eMUModules);
eCode = BCSetText(m_pbarCode, szText, szText.GetLength());
if (eCode == S_OK)
eCode = BCCreate(m_pbarCode); // create internal bar code structure (MUST)
矩形保护条
对于直接在纸箱上打印的情况,保护条必须为矩形并具有特定尺寸,此时条码尺寸也应相应放大。
// #2 print on carton
// for rectangular bearer bar having a width of 4.83 mm
// 203 dpi ➞ Module Width = 1.000 mm = 8 Pixel per Module
double const dModuleWidth = 1.0F;
// 300/600/1200 dpi ➞ Module Width = 1.016 mm
//double const dModuleWidth = 1.016F;
BCSetModWidthN(m_pbarCode, dModuleWidth * 1000); // set in 0.001 mm units
double dBearerBarWidth = 4.83F;
double dModulesBearerBar = ceil(dBearerBarWidth / dModuleWidth);
BCSetBearerBarType(m_pbarCode, eBearerBar_Rectangle);
BCSetBearerBarWidth(m_pbarCode, static_cast<int> (dBearerBarWidth * 1000)); // set in 0.001 mm units
RECTD QZRect = { 10 + dModulesBearerBar, 0, 10 + dModulesBearerBar, 0 };
BCSetQuietZone(m_pbarCode, &QZRect, eMUModules);