Example #1
0
        internal RtfImage(string fileName, ImageFileType type)
        {
            _imgFname       = fileName;
            _imgType        = type;
            _alignment      = Align.None;
            _margins        = new Margins();
            KeepAspectRatio = true;
            _blockHead      = @"{\pard";
            _blockTail      = @"}";
            _startNewPage   = false;
            StartNewPara    = false;

            var image = Image.FromFile(fileName);

            _width  = image.Width / image.HorizontalResolution * 72;
            _height = image.Height / image.VerticalResolution * 72;

            using (var mStream = new MemoryStream())
            {
                image.Save(mStream, image.RawFormat);
                _imgByte = mStream.ToArray();
            }
        }
Example #2
0
        public RtfTable(int rowCount, int colCount, float horizontalWidth, float fontSize)
        {
            _fontSize           = fontSize;
            _alignment          = Align.None;
            _margins            = new Margins();
            RowCount            = rowCount;
            ColCount            = colCount;
            _representativeList = new List <RtfTableCell>();
            _startNewPage       = false;
            TitleRowCount       = 0;
            CellPadding         = new Margins[RowCount];
            if (RowCount < 1 || ColCount < 1)
            {
                throw new Exception("The number of rows or columns is less than 1.");
            }

            HeaderBackgroundColor = null;
            RowBackgroundColor    = null;
            RowAltBackgroundColor = null;

            // Set cell default width according to paper width
            _defaultCellWidth  = horizontalWidth / colCount;
            _cells             = new RtfTableCell[RowCount][];
            _rowHeight         = new float[RowCount];
            _rowKeepInSamePage = new bool[RowCount];
            for (var i = 0; i < RowCount; i++)
            {
                _cells[i]             = new RtfTableCell[ColCount];
                _rowHeight[i]         = 0F;
                _rowKeepInSamePage[i] = false;
                CellPadding[i]        = new Margins();
                for (var j = 0; j < ColCount; j++)
                {
                    _cells[i][j] = new RtfTableCell(_defaultCellWidth, i, j, this);
                }
            }
        }