private void ReportHeader(PdfPTable headingtable, Image gif, CostRevisionReport pageEvent, int colspan) { PdfPCell cell = new PdfPCell(); //row 1 cell = new PdfPCell(gif); cell.Border = Rectangle.NO_BORDER; cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.VerticalAlignment = Element.ALIGN_TOP; cell.Colspan = 8; headingtable.AddCell(cell); WriteCell(headingtable, string.Empty, ReportFont, colspan, Element.ALIGN_LEFT, Element.ALIGN_TOP, Rectangle.NO_BORDER); //row 2 WriteCell(headingtable, DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString(), ReportFont, 8, Element.ALIGN_LEFT, Rectangle.NO_BORDER); WriteCell(headingtable, string.Empty, ReportFont, colspan, Element.ALIGN_LEFT, Element.ALIGN_TOP, Rectangle.NO_BORDER); WriteCell(headingtable, string.Empty, ReportFont, colspan, Element.ALIGN_LEFT, Element.ALIGN_TOP, Rectangle.NO_BORDER); WriteCell(headingtable, "Cost Revision Report", ReportFontHeading, 8, Element.ALIGN_CENTER, Rectangle.NO_BORDER); WriteCell(headingtable, string.Empty, ReportFont, colspan, Element.ALIGN_LEFT, Element.ALIGN_TOP, Rectangle.NO_BORDER); WriteCell(headingtable, string.Empty, ReportFont, colspan, Element.ALIGN_LEFT, Element.ALIGN_TOP, Rectangle.NO_BORDER); //row 5 WriteCell(headingtable, "ICN:", ReportFontBold, 1, Element.ALIGN_RIGHT, Element.ALIGN_TOP, Rectangle.NO_BORDER); WriteCell(headingtable, _icn, ReportFontBold, 1, Element.ALIGN_LEFT, Element.ALIGN_TOP, Rectangle.NO_BORDER); WriteCell(headingtable, "Description:", ReportFontBold, 1, Element.ALIGN_RIGHT, Element.ALIGN_TOP, Rectangle.NO_BORDER); WriteCell(headingtable, _description, ReportFontBold, 4, Element.ALIGN_LEFT, Element.ALIGN_TOP, Rectangle.NO_BORDER); WriteCell(headingtable, string.Empty, ReportFont, 1, Element.ALIGN_LEFT, Element.ALIGN_TOP, Rectangle.NO_BORDER); //Write Columns //ReportColumns(headingtable); }
public bool CreateReport(String icn, String description, System.Data.DataSet theData) { _icn = icn; _description = description; bool isSuccessful = false; iTextSharp.text.Document document = new iTextSharp.text.Document(PageSize.LETTER.Rotate()); try { //set up RunReport event overrides & create doc _pageCount = 1; CostRevisionReport events = this; PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(ReportObject.ReportTempFileFullName, FileMode.Create)); writer.PageEvent = events; MultiColumnText columns = new MultiColumnText(document.PageSize.Top - 100, document.PageSize.Height - (50)); float pageLeft = document.PageSize.Left; float pageright = document.PageSize.Right; columns.AddSimpleColumn(-150, document.PageSize.Width + 76); //set up tables, etc... PdfPTable table = new PdfPTable(8); table.WidthPercentage = 85;// document.PageSize.Width; PdfPCell cell = new PdfPCell(); Image gif = Image.GetInstance(Common.Properties.Resources.logo, BaseColor.WHITE); gif.ScalePercent(25); runReport = new RunReport(); document.Open(); document.SetPageSize(PageSize.LETTER.Rotate()); document.SetMargins(-100, -100, 10, 45); document.AddTitle(string.Format("{0}: {1}", ReportObject.ReportTitle, DateTime.Now.ToString("MM/dd/yyyy"))); ReportColumns(table); //here add detail WriteDetail(table, 8, theData); columns.AddElement(table); document.Add(columns); document.Close(); OpenFile(ReportObject.ReportTempFileFullName); //CreateReport(_icn, _description, theData); isSuccessful = true; } catch (DocumentException de) { ReportObject.ReportError = de.Message; ReportObject.ReportErrorLevel = (int)LogLevel.ERROR; } catch (IOException ioe) { ReportObject.ReportError = ioe.Message; ReportObject.ReportErrorLevel = (int)LogLevel.ERROR; } return(isSuccessful); }