예제 #1
0
        private void Create(SvgImage image, BitMatrix matrix, BarcodeFormat format, string content, EncodingOptions options)
        {
            const int quietZone = 5;

            if (matrix == null)
            {
                return;
            }

            int width  = matrix.Width;
            int height = matrix.Height;

            image.AddHeader();
            image.AddTag(0, 0, 2 * quietZone + width, 2 * quietZone + height, Background, Foreground);
            AppendDarkCell(image, matrix, quietZone, quietZone);
            image.AddEnd();
        }
예제 #2
0
        private void Create(SvgImage image, BitMatrix matrix, BarcodeFormat format, string content, EncodingOptions options)
        {
            if (matrix == null)
            {
                return;
            }

            const int spaceBetweenMatrixAndText = 3;
            int       width         = matrix.Width;
            int       height        = matrix.Height;
            var       outputContent = (options == null || !options.PureBarcode) &&
                                      !String.IsNullOrEmpty(content) &&
                                      (format == BarcodeFormat.CODE_39 ||
                                       format == BarcodeFormat.CODE_93 ||
                                       format == BarcodeFormat.CODE_128 ||
                                       format == BarcodeFormat.EAN_13 ||
                                       format == BarcodeFormat.EAN_8 ||
                                       format == BarcodeFormat.CODABAR ||
                                       format == BarcodeFormat.ITF ||
                                       format == BarcodeFormat.UPC_A ||
                                       format == BarcodeFormat.UPC_E ||
                                       format == BarcodeFormat.MSI ||
                                       format == BarcodeFormat.PLESSEY);

            if (outputContent)
            {
                var fontSize = FontSize < 1 ? DefaultFontSize : FontSize;
                height += fontSize + spaceBetweenMatrixAndText;
            }

            image.AddHeader();
            image.AddTag(0, 0, width, height, Background, Foreground);
            AppendDarkCell(image, matrix, 0, 0);

            if (outputContent)
            {
                var fontName = String.IsNullOrEmpty(FontName) ? DefaultFontName : FontName;
                var fontSize = FontSize < 1 ? DefaultFontSize : FontSize;

                content = ModifyContentDependingOnBarcodeFormat(format, content);

                image.AddText(content, fontName, fontSize);
            }

            image.AddEnd();
        }