Esempio n. 1
0
 /// <summary>
 /// 设置条形码
 /// </summary>
 /// <param name="value">值</param>
 /// <param name="options">条形码选项</param>
 public byte[] Barcode(string value, BarcodeOptions options)
 {
     Builder.Width(options.Width ?? BarcodeWidth.Thinnest)
     .Height(options.Height ?? 50)
     .LabelPosition(options.Position ?? BarcodePositionType.None)
     .LabelFontB(options.FontType ?? BarcodeFontType.B);
     return(Builder.Build(options.Type, value));
 }
Esempio n. 2
0
        private static BarcodeOptions GetBarcodeOptions(Match translatorMatch)
        {
            var options = new BarcodeOptions();

            if (!string.IsNullOrEmpty(translatorMatch.Groups[2].Value))
            {
                options = JsonConvert.DeserializeObject <BarcodeOptions>(translatorMatch.Groups[2].Value);
            }

            return(options);
        }
Esempio n. 3
0
        static async Task CreateQRCode()
        {
            var options = new BarcodeOptions
            {
                Type           = "QRCode",
                Content        = "https://cn.etsoo.com/",
                ForegroundText = "#3f51b5",
                Width          = 600,
                Height         = 600
            };

            using var stream = File.Create("D:\\test.png");
            await BarcodeUtils.CreateAsync(stream, options);

            Console.Write("QRCode created");
        }
        public async Task TestQRCode(string content, string charset, int width, int height, int margin)
        {
            var opts = new BarcodeOptions()
            {
                Width   = width,
                Height  = height,
                Margin  = margin,
                Content = content,
                Charset = charset,
                Alt     = "test",
            };
            var resp = await this._client.PostAsJsonAsync("/home/qr_code", opts);

            //var resp = this._client.GetAsync("/home/index?").Result;
            Assert.Equal(HttpStatusCode.OK, resp.StatusCode);
            var respContent = await resp.Content.ReadAsStringAsync();

            var parser = new HtmlParser();
            var doc    = parser.ParseDocument(respContent);
            var img    = doc.QuerySelector("img");

            Assert.Equal(Convert.ToInt32(img.GetAttribute("width")), opts.Width);
            Assert.Equal(Convert.ToInt32(img.GetAttribute("height")), opts.Height);
        }
Esempio n. 5
0
 protected EanEncoder(BarcodeOptions options) : base(options)
 {
 }
Esempio n. 6
0
 public IActionResult Code_128([FromBody] BarcodeOptions barcodeOptions)
 {
     return(View(barcodeOptions));
 }
Esempio n. 7
0
 public Ean13Encoder(BarcodeOptions options) : base(options)
 {
 }
Esempio n. 8
0
 public UpcaEncoder(BarcodeOptions options) : base(options)
 {
 }
Esempio n. 9
0
 protected Encoder(BarcodeOptions options)
 {
     Options = options;
 }
Esempio n. 10
0
 /// <summary>
 /// 设置条形码
 /// </summary>
 /// <param name="value">值</param>
 /// <param name="options">条形码选项</param>
 public TPrinter Barcode(string value, BarcodeOptions options) => Write(Command.Barcode.Barcode(value, options));