private void ReportHeader(PdfPTable headingtable, Image gif, RetailSaleInquiryDetailReport 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, "Retail Sale Inquiry Detail", 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);
        }
        public bool CreateReport(ReportObject.RetailSaleListing RetailSaleListingData,
                                 ReportObject.RetailSaleCustomer RetailSaleCustomerData,
                                 List <ReportObject.RetailSaleMerchandise> RetailSaleMerchandiseList,
                                 List <ReportObject.RetailSaleTender> RetailSaleTenderList,
                                 List <ReportObject.RetailSaleHistory> RetailSaleHistoryList)
        {
            bool isSuccessful = false;

            iTextSharp.text.Document document = new iTextSharp.text.Document(PageSize.LETTER.Rotate());
            try
            {
                //set up RunReport event overrides & create doc
                _pageCount = 1;
                RetailSaleInquiryDetailReport 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(-75, document.PageSize.Width + 76);

                //set up tables, etc...
                PdfPCell cell = new PdfPCell();
                Image    gif  = Image.GetInstance(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(ReportObject.ReportTitle + ": " + DateTime.Now.ToString("MM/dd/yyyy"));

                PdfPTable customerTable = new PdfPTable(12);
                customerTable.WidthPercentage = 100;// document.PageSize.Width;
                WriteRetailSaleCustomerSectionHeader(customerTable, RetailSaleCustomerData);
                WriteRetailSaleCustomerSection(customerTable, 12, RetailSaleCustomerData);
                columns.AddElement(customerTable);

                PdfPTable transactionDetailTable = new PdfPTable(12);
                transactionDetailTable.WidthPercentage = 100;// document.PageSize.Width;
                WriteRetailSaleTransactionDetailSectionHeader(transactionDetailTable, RetailSaleListingData);
                WriteRetailSaleTransactionDetailSection(transactionDetailTable, 12, RetailSaleListingData, RetailSaleTenderList);
                columns.AddElement(transactionDetailTable);

                PdfPTable merchandiseTable = new PdfPTable(12);
                merchandiseTable.WidthPercentage = 100;// document.PageSize.Width;
                WriteRetailSaleMerchandiseSectionHeader(merchandiseTable, RetailSaleMerchandiseList);
                WriteRetailSaleMerchandiseSection(merchandiseTable, 12, RetailSaleMerchandiseList);
                columns.AddElement(merchandiseTable);

                PdfPTable retailSaleHistoryTable = new PdfPTable(12);
                retailSaleHistoryTable.WidthPercentage = 100;// document.PageSize.Width;
                WriteRetailSaleHistorySectionHeader(retailSaleHistoryTable, RetailSaleHistoryList);
                WriteRetailSaleHistorySectionColumnHeaders(retailSaleHistoryTable, RetailSaleHistoryList);
                WriteRetailSaleHistorySection(retailSaleHistoryTable, 12, RetailSaleHistoryList);
                columns.AddElement(retailSaleHistoryTable);

                //here add detail
                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);
        }