예제 #1
0
        private void ReportHeader(PdfPTable headingtable, Image gif, InventoryChargeOffReport pageEvent)
        {
            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             = 5;
            headingtable.AddCell(cell);

            //row 2
            Phrase dateLabelPhrase = new Phrase("Date:", ReportFontBold);
            Phrase spacePhrase     = new Phrase(new Chunk(" ") + "", ReportFont);
            Phrase datePhrase      = new Phrase(DateTime.Now.ToShortDateString(), ReportFontBold);

            dateLabelPhrase.Add(spacePhrase);
            dateLabelPhrase.Add(datePhrase);
            cell        = new PdfPCell();
            cell.Border = Rectangle.NO_BORDER;
            cell.HorizontalAlignment = Element.ALIGN_LEFT;
            cell.VerticalAlignment   = Element.ALIGN_TOP;
            cell.Colspan             = 2;
            cell.AddElement(dateLabelPhrase);
            headingtable.AddCell(cell);


            //WriteCell(headingtable, "Date:", ReportFontBold, 1, Element.ALIGN_LEFT, Element.ALIGN_TOP, Rectangle.NO_BORDER);
            //WriteCell(headingtable, "4/27/2011", ReportFont, 1, Element.ALIGN_LEFT, Element.ALIGN_TOP, Rectangle.NO_BORDER);
            WriteCell(headingtable, string.Empty, ReportFont, 1, Element.ALIGN_LEFT, Element.ALIGN_TOP, Rectangle.NO_BORDER);
            WriteCell(headingtable, "Charge Off#:", ReportFontBold, 1, Element.ALIGN_RIGHT, Element.ALIGN_TOP, Rectangle.NO_BORDER);
            WriteCell(headingtable, pageEvent.ReportObject.InventoryChargeOffFields.ChargeOffNumber, ReportFont, 1, Element.ALIGN_LEFT, Element.ALIGN_TOP, Rectangle.NO_BORDER);

            //row 3
            WriteCell(headingtable, string.Empty, ReportFont, 1, Element.ALIGN_LEFT, Element.ALIGN_TOP, Rectangle.NO_BORDER);
            WriteCell(headingtable, "INVENTORY CHARGE OFF", ReportFontHeading, 3, Element.ALIGN_CENTER, Element.ALIGN_TOP, Rectangle.NO_BORDER);
            WriteCell(headingtable, string.Empty, ReportFont, 1, Element.ALIGN_LEFT, Element.ALIGN_TOP, Rectangle.NO_BORDER);

            Phrase timeLabelPhrase = new Phrase("Time:", ReportFontBold);
            Phrase timePhrase      = new Phrase(DateTime.Now.ToShortTimeString(), ReportFont);

            timeLabelPhrase.Add(spacePhrase);
            timeLabelPhrase.Add(timePhrase);
            cell        = new PdfPCell();
            cell.Border = Rectangle.NO_BORDER;
            cell.HorizontalAlignment = Element.ALIGN_LEFT;
            cell.VerticalAlignment   = Element.ALIGN_TOP;
            cell.Colspan             = 2;
            cell.AddElement(timeLabelPhrase);
            headingtable.AddCell(cell);

            //WriteCell(headingtable, "Time:", ReportFontBold, 1, Element.ALIGN_LEFT, Element.ALIGN_TOP, Rectangle.NO_BORDER);
            //WriteCell(headingtable, "4:08 P.M", ReportFont, 1, Element.ALIGN_LEFT, Element.ALIGN_TOP, Rectangle.NO_BORDER);
            WriteCell(headingtable, string.Empty, ReportFont, 3, Element.ALIGN_LEFT, Element.ALIGN_TOP, Rectangle.NO_BORDER);
            WriteCell(headingtable, string.Empty, ReportFont, 5, Element.ALIGN_LEFT, Element.ALIGN_TOP, Rectangle.BOTTOM_BORDER);
            //row 4
            //WriteCell(headingtable, string.Empty, ReportFont, 5, Element.ALIGN_LEFT, Element.ALIGN_TOP, Rectangle.NO_BORDER);
            //DrawLine(headingtable);
        }
예제 #2
0
        public bool CreateReport(bool openFile)
        {
            var isSuccessful = false;

            //openFile = true; //comment out
            iTextSharp.text.Document document = new iTextSharp.text.Document(PageSize.HALFLETTER.Rotate());
            try
            {
                //set up RunReport event overrides & create doc
                InventoryChargeOffReport events = this;
                PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(ReportObject.ReportTempFileFullName, FileMode.Create));
                writer.PageEvent = events;

                MultiColumnText columns   = new MultiColumnText(document.PageSize.Top - 80, MultiColumnText.AUTOMATIC);
                float           pageLeft  = document.PageSize.Left;
                float           pageright = document.PageSize.Right;
                columns.AddSimpleColumn(1, document.PageSize.Width + 40);

                //set up tables, etc...
                PdfPTable table = new PdfPTable(5);
                table.WidthPercentage = 85;// document.PageSize.Width;
                PdfPCell cell = new PdfPCell();
                Image    gif  = Image.GetInstance(Resources.logo, BaseColor.WHITE);
                gif.ScalePercent(25);
                runReport = new RunReport();
                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")));

                //here add detail
                WriteDetail(table, 5);
                columns.AddElement(table);
                document.Add(columns);
                document.Close();
                if (openFile)
                {
                    OpenFile(ReportObject.ReportTempFileFullName);
                }

                //CreateReport(true); //comment out
                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);
        }