Exemplo n.º 1
0
        public void Validate()
        {
            if (_pageSize == null)
            {
                throw new BarcodeSheetException("Pagesize cannot be null");
            }
            if (_codes == null || _codes.Count == 0)
            {
                throw new BarcodeSheetException("Codes count must be greater than 0");
            }
            if (_column < 1)
            {
                throw new BarcodeSheetException("Column count must be greater than 0");
            }
            if (_row < 1)
            {
                throw new BarcodeSheetException("Row count must be greater than 0");
            }
            if (_columnPercentWidth != null && _columnPercentWidth.Length != _column)
            {
                throw new BarcodeSheetException("Column count and percentage distribution of columns must be the same size");
            }
            if (_columnPercentWidth != null && _columnPercentWidth.Sum() != 100)
            {
                throw new BarcodeSheetException("Sum of column percentage width must be 100");
            }

            if (_sheetMargin != null)
            {
                _sheetMargin.Validate();
            }
            else
            {
                _sheetMargin = new SheetMargin();
            }

            if (_barcodeHeight > 86.5f && _withBarcodeText)
            {
                _barcodeHeight = 86.5f;
            }

            if (_columnPercentWidth == null)
            {
                float tableWith = 100f / (float)_column;
                _columnPercentWidth = Enumerable.Repeat(tableWith, _column).ToArray();
            }

            _codes.AddRange(Enumerable.Repeat("", _codes.Count % _column).ToArray());
        }
Exemplo n.º 2
0
 /// <summary>
 /// Set the page margins in mm
 /// </summary>
 /// <param name="left"></param>
 /// <param name="right"></param>
 /// <param name="top"></param>
 /// <param name="bottom"></param>
 /// <returns></returns>
 public BarcodeSheetBuilder SetPageMargins(float left, float right, float top, float bottom)
 {
     _sheetMargin = new SheetMargin(MMToPixel(left), MMToPixel(right), MMToPixel(top), MMToPixel(bottom));
     return(this);
 }