private double printColumn(PDFColumn column, double[] bg, double[] border, double x, double y)
        {
            double width  = column.GetWidth() * pageWidth / widthSum;
            double height = column.GetHeight() * HeaderLineHeight;

            if (height > 0 && width > 0)
            {
                XRect cellIn = new XRect();
                cellIn.Location = new XPoint(x, y);
                cellIn.Size     = new XSize(width, height);

                gfx.DrawRectangle(new XSolidBrush(RGBColor.GetXColor(bg)), cellIn);

                String label  = textWrap(column.GetName(), width - 2 * CellOffset, f1);
                double text_x = x + (width - gfx.MeasureString(label, f1).Width) / 2;

                double text_y = y + (height + f1.Size) / 2;
                gfx.DrawString(label, f1, new XSolidBrush(RGBColor.GetXColor(headerTextColor)), new XPoint(text_x, text_y));

                var points = new XPoint[4];
                points[0] = new XPoint(x + width, y + height);
                points[1] = new XPoint(x + width, y);
                points[2] = new XPoint(x, y);
                points[3] = new XPoint(x, y + height);
                gfx.DrawLine(new XPen(RGBColor.GetXColor(border), BorderWidth), points[0], points[1]);
                gfx.DrawLine(new XPen(RGBColor.GetXColor(border), BorderWidth), points[1], points[2]);
                gfx.DrawLine(new XPen(RGBColor.GetXColor(border), BorderWidth), points[2], points[3]);
                gfx.DrawLine(new XPen(RGBColor.GetXColor(border), BorderWidth), points[3], points[0]);
            }
            return(width);
        }
        public PDFColumn[][] GetHeaderInfo()
        {
            PDFColumn[] colLine = null;
            XmlNodeList n1      = root.GetElementsByTagName("columns");

            if ((n1 != null) && (n1.Count > 0))
            {
                columns = new PDFColumn[n1.Count][];
                for (int i = 0; i < n1.Count; i++)
                {
                    XmlElement  cols = (XmlElement)n1[i];
                    XmlNodeList n2   = cols.GetElementsByTagName("column");
                    if ((n2 != null) && (n2.Count > 0))
                    {
                        colLine = new PDFColumn[n2.Count];
                        for (int j = 0; j < n2.Count; j++)
                        {
                            XmlElement col_xml = (XmlElement)n2[j];
                            PDFColumn  col     = new PDFColumn();
                            col.Parse(col_xml);
                            colLine[j] = col;
                        }
                    }
                    columns[i] = colLine;
                }
            }
            createWidthsArray();
            optimizeColumns();
            return(columns);
        }
        private void headerPrint()
        {
            if (cols == null)
            {
                cols   = parser.GetHeaderInfo();
                widths = parser.GetWidths();
                for (int i = 0; i < cols[0].Length; i++)
                {
                    widthSum += cols[0][i].GetWidth();
                }
            }

            cols_stat = cols.Length;

            double[] bg     = RGBColor.GetColor(bgColor);
            double[] border = RGBColor.GetColor(lineColor);
            double   x      = OffsetLeft;
            double   y      = OffsetTop;
            int      lines  = 0;

            for (int row = 0; row < cols.Length; row++)
            {
                x = OffsetLeft;
                if (cols[row][0].IsFooter())
                {
                    continue;
                }
                for (int j = 0; j < cols[row].Length; j++)
                {
                    PDFColumn column = cols[row][j];

                    x += printColumn(column, bg, border, x, y);
                }
                y += HeaderLineHeight;
                lines++;
            }

            headerHeight = lines * HeaderLineHeight;
            footerHeight = (cols.Length - lines) * HeaderLineHeight;
            y            = pageHeight - headerHeight - footerHeight;
            y            = Math.Floor(y / LineHeight) * LineHeight + OffsetTop + headerHeight;

            for (int i = 0; i < cols.Length; i++)
            {
                if (!cols[i][0].IsFooter())
                {
                    continue;
                }
                x = OffsetLeft;
                for (int j = 0; j < cols[i].Length; j++)
                {
                    PDFColumn column = cols[i][j];
                    x += printColumn(column, bg, border, x, y);
                }
                y += HeaderLineHeight;
            }
        }