private void printFooter() { Boolean footer = parser.GetFooter(); if (footer == true) { XImage im = images.Get(PDFImages.Types.Footer);; gfx.DrawImage(im, new XPoint(OffsetLeft, pageHeight + OffsetTop - FooterImgHeight)); pageHeight -= FooterImgHeight; OffsetTop += FooterImgHeight; firstPage = true; } }
private void printRows() { PDFRow[] rows = parser.GetGridContent(); rows_stat = rows.Length; double[] rowColor; double[] border = RGBColor.GetColor(lineColor); double y = OffsetTop + headerHeight; bool cellsLined = false; XFont cf; int rowsOnPage = 0; for (int rowNum = 0; rowNum < rows.Length; rowNum++) { double x = OffsetLeft; PDFCell[] cells = rows[rowNum].GetCells(); if (rowNum % 2 == 0) { rowColor = RGBColor.GetColor(scaleOneColor); } else { rowColor = RGBColor.GetColor(scaleTwoColor); } rowsOnPage++; for (int colNum = 0; colNum < cells.Length; colNum++) { #region columnDrawing double height = cols[0][colNum].GetHeight() * LineHeight; double width = widths[colNum] * pageWidth / widthSum; String al = cells[colNum].GetAlign(); if (al.ToLower().Equals("")) { al = cols[0][colNum].GetAlign(); } String tp = cols[0][colNum].getType(); XRect cellIn = new XRect(); cellIn.Location = new XPoint(x, y); cellIn.Size = new XSize(width, LineHeight); gfx.DrawRectangle(new XSolidBrush(RGBColor.GetXColor(((!cells[colNum].GetBgColor().Equals("")) && (parser.GetProfile() == ColorProfile.FullColor)) ? RGBColor.GetColor(cells[colNum].GetBgColor()) : rowColor)), cellIn); if (cells[colNum].GetBold()) { if (cells[colNum].GetItalic()) { if (f4 == null) { f4 = createFont("Helvetica-BoldOblique", fontSize); } cf = f4; } else { if (f2 == null) { f2 = createFont("Helvetica-Bold", fontSize); } cf = f2; } } else if (cells[colNum].GetItalic()) { if (f3 == null) { f3 = createFont("Helvetica-Oblique", fontSize); } cf = f3; } else { cf = f1; } XTextFormatter text = new XTextFormatter(gfx); text.Font = cf; text.Text = textWrap(cells[colNum].GetValue(), width - 2 * CellOffset, cf); String label = textWrap(cells[colNum].GetValue(), width - 2 * CellOffset, cf); if (al.ToLower().Equals("left") == true) { text.Alignment = XParagraphAlignment.Left; } else { if (al.ToLower().Equals("right") == true) { text.Alignment = XParagraphAlignment.Right; } else { text.Alignment = XParagraphAlignment.Center; } } var checkbox_width = 15 / 2;//approxmatelly... if (tp.ToLower().Equals("ch")) { double ch_x = width / 2 - checkbox_width; double ch_y = LineHeight / 2 - checkbox_width; if (text.Text.ToLower().Equals("1") == true) { drawCheckbox(true, ch_x, ch_y, cellIn); } else { drawCheckbox(false, ch_x, ch_y, cellIn); } } else { if (tp.ToLower().Equals("ra")) { double ch_x = width / 2 - checkbox_width; double ch_y = LineHeight / 2 - checkbox_width; if (text.Text.ToLower().Equals("1") == true) { drawRadio(true, ch_x, ch_y, cellIn); } else { drawRadio(false, ch_x, ch_y, cellIn); } } else { double text_y = (LineHeight + f1.Size) / 2; XRect text_cell = new XRect(); text_cell.Size = new XSize(width - 2 * LineHeight / 5, gfx.MeasureString(text.Text, text.Font).Height); text_cell.Location = new XPoint(x + LineHeight / 5, y + (LineHeight - text_cell.Size.Height) / 1.7); text.DrawString(text.Text, text.Font, new XSolidBrush((!cells[colNum].GetTextColor().Equals("") && parser.GetProfile().Equals("full_color")) ? RGBColor.GetXColor(cells[colNum].GetTextColor()) : RGBColor.GetXColor(gridTextColor)), text_cell); } } x += width; #endregion } gfx.DrawLine(new XPen(RGBColor.GetXColor(border), BorderWidth), new XPoint(OffsetLeft, y), new XPoint(OffsetLeft + pageWidth, y)); y += LineHeight; gfx.DrawLine(new XPen(RGBColor.GetXColor(border), BorderWidth), new XPoint(OffsetLeft, y), new XPoint(OffsetLeft + pageWidth, y)); if (y + LineHeight - OffsetTop + footerHeight >= pageHeight) { var left = OffsetLeft; var top = OffsetTop + headerHeight; top = OffsetTop + headerHeight; gfx.DrawLine(new XPen(RGBColor.GetXColor(border), BorderWidth), new XPoint(left, top), new XPoint(left, top + rowsOnPage * LineHeight)); var widths = parser.GetWidths(); for (int colNum = 0; colNum < widths.Length; colNum++) { left += widths[colNum] * pageWidth / widthSum; gfx.DrawLine(new XPen(RGBColor.GetXColor(border), BorderWidth), new XPoint(left, top), new XPoint(left, top + rowsOnPage * LineHeight)); } newPage(); if (firstPage == true) { pageHeight += getHeaderImgHeight(); OffsetTop -= getHeaderImgHeight(); firstPage = false; } double imgHeight = 0; if (rows.Length - rowNum < rowsOnPage && parser.GetFooter()) { imgHeight = getFooterImgHeight(); } rowsOnPage = 0; headerPrint(); footerHeight += imgHeight; y = OffsetTop + headerHeight; } x = OffsetLeft; } f1 = createFont("Helvetica", fontSize); if (!cellsLined) { var left = OffsetLeft; var top = OffsetTop + headerHeight; top = OffsetTop + headerHeight; gfx.DrawLine(new XPen(RGBColor.GetXColor(border), BorderWidth), new XPoint(left, top), new XPoint(left, top + rowsOnPage * LineHeight)); var widths = parser.GetWidths(); for (int colNum = 0; colNum < widths.Length; colNum++) { left += widths[colNum] * pageWidth / widthSum; gfx.DrawLine(new XPen(RGBColor.GetXColor(border), BorderWidth), new XPoint(left, top), new XPoint(left, top + rowsOnPage * LineHeight)); } } }