Example #1
0
        IList <byte[]> IBarcodeGeneratorService.GetBarcodesBytes(BarcodesRequest barcodesRequest)
        {
            IList <byte[]> list = new List <byte[]>();

            barcodesRequest.Contents.ToList().ForEach(x =>
            {
                var bytes = BarCodeHelper.GetBarcodeImage(new BarcodeRequest()
                {
                    BackgroundColor = barcodesRequest.BackgroundColor,
                    ForegroundColor = barcodesRequest.ForegroundColor,
                    BarcodeType     = barcodesRequest.BarcodeType,
                    Height          = barcodesRequest.Height,
                    Width           = barcodesRequest.Width,
                    Margin          = barcodesRequest.Margin,
                    Content         = new BarcodeContent()
                    {
                        Content     = x.Content,
                        DisplayText = x.DisplayText
                    },
                    ImageFormat = barcodesRequest.ImageFormat
                });

                list.Add(bytes);
            });

            return(list);
        }
        public void Legacy_Barcodes()
        {
            var request = new BarcodesRequest
            {
                Contents = new List <BarcodeContent>
                {
                    new BarcodeContent {
                        Content = "005079500003995086", DisplayText = "005-07950-0003995086-58"
                    },
                    new BarcodeContent {
                        Content = "005079500003995087", DisplayText = "005-07950-0003995087-59"
                    }
                },
                Margin          = 0,
                Width           = 200,
                Height          = 35,
                BarcodeType     = "CODE_128",
                ForegroundColor = "Black",
                BackgroundColor = "White",
                ImageFormat     = "jpg",
                IsTextDisplay   = true
            };
            var response = _subjectUnderTest.GetBarcodesBytes(request);

            response.ShouldNotBeNull();
            response.Count.ShouldBe(2);

            string[] datas = Spire.Barcode.BarcodeScanner.Scan(new MemoryStream(response[0]));
            datas[0].ShouldBe("005079500003995086");

            datas = Spire.Barcode.BarcodeScanner.Scan(new MemoryStream(response[1]));
            datas[0].ShouldBe("005079500003995087");
        }