如何在 Crystal Reports 中使用 Interleaved 2 of 5 条码字体

问题描述 投票:0回答:1

我从https://grandzebu.net/informatique/codbar-en/code25I.htm下载了优秀的Interleaved 2 of 5字体并将其添加到Windows

我已经安装并启动了 Crystal Reports

我需要一个公式将数据转换为交错格式,因为如果我直接使用它,它不会添加开始和停止字符,并且当我扫描条形码(添加开始和停止字符后)时,它不会读取正确的数字。 (如果数据为“1234”,扫描仪将读取“16171819”,对应于ITF条码字符集图表)

我已经找到了解决方案,并希望将其记录在答案中以供其他人查找。如果可能,请改进答案,或者如果您有更好的解决方案,请发布另一个答案。

crystal-reports
1个回答
0
投票

创建公式并添加以下内容:

StringVar Array patterns := [
      "!",chrW(34),"#","$","%","&","'","(",")","*","+",",","-",".","/","0","1","2","3","4","5","6","7","8","9",":",";","<","=",">","?","@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","[","\","]","^","_","`","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","{","|","}","~"," ","¡","¢","£","¤","¥","¦","§","¨","©","ª","«","¬","­","®","¯","°","±","²","³","´","µ","¶","·","¸","¹","º","»","¼","½","¾","¿","À","Á","Â","Ã","Ä","Å","Æ","Ç","È"
    ];
StringVar input := {YOUR_DATA_STRING}; 
StringVar barcode := "";

//Pad with zero if the number of digits is odd
If (Length(input) mod 2) = 1 Then
   input := "0" & input;

Local NumberVar i;
// Iterate through the input in pairs of digits and build the barcode string
For i := 1 To Length(input) Step 2 Do (
   StringVar digitPair := Mid(input, i, 2);
   NumberVar pairIndex := Val(digitPair); // Converts the pair of digits to a number
   barcode := barcode + patterns[pairIndex + 1]; // Add 1 because arrays are 1-indexed in Crystal Reports
);
    
// Add start/stop characters
barcode := "É" + barcode + "Ê";

barcode
© www.soinside.com 2019 - 2024. All rights reserved.