/// <summary> /// Add nested table with the specified number of columns and cellpadding /// </summary> /// <param name="inColumns">Number of columns</param> /// <param name="padding">Padding amount</param> /// <returns>Created PDFTable object</returns> public PDFTable AddTable(int inColumns, double padding) { PDFTable result = AddTable(inColumns); result.CellPadding = padding; return(result); }
public PagePos(PDFTable inTable) { mPageHeight = inTable.mDoc.MediaBox.Height; PosY = inTable.mDoc.Rect.Top; if (inTable.PageNumber == 0) { PageNr = 1; } else { PageNr = inTable.PageNumber; } }
/// <summary> /// Add nested table with the specified number of columns /// </summary> /// <param name="inColumns">Number of columns</param> /// <returns></returns> public PDFTable AddTable(int inColumns) { PageNumber = RowTop.PageNr; string theRect = mDoc.Rect.String; mDoc.Rect.Bottom = mBounds.Bottom; PDFTable nestedTable = new PDFTable(mDoc, inColumns); nestedTable.mParentTable = this; nestedTable.CellPadding = CellPadding; nestedTable.VerticalAlignment = VerticalAlignment; mDoc.Rect.String = theRect; return(nestedTable); }
public PdfDocument BuildDocument(ReportTextFieldCollection textFields, RenderHintsCollection hints, ReportRowCollection rows) { Document = hints.Orientation == ReportOrientation.Portrait ? new PdfDocument(ReportOrientation.Portrait) : new PdfDocument(); Document.Font = Document.AddFont("Helvetica"); Document.FontSize = 6; XRect docCoords = Document.Rect; double height = Document.Rect.Height; double width = Document.Rect.Width; Document.Rect.Inset(10, 40); Document.Rect.Height = Document.Rect.Height - 50; int fieldCount = 0; if (rows[0] != null) { fieldCount = rows[0].Fields.Count(f => f.Hidden == false); } var table = new PDFTable(Document, fieldCount) { CellPadding = 5, RepeatHeader = true }; if (hints.ContainsKey("PdfWidths")) { double[] widths = hints["PdfWidths"] as double[]; table.SetColumnWidths(widths); } foreach (ReportRow row in rows) { table.NextRow(); int cellIndex = 0; foreach (RowField field in row.Fields) { table.NextCell(); string cellHtml; if (row.RowType == ReportRowType.HeaderRow) { cellHtml = string.Format("<StyleRun FontSize=7><B><U>{0}</U></B></StyleRun>", field.HeaderText); } else { // TODO: Support DataRow styling, etc cellHtml = row.GetFormattedValue(field); } table.AddHtml(cellHtml); cellIndex++; } if (hints.ContainsKey("PdfUnderline")) { if (hints["PdfUnderline"] as bool? == true) { table.UnderlineRow("800 800 800", table.Row); } } } // HEADER Document.Rect.Position(10, height - 90); Document.Rect.Height = 80; Document.Rect.Width = width; for (int i = 1; i <= Document.PageCount; i++) { Document.PageNumber = i; Document.AddHtml(string.Format("<h3 align='center'>{0}</h3>", textFields.Title.FormatHtml())); Document.AddHtml(string.Format("<h5 align='center'>{0}</h5>", textFields.SubTitle.FormatHtml())); Document.AddHtml(string.Format("<p><b>{0}</b></p>", textFields.Header.FormatHtml())); } // TODO: Support for sub-totals on each page, for columns that ask for totals // TODO: Need to add support for the Report Footer text, currently only supports page numbers // FOOTER if (hints.IncludePageNumbers) { Document.Rect.Position(10, Document.MediaBox.Bottom); Document.Rect.Height = 30; Document.Rect.Width = width; Document.HPos = 0.5; Document.VPos = 0.5; for (int i = 1; i <= Document.PageCount; i++) { //Document.AddBookmark("Page " + i.ToString(), true); Document.PageNumber = i; Document.AddText(string.Format("Page {0} of {1}", i, Document.PageCount)); } } for (int i = 1; i <= Document.PageCount; i++) { Document.PageNumber = i; Document.Flatten(); } return(Document); }