Пример #1
0
        private RectangleF RenderTableHeader(Font font, RectangleF rc, params string[] fields)
        {
            // calculate cell width (same for all columns)
            RectangleF rcCell = rc;

            rcCell.Width  = rc.Width / fields.Length;
            rcCell.Height = 0;

            // calculate cell height (max of all columns)
            foreach (string field in fields)
            {
                float height = PdfCotizacion.MeasureString(field, font, rcCell.Width).Height;
                rcCell.Height = Math.Max(rcCell.Height, height);
            }

            // render header cells
            StringFormat sf = new StringFormat();

            foreach (string field in fields)
            {
                sf.Alignment     = StringAlignment.Center;
                sf.LineAlignment = StringAlignment.Center;

                PdfCotizacion.FillRectangle(Brushes.Black, rcCell);
                PdfCotizacion.DrawString(field, font, Brushes.White, rcCell, sf);
                rcCell.Offset(rcCell.Width, 0);
            }

            // update rectangle and return it
            rc.Offset(0, rcCell.Height);
            return(rc);
        }