Код: public bool Print2DBarcode(string in_text) // Печать QR-кода { string DataHex = MySys.StringToHexString(in_text); byte block_size = 128; int block_count = (DataHex.Length + block_size - 1) / block_size; for (int i = 0; i < block_count; i++) { this.FR.BlockType = 0; this.FR.BlockNumber = i; this.FR.BlockDataHex = MySys.SubString(DataHex, i * block_size, block_size); this.FR.LoadBlockData(); } this.FR.BarcodeType = 3; this.FR.BarcodeDataLength = DataHex.Length / 2; this.FR.BarcodeStartBlockNumber = 0; this.FR.BarcodeParameter1 = 0; this.FR.BarcodeParameter2 = 0; this.FR.BarcodeParameter3 = 8; // Размер точки 0-8 this.FR.BarcodeParameter4 = 0; this.FR.BarcodeParameter5 = 0; this.FR.Print2DBarcode(); return true;// Report() == 0 }
public class MySys { public static string StringToHexString(string in_text) { byte[] ba = Encoding.UTF8.GetBytes(in_text); string hexString = BitConverter.ToString(ba); hexString = hexString.Replace("-", ""); return hexString; } public static string SubString(string in_text, int in_start, int in_length) { // Сделана эта функция, т.к. родная выдает исключение если длина вырезания превышает то, что можно вырезать return in_text.Substring(in_start, Math.Min(in_text.Length - in_start, in_length)); } }
|