public bool CreateReport() { bool isSuccessful = false; iTextSharp.text.Document document = new iTextSharp.text.Document(PageSize.HALFLETTER.Rotate()); try { //set up RunReport event overrides & create doc LayawayPickingSlip events = this; PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(ReportObject.ReportTempFileFullName, FileMode.Create)); writer.PageEvent = events; MultiColumnText columns = new MultiColumnText(document.PageSize.Top - 125, MultiColumnText.AUTOMATIC); columns.AddSimpleColumn(-30, document.PageSize.Width + 20); //set up tables, etc... PdfPTable table = new PdfPTable(7); table.WidthPercentage = 85;// document.PageSize.Width; var gif = Image.GetInstance(Resources.logo, BaseColor.WHITE); gif.ScalePercent(25); runReport = new LayawayRunReports(); document.Open(); document.SetPageSize(PageSize.HALFLETTER.Rotate()); document.SetMargins(-100, -100, 10, 45); document.AddTitle(string.Format("{0}: {1}", ReportObject.ReportTitle, DateTime.Now.ToString("MM/dd/yyyy"))); ReportDetail(table); columns.AddElement(table); document.Add(columns); document.Close(); //nnaeme //OpenFile(ReportObject.ReportTempFileFullName); //CreateReport(); 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); }
private void ReportHeader(PdfPTable headingtable, Image gif, LayawayPickingSlip pageEvent) { PdfPCell cell = new PdfPCell(); // heading - row 1 cell = new PdfPCell(gif); cell.Border = Rectangle.NO_BORDER; cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.VerticalAlignment = Element.ALIGN_TOP; cell.Colspan = 1; headingtable.AddCell(cell); cell = new PdfPCell(new Paragraph(string.Empty, ReportFont)); cell.Border = Rectangle.NO_BORDER; cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.VerticalAlignment = Element.ALIGN_TOP; cell.Colspan = 6; headingtable.AddCell(cell); // heading - row 2 -empty row cell = new PdfPCell(new Paragraph(string.Empty, ReportFont)); cell.Border = Rectangle.NO_BORDER; cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.VerticalAlignment = Element.ALIGN_TOP; cell.Colspan = 7; headingtable.AddCell(cell); //row 3 - date cell = new PdfPCell(new Paragraph(DateTime.Now.ToString("MM/dd/yyyy"), ReportFont)); cell.Border = Rectangle.NO_BORDER; cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.VerticalAlignment = Element.ALIGN_TOP; cell.Colspan = 6; headingtable.AddCell(cell); cell = new PdfPCell(new Phrase("Ticket #:" + pageEvent.ReportObject.CurrentLayaway.TicketNumber.ToString(), ReportFont)); cell.Border = Rectangle.NO_BORDER; cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.Colspan = 1; headingtable.AddCell(cell); // heading - row 11 //empty row cell = new PdfPCell(new Phrase(pageEvent.ReportObject.ReportTitle, ReportFontHeading)); cell.Border = Rectangle.NO_BORDER; cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.Colspan = 7; headingtable.AddCell(cell); // heading - row 12 //empty row cell = new PdfPCell(new Phrase("Employee #:" + pageEvent.ReportObject.ReportEmployee, ReportFont)); cell.Border = Rectangle.NO_BORDER; cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.Colspan = 7; headingtable.AddCell(cell); //draw line cell = new PdfPCell(new Phrase(StringUtilities.fillString("_", 140), ReportFont)); cell.Colspan = 7; cell.HorizontalAlignment = Rectangle.ALIGN_LEFT; cell.Border = Rectangle.NO_BORDER; headingtable.AddCell(cell); ColumnHeaders(headingtable); }