コード例 #1
0
        //public override void OnEndPage(PdfWriter writer, Document document) {

        //    String text = "Page " + writer.PageNumber.ToString();
        //    float len = bf.GetWidthPoint(text, 8);
        //    cb.BeginText();
        //    cb.SetFontAndSize(bf, 8);
        //    cb.SetTextMatrix(280, 30);
        //    cb.ShowText(text);
        //    cb.EndText();

        //    base.OnEndPage(writer, document);

        //    //int pageN = writer.PageNumber;
        //    ////string text = "Page " + pageN + " of ";
        //    //string text = "Page " + pageN;
        //    //float len = bf.GetWidthPoint(text, 8);
        //    //cb.BeginText();
        //    //cb.SetFontAndSize(bf, 8);
        //    //cb.SetTextMatrix(300, 30);
        //    //cb.ShowText(text);
        //    //cb.EndText();
        //    //cb.AddTemplate(template, 300 + len, 30);

        //    //base.OnEndPage(writer, document);
        //}

        // Used to supply end of document values to template.
        //public override void OnCloseDocument(PdfWriter writer, Document document) {

        //    // add template text to document here.
        //    template.BeginText();
        //    template.SetFontAndSize(bf, 8);
        //    template.ShowText((writer.PageNumber - 1).ToString());
        //    template.EndText();

        //    base.OnCloseDocument(writer, document);
        //}

        public override void OnStartPage(PdfWriter writer, Document document)
        {
            if (!_isDocumentClosing)
            {
                // ===========================================================================
                // Create header column -- in this report this is the page's column object
                // ===========================================================================
                ct.SetSimpleColumn(PortraitPageSize.HdrLowerLeftX, PortraitPageSize.HdrLowerLeftY,
                                   PortraitPageSize.HdrUpperRightX, PortraitPageSize.HdrUpperRightY,
                                   PortraitPageSize.PgLeading, Element.ALIGN_CENTER);
                ct.YLine = PortraitPageSize.HdrTopYLine;

                // We need a greyed (hidden) header having Trans# in the far left corner and Contract# in the far right corner.
                PdfPTable table = PdfReports.CreateTable(_headerLayout, 0);

                // Line 1
                PdfReports.AddText2Table(table, DateTime.Now.ToShortDateString(), _subNormalFont);

                PdfReports.AddText2Table(table, "Western Sugar Cooperative\n" +
                                         "Contract/Delivery Summary\n" +
                                         "Crop Year " + _cropYear, _titleFont, "center");

                PdfReports.AddImage2Table(table, _imgLogo);

                PdfReports.AddText2Table(table, " ", _normalFont, _headerLayout.Length);
                PdfReports.AddText2Table(table, " ", _normalFont, _headerLayout.Length);
                PdfReports.AddText2Table(table, " ", _normalFont, _headerLayout.Length);

                PdfReports.AddTableNoSplit(document, this, table);
                _headerBottomYLine = ct.YLine;
            }

            base.OnStartPage(writer, document);
        }
コード例 #2
0
        public override void OnStartPage(PdfWriter writer, Document document)
        {
            if (!_isDocumentClosing)
            {
                // ===========================================================================
                // Create header column -- in this report this is the page's column object
                // ===========================================================================
                _ct.SetSimpleColumn(PortraitPageSize.HdrLowerLeftX, PortraitPageSize.HdrLowerLeftY,
                                    PortraitPageSize.HdrUpperRightX, PortraitPageSize.HdrUpperRightY,
                                    PortraitPageSize.PgLeading, Element.ALIGN_TOP);
                _ct.YLine = PortraitPageSize.HdrTopYLine;

                // =======================================================
                // Add Header
                // =======================================================
                float[]   layout = new float[] { 413F, 127F };
                PdfPTable table  = PdfReports.CreateTable(layout, 0);
                PdfReports.AddText2Table(table, _title + "\n", titleFont, "center");
                PdfReports.AddImage2Table(table, _imgLogo);
                PdfReports.AddText2Table(table, " ", normalFont, table.NumberOfColumns);
                PdfReports.AddText2Table(table, " ", normalFont, table.NumberOfColumns);

                PdfReports.AddText2Table(table, "SHID: " + _shid, labelFont, "left", 2);
                PdfReports.AddText2Table(table, _payeeName, labelFont, "left", 2);
                PdfReports.AddText2Table(table, " ", normalFont, table.NumberOfColumns);

                PdfReports.AddTableNoSplit(document, this, table);

                PdfPTable hdrTab = PdfReports.CreateTable(_hdrTableLayout, 0);
                PdfReports.AddText2Table(hdrTab, _hdrNameList[0], labelFont, "center");
                PdfReports.AddText2Table(hdrTab, _hdrNameList[1], labelFont, "center");
                PdfReports.AddText2Table(hdrTab, _hdrNameList[2], labelFont, "center");
                PdfReports.AddText2Table(hdrTab, _hdrNameList[3], labelFont, "center");
                PdfReports.AddText2Table(hdrTab, _hdrNameList[4], labelFont, "center");
                PdfReports.AddText2Table(hdrTab, _hdrNameList[5], labelFont, "center");
                PdfReports.AddText2Table(hdrTab, _hdrNameList[6], labelFont, "center");

                PdfReports.AddTableNoSplit(document, this, hdrTab);

                _headerBottomYLine = _ct.YLine;
            }

            base.OnStartPage(writer, document);
        }
コード例 #3
0
        // we override the onEndPage method
        //public override void OnEndPage(PdfWriter writer, Document document) {

        //    String text = "Page " + _pageNumber.ToString();
        //    float len = _bf.GetWidthPoint(text, 8);
        //    _cb.BeginText();
        //    _cb.SetFontAndSize(_bf, 8);
        //    _cb.SetTextMatrix(280, 30);
        //    _cb.ShowText(text);
        //    _cb.EndText();

        //    base.OnEndPage(writer, document);
        //}

        public override void OnStartPage(PdfWriter writer, Document document)
        {
            if (!_isDocumentClosing)
            {
                _pageNumber++;

                // ===========================================================================
                // Create header column -- in this report this is the page's column object
                // ===========================================================================
                _ct.SetSimpleColumn(PortraitPageSize.HdrLowerLeftX, PortraitPageSize.HdrLowerLeftY,
                                    PortraitPageSize.HdrUpperRightX, PortraitPageSize.HdrUpperRightY,
                                    PortraitPageSize.PgLeading, Element.ALIGN_CENTER);
                _ct.YLine = PortraitPageSize.HdrTopYLine;

                // =======================================================
                // Add Header
                // =======================================================
                float[]   wscLogoLayout = new float[] { 60, 353F, 127F };
                PdfPTable logoTable     = PdfReports.CreateTable(wscLogoLayout, 0);

                PdfReports.AddText2Table(logoTable, _statementDate, _normalFont);
                PdfReports.AddText2Table(logoTable, _title, _titleFont, "center");

                // Only add actual logo on First page of set.
                if (_pageNumber == 1)
                {
                    PdfReports.AddImage2Table(logoTable, _imgLogo);
                }
                else
                {
                    PdfReports.AddText2Table(logoTable, " ", _normalFont);
                }
                PdfReports.AddText2Table(logoTable, " \n \n ", _titleFont, wscLogoLayout.Length);
                PdfReports.AddTableNoSplit(document, this, logoTable);

                _headerBottomYLine = _ct.YLine;
            }

            base.OnStartPage(writer, document);
        }
コード例 #4
0
        public override void OnStartPage(PdfWriter writer, Document document)
        {
            if (!_isDocumentClosing)
            {
                bool isNewArea = false;

                if (_pageNumber == 0 || _lastShid != _shid)
                {
                    _pageNumber     = 0;
                    _lastPageNumber = 0;
                    _lastShid       = _shid;

                    isNewArea     = true;
                    _lastAreaName = _areaName;

                    _template = _cb.CreateTemplate(PortraitPageSize.HdrUpperRightX - PortraitPageSize.HdrLowerLeftX, 50);
                }
                if (_lastAreaName != _areaName)
                {
                    isNewArea     = true;
                    _lastAreaName = _areaName;
                }

                _pageNumber++;

                // ===========================================================================
                // Create header column -- in this report this is the page's column object
                // ===========================================================================
                _ct.SetSimpleColumn(PortraitPageSize.HdrLowerLeftX, PortraitPageSize.HdrLowerLeftY,
                                    PortraitPageSize.HdrUpperRightX, PortraitPageSize.HdrUpperRightY,
                                    PortraitPageSize.PgLeading, Element.ALIGN_TOP);
                _ct.YLine = PortraitPageSize.HdrTopYLine;

                // =======================================================
                // Add Report Header
                // =======================================================
                PdfPTable table = PdfReports.CreateTable(_headerLayout, 0);

                PdfReports.AddText2Table(table, " ", _normalFont, table.NumberOfColumns);

                PdfReports.AddText2Table(table, DateTime.Now.ToShortDateString(), _normalFont);
                PdfReports.AddText2Table(table, _rptTitle, _titleFont, "center");
                if (isNewArea)
                {
                    PdfReports.AddImage2Table(table, _imgLogo);
                }
                else
                {
                    PdfReports.AddText2Table(table, " ", _normalFont);
                }

                //---------------------------------------
                // SHID
                //---------------------------------------
                Paragraph para   = new Paragraph("", _normalFont);
                Phrase    phrase = new Phrase("SHID: ", _labelFont);
                para.Add(phrase);
                phrase = new Phrase(_shid.ToString(), _normalFont);
                para.Add(phrase);
                PdfReports.AddText2Table(table, para);

                //---------------------------------------
                // BUSINESS NAME
                //---------------------------------------
                para   = new Paragraph("", _normalFont);
                phrase = new Phrase("Name: ", _labelFont);
                para.Add(phrase);
                phrase = new Phrase(_busName, _labelFont);
                para.Add(phrase);
                PdfReports.AddText2Table(table, para, 2);

                //---------------------------------------
                // REGION NAME
                //---------------------------------------
                para   = new Paragraph("", _normalFont);
                phrase = new Phrase("Region: ", _labelFont);
                para.Add(phrase);
                phrase = new Phrase(_regionName, _normalFont);
                para.Add(phrase);
                PdfReports.AddText2Table(table, para);

                //---------------------------------------
                // AREA NAME
                //---------------------------------------
                para   = new Paragraph("", _normalFont);
                phrase = new Phrase("Area: ", _labelFont);
                para.Add(phrase);
                phrase = new Phrase(_areaName, _normalFont);
                para.Add(phrase);
                PdfReports.AddText2Table(table, para, 2);

                PdfReports.AddText2Table(table, " ", _normalFont, table.NumberOfColumns);
                PdfReports.AddText2Table(table, " ", _normalFont, table.NumberOfColumns);
                PdfReports.AddTableNoSplit(document, this, table);

                if (_contractTableLayout != null)
                {
                    BuildContractDumpHeader(document, _contractTableLayout);       // this routine adds table to document
                }

                _headerBottomYLine = _ct.YLine;
            }

            base.OnStartPage(writer, document);
        }
コード例 #5
0
        public override void OnStartPage(PdfWriter writer, Document document)
        {
            if (!_isDocumentClosing)
            {
                _pageNumber++;

                if (_pageNumber == 1)
                {
                    _template = _cb.CreateTemplate(PortraitPageSize.HdrUpperRightX - PortraitPageSize.HdrLowerLeftX, 50);
                }

                // ===========================================================================
                // Create header column -- in this report this is the page's column object
                // ===========================================================================
                _ct.SetSimpleColumn(PortraitPageSize.HdrLowerLeftX, PortraitPageSize.HdrLowerLeftY,
                                    PortraitPageSize.HdrUpperRightX, PortraitPageSize.HdrUpperRightY,
                                    PortraitPageSize.PgLeading, Element.ALIGN_CENTER);
                _ct.YLine = PortraitPageSize.HdrTopYLine;

                // =======================================================
                // Add Header: Logo 2010
                // =======================================================

                PdfPTable logoTable = PdfReports.CreateTable(_logo2010Layout, 0);

                // Only add actual logo on First Page of set
                Paragraph p = new Paragraph("", _normalFont);
                if (_pageNumber == 1)
                {
                    // BLANK
                    PdfReports.AddText2Table(logoTable, " ", _normalFont);

                    // LOGO
                    PdfReports.AddImage2Table(logoTable, _imgLogo);

                    // TEXT
                    Phrase ph = new Phrase(16F, "The Western Sugar Cooperative", _superTitleFont);
                    p.Add(ph);
                    ph = new Phrase(5F, "\n\n(Grower Owned)", _normalFont);
                    p.Add(ph);
                    PdfReports.AddText2Table(logoTable, p, "center");

                    // BLANK
                    PdfReports.AddText2Table(logoTable, " ", _normalFont);
                }
                else
                {
                    PdfReports.AddText2Table(logoTable, " ", _normalFont, _logo2010Layout.Length);
                }

                //-----------------------------------------
                // Add and center the title
                //-----------------------------------------
                PdfReports.AddText2Table(logoTable, " ", _normalFont);
                PdfReports.AddText2Table(logoTable, _title, _titleFont, "center", 2);
                PdfReports.AddText2Table(logoTable, " ", _normalFont);

                // Skip a line: adjust font size to automatically adjust leading.  Setting leading is not working  !!!
                //PdfReports.AddText2Table(logoTable, " \n ", FontFactory.GetFont("HELVETICA", 12F, Font.NORMAL), _logo2010Layout.Length);

                PdfReports.AddTableNoSplit(document, this, logoTable);

                float[]   addrLayout = new float[] { 50F, 355F, 135F };
                PdfPTable addrTable  = PdfReports.CreateTable(addrLayout, 0);

                if (_pageNumber == 1)
                {
                    //-----------------------------------------------
                    // Next Add SHID / Check Amt
                    //-----------------------------------------------
                    float[]   summaryLayout = new float[] { 385F, 60F, 95F };
                    PdfPTable summaryTable  = PdfReports.CreateTable(summaryLayout, 0);

                    PdfReports.AddText2Table(summaryTable, " ", _normalFont, summaryLayout.Length);

                    PdfReports.AddText2Table(summaryTable, " ", _normalFont);
                    PdfReports.AddText2Table(summaryTable, "SHID:", _labelFont, "left");
                    PdfReports.AddText2Table(summaryTable, _shid, _normalFont, "right");

                    PdfReports.AddText2Table(summaryTable, " ", _normalFont);
                    PdfReports.AddText2Table(summaryTable, "Check Amt:", _labelFont, "left");
                    PdfReports.AddText2Table(summaryTable, _checkAmount.ToString("$#,##0.00"), _normalFont, "right");

                    PdfReports.AddTableNoSplit(document, this, summaryTable);

                    //-----------------------------------------------
                    // Address block
                    //-----------------------------------------------

                    //PdfReports.AddText2Table(addrTable, " ", _normalFont, addrLayout.Length);       // Blank Line
                    PdfReports.AddText2Table(addrTable, " ", _normalFont);

                    p = PdfReports.GetAddressBlock(_businessName, _memAddr1, _memAddr2, _memCSZ,
                                                   0F, 12F, iTextSharp.text.Element.ALIGN_LEFT, _uspsFont);
                    PdfReports.AddText2Table(addrTable, p);

                    PdfReports.AddText2Table(addrTable, " ", _normalFont);

                    PdfReports.AddText2Table(addrTable, " ", _normalFont, addrLayout.Length);
                }

                PdfReports.AddText2Table(addrTable, " ", _normalFont, addrLayout.Length);
                PdfReports.AddText2Table(addrTable, " ", _normalFont, addrLayout.Length);

                PdfReports.AddTableNoSplit(document, this, addrTable);
                _headerBottomYLine = _ct.YLine;
            }

            base.OnStartPage(writer, document);
        }
コード例 #6
0
        private static void ReportBuilderPatronage(List <ListStatementPatRetainItem> stateList,
                                                   int cropYear, DateTime certificateDate, string shid, string fromShid, string toShid, string logoUrl, System.IO.FileStream fs,
                                                   string sigName, string sigTitle, string sigImagePath)
        {
            const string METHOD_NAME = "ReportBuilderPatronage: ";

            string SHID               = "";
            string equityCropYear     = "";
            string rptTitle           = "";
            string certificateDateStr = certificateDate.ToString(HEADER_DATE_FORMAT);
            string qualifiedStr       = "";
            float  pdfYPos            = 0;
            float  pdfXPos            = -4;

            Document        document    = null;
            PdfWriter       writer      = null;
            PdfPTable       bottomTable = null;
            ColumnText      ct          = null;
            PdfImportedPage pdfImport   = null;

            CertificateEvent pgEvent = null;

            try {
                if (stateList.Count > 0)
                {
                    qualifiedStr = (stateList[0].Qualified.ToLower() == "qualified" ? "Qualified" : "NonQualified");
                }

                iTextSharp.text.Image imgSignature = PdfReports.GetImage(sigImagePath, 228, 68, iTextSharp.text.Element.ALIGN_LEFT);

                foreach (ListStatementPatRetainItem state in stateList)
                {
                    if (rptTitle.Length == 0)
                    {
                        rptTitle = qualifiedStr.ToUpper() + " PATRONAGE REFUND NOTICE\n" + "CROP YEAR " + cropYear.ToString();
                    }

                    SHID           = state.SHID;
                    equityCropYear = state.EquityCropYear;

                    if (document == null)
                    {
                        // IF YOU CHANGE MARGINS, CHANGE YOUR TABLE LAYOUTS !!!
                        //  ***  US LETTER: 612 X 792  ***
                        document = new Document(PortraitPageSize.PgPageSize, PortraitPageSize.PgLeftMargin,
                                                PortraitPageSize.PgRightMargin, PortraitPageSize.PgTopMargin, PortraitPageSize.PgBottomMargin);

                        // we create a writer that listens to the document
                        // and directs a PDF-stream to a file
                        writer = PdfWriter.GetInstance(document, fs);

                        // Attach my override event handler(s)
                        pgEvent = new CertificateEvent();
                        pgEvent.FillEvent(state.SHID, state.BusName, state.Addr1, state.Addr2, state.CSZ, rptTitle, logoUrl);
                        writer.PageEvent = pgEvent;

                        // Open the document
                        document.Open();

                        //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

                        // ** ROTATE ** ROTATE **  ---------------------------------------------------------------------------------------
                        //PdfReader reader = new PdfReader(...);
                        //for (int k = 1; k <= reader.getNumberOfPages(); ++k) {
                        //    reader.getPageN(k).put(PdfName.ROTATE, new PdfNumber(90));
                        //}
                        //PdfStamper stp = new PdfStamper(reader, ...);
                        //stp.close();
                        // ** ROTATE ** ROTATE **  ---------------------------------------------------------------------------------------
                        //string tmpFilePath = sigImagePath.Replace("CertificateSignature.gif", "WorkTemplate.pdf");
                        //PdfReader rdr = new PdfReader(tmpFilePath);
                        //rdr.GetPageN(1).Put(PdfName.ROTATE, new PdfNumber(90));

                        //Document docCopy = new Document(rdr.GetPageSizeWithRotation(1));
                        //PdfCopy pCopy = new PdfCopy(docCopy, new System.IO.FileStream(sigImagePath.Replace("CertificateSignature.gif", "WorkTemplate90.pdf"),
                        //    System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.Read));

                        //docCopy.Open();

                        //docCopy.AddCreationDate();
                        //docCopy.AddCreator("");
                        //docCopy.AddTitle("CertificateTemplate.pdf");

                        //pCopy.AddPage(pCopy.GetImportedPage(rdr, 1));
                        //docCopy.Close();

                        //using (System.IO.FileStream fsTmpOut = new FileStream(sigImagePath.Replace("CertificateSignature.gif", "WorkTemplate90.pdf"),
                        //    System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.Read)) {

                        //    PdfStamper tmpStamp = new PdfStamper(rdr, fsTmpOut);
                        //    tmpStamp.Close();
                        //}

                        // ================================================================================================================
                        // FROM PDF -- Pulls a background image out of a pdf and uses it as the under layer! Works BUT NEEDS ADJUSTMENT
                        // ================================================================================================================
                        string    _certBorderPath = sigImagePath.Replace("CertificateSignature.gif", "CertBorders.pdf");
                        PdfReader rdrCertBorder   = new PdfReader(_certBorderPath);
                        pdfImport = writer.GetImportedPage(rdrCertBorder, 1); // import only page 1.

                        //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                        // ================================================================================================================
                        // FROM JPG -- Uses a jpg image as the under layer!!! This ROUGHLY WORKS -- NEEDS HELP !
                        // ================================================================================================================
                        //string _logo = sigImagePath.Replace("CertificateSignature.gif", "MyBorders.gif");

                        //iTextSharp.text.Image imgBack = PdfReports.GetImage(_logo, Convert.ToInt32(document.Right - document.RightMargin - document.LeftMargin),
                        //    Convert.ToInt32(document.Top - document.TopMargin - document.BottomMargin), iTextSharp.text.Element.ALIGN_CENTER);

                        //float imageYPos = document.Top - imgBack.Height;
                        //float imageXPos = 0;

                        //// To position an image  at (x,y) use addImage(image, image_width, 0, 0, image_height, x, y)
                        //writer.DirectContentUnder.AddImage(imgBack, imgBack.Width, 0, 0, imgBack.Height, imageXPos, imageYPos);

                        //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                    }
                    else
                    {
                        pgEvent.FillEvent(state.SHID, state.BusName, state.Addr1, state.Addr2, state.CSZ, rptTitle, logoUrl);
                        document.NewPage();
                    }

                    writer.DirectContentUnder.AddTemplate(pdfImport, pdfXPos, pdfYPos);

                    // =======================================================
                    // Build Report
                    // =======================================================

                    // Fill report Body
                    ct = pgEvent.GetColumnObject();
                    BuildPatronageBodyText(cropYear, qualifiedStr, ct);

                    // Add Bottom section -- Date, Amount, SigLine.
                    bottomTable = PdfReports.CreateTable(_bottomPatLayout, 0);

                    PdfReports.AddText2Table(bottomTable, " ", _normalFont);
                    PdfReports.AddText2Table(bottomTable, "Dated: " + certificateDateStr, _normalFont, "left");
                    PdfReports.AddText2Table(bottomTable, "Total patronage refund: ", _normalFont, "left");
                    PdfReports.AddText2Table(bottomTable, Convert.ToDecimal(state.EquityAmt).ToString("$#,##0.00"), _normalFont, "right");
                    PdfReports.AddText2Table(bottomTable, " ", _normalFont);

                    PdfReports.AddText2Table(bottomTable, " ", _normalFont, 2);
                    PdfReports.AddText2Table(bottomTable, "Paid by check: ", _normalFont, "left");
                    PdfReports.AddText2Table(bottomTable, Convert.ToDecimal(state.PatInitPayment).ToString("$#,##0.00"), _normalFont, "right");
                    PdfReports.AddText2Table(bottomTable, " ", _normalFont);

                    PdfReports.AddText2Table(bottomTable, " ", _normalFont, 2);
                    PdfReports.AddText2Table(bottomTable, "Patronage equity: ", _normalFont, "left");
                    PdfReports.AddText2Table(bottomTable, Convert.ToDecimal(state.RedeemAmt).ToString("$#,##0.00"), _normalFont, "right");
                    PdfReports.AddText2Table(bottomTable, " ", _normalFont);

                    PdfReports.AddText2Table(bottomTable, " ", _normalFont, _bottomRetLayout.Length);
                    PdfReports.AddText2Table(bottomTable, " ", _normalFont, _bottomRetLayout.Length);
                    ct.AddElement(bottomTable);

                    //----------------------------------
                    // Add Signature
                    //----------------------------------
                    //  this is odd, but use the RET layout for sig line.
                    bottomTable = PdfReports.CreateTable(_bottomRetLayout, 0);
                    PdfReports.AddText2Table(bottomTable, " ", _normalFont, 2);
                    PdfReports.AddImage2Table(bottomTable, imgSignature);
                    PdfReports.AddText2Table(bottomTable, " ", _normalFont);

                    // add signature info
                    PdfReports.AddText2Table(bottomTable, " ", _normalFont, 2);
                    PdfReports.AddText2Table(bottomTable, sigName, _normalFont);
                    PdfReports.AddText2Table(bottomTable, " ", _normalFont);

                    PdfReports.AddText2Table(bottomTable, " ", _normalFont, 2);
                    PdfReports.AddText2Table(bottomTable, sigTitle, _normalFont);
                    PdfReports.AddText2Table(bottomTable, " ", _normalFont);

                    ct.AddElement(bottomTable);
                    ct.Go(false);
                }

                // ======================================================
                // Close document
                // ======================================================
                if (document != null)
                {
                    pgEvent.IsDocumentClosing = true;
                    document.Close();
                    document = null;
                }
                if (writer == null)
                {
                    // Warn that we have no data.
                    WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("No records matched your report criteria.");
                    throw (warn);
                }
            }
            catch (Exception ex) {
                string errMsg = "document is null: " + (document == null).ToString() + "; " +
                                "writer is null: " + (writer == null).ToString();
                WSCIEMP.Common.CException wscex = new WSCIEMP.Common.CException(METHOD_NAME + errMsg, ex);
                throw (wscex);
            }
            finally {
                if (document != null)
                {
                    pgEvent.IsDocumentClosing = true;
                    document.Close();
                }
                if (writer != null)
                {
                    writer.Close();
                }
            }
        }
コード例 #7
0
        private static void ReportBuilderRetain(List <ListStatementPatRetainItem> stateList,
                                                int cropYear, DateTime certificateDate, string shid, string fromShid, string toShid, string logoUrl, System.IO.FileStream fs,
                                                string sigName, string sigTitle, string sigImagePath)
        {
            const string METHOD_NAME = "ReportBuilderRetain: ";

            string SHID               = "";
            string equityCropYear     = "";
            string rptTitle           = "";
            string certificateDateStr = certificateDate.ToString(HEADER_DATE_FORMAT);
            string qualifiedStr       = "";
            float  pdfYPos            = 0;
            float  pdfXPos            = -4;

            Document        document    = null;
            PdfWriter       writer      = null;
            PdfPTable       bottomTable = null;
            ColumnText      ct          = null;
            PdfImportedPage pdfImport   = null;

            CertificateEvent pgEvent = null;

            try {
                if (stateList.Count > 0)
                {
                    qualifiedStr = (stateList[0].Qualified.ToLower() == "qualified" ? "Qualified" : "NonQualified");
                }

                iTextSharp.text.Image imgSignature = PdfReports.GetImage(sigImagePath, 228, 68, iTextSharp.text.Element.ALIGN_LEFT);

                foreach (ListStatementPatRetainItem state in stateList)
                {
                    if (rptTitle.Length == 0)
                    {
                        rptTitle = qualifiedStr.ToUpper() + " UNIT RETAIN NOTICE\n" + "CROP YEAR " + cropYear.ToString();
                    }

                    SHID           = state.SHID;
                    equityCropYear = state.EquityCropYear;

                    if (document == null)
                    {
                        // IF YOU CHANGE MARGINS, CHANGE YOUR TABLE LAYOUTS !!!
                        //  ***  US LETTER: 612 X 792  ***
                        document = new Document(PortraitPageSize.PgPageSize, PortraitPageSize.PgLeftMargin,
                                                PortraitPageSize.PgRightMargin, PortraitPageSize.PgTopMargin, PortraitPageSize.PgBottomMargin);

                        // we create a writer that listens to the document
                        // and directs a PDF-stream to a file
                        writer = PdfWriter.GetInstance(document, fs);

                        // Attach my override event handler(s)
                        pgEvent = new CertificateEvent();
                        pgEvent.FillEvent(state.SHID, state.BusName, state.Addr1, state.Addr2, state.CSZ, rptTitle, logoUrl);
                        writer.PageEvent = pgEvent;

                        // Open the document
                        document.Open();

                        // ================================================================================================================
                        // FROM PDF -- Pulls a background image out of a pdf and uses it as the under layer! Works BUT NEEDS ADJUSTMENT
                        // ================================================================================================================
                        string    _certBorderPath = sigImagePath.Replace("CertificateSignature.gif", "CertBorders.pdf");
                        PdfReader rdrCertBorder   = new PdfReader(_certBorderPath);
                        pdfImport = writer.GetImportedPage(rdrCertBorder, 1); // import only page 1.
                    }
                    else
                    {
                        pgEvent.FillEvent(state.SHID, state.BusName, state.Addr1, state.Addr2, state.CSZ, rptTitle, logoUrl);
                        document.NewPage();
                    }

                    writer.DirectContentUnder.AddTemplate(pdfImport, pdfXPos, pdfYPos);

                    // =======================================================
                    // Build Report
                    // =======================================================

                    // Fill report Body
                    ct = pgEvent.GetColumnObject();
                    BuildRetainBodyText(cropYear, qualifiedStr, ct);

                    // Add Bottom section -- Date, Amount, SigLine.
                    bottomTable = PdfReports.CreateTable(_bottomRetLayout, 0);

                    PdfReports.AddText2Table(bottomTable, " ", _normalFont);
                    PdfReports.AddText2Table(bottomTable, "Dated: " + certificateDateStr, _normalFont, "left");
                    PdfReports.AddText2Table(bottomTable, "Amount: " + Convert.ToDecimal(state.EquityAmt).ToString("$#,##0.00"), _normalFont, "left");
                    PdfReports.AddText2Table(bottomTable, " ", _normalFont);

                    PdfReports.AddText2Table(bottomTable, " ", _normalFont, _bottomRetLayout.Length);
                    PdfReports.AddText2Table(bottomTable, " ", _normalFont, _bottomRetLayout.Length);

                    //----------------------------------
                    // Add Signature
                    //----------------------------------
                    PdfReports.AddText2Table(bottomTable, " ", _normalFont, 2);
                    PdfReports.AddImage2Table(bottomTable, imgSignature);
                    PdfReports.AddText2Table(bottomTable, " ", _normalFont);

                    // add signature info
                    PdfReports.AddText2Table(bottomTable, " ", _normalFont, 2);
                    PdfReports.AddText2Table(bottomTable, sigName, _normalFont);
                    PdfReports.AddText2Table(bottomTable, " ", _normalFont);

                    PdfReports.AddText2Table(bottomTable, " ", _normalFont, 2);
                    PdfReports.AddText2Table(bottomTable, sigTitle, _normalFont);
                    PdfReports.AddText2Table(bottomTable, " ", _normalFont);

                    ct.AddElement(bottomTable);
                    ct.Go(false);
                }

                // ======================================================
                // Close document
                // ======================================================
                if (document != null)
                {
                    pgEvent.IsDocumentClosing = true;
                    document.Close();
                    document = null;
                }
                if (writer == null)
                {
                    // Warn that we have no data.
                    WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("No records matched your report criteria.");
                    throw (warn);
                }
            }
            catch (Exception ex) {
                string errMsg = "document is null: " + (document == null).ToString() + "; " +
                                "writer is null: " + (writer == null).ToString();
                WSCIEMP.Common.CException wscex = new WSCIEMP.Common.CException(METHOD_NAME + errMsg, ex);
                throw (wscex);
            }
            finally {
                if (document != null)
                {
                    pgEvent.IsDocumentClosing = true;
                    document.Close();
                }
                if (writer != null)
                {
                    writer.Close();
                }
            }
        }
コード例 #8
0
ファイル: rptTransmittal.cs プロジェクト: jwebb-vtg/WSCIEMP
        public override void OnStartPage(PdfWriter writer, Document document)
        {
            if (!_isDocumentClosing)
            {
                _pageNumber++;

                if (_pageNumber == 1)
                {
                    _template = _cb.CreateTemplate(PortraitPageSize.HdrUpperRightX - PortraitPageSize.HdrLowerLeftX, 50);
                }

                // ===========================================================================
                // Create header column -- in this report this is the page's column object
                // ===========================================================================
                _ct.SetSimpleColumn(PortraitPageSize.HdrLowerLeftX, PortraitPageSize.HdrLowerLeftY,
                                    PortraitPageSize.HdrUpperRightX, PortraitPageSize.HdrUpperRightY,
                                    PortraitPageSize.PgLeading, Element.ALIGN_CENTER);
                _ct.YLine = PortraitPageSize.HdrTopYLine;

                // =======================================================
                // Add Header
                // =======================================================
                float[]   logoLayout = new float[] { 413F, 127F };
                PdfPTable logoTable  = PdfReports.CreateTable(logoLayout, 0);
                Paragraph p          = null;

                PdfReports.AddText2Table(logoTable, _title + "\n" +
                                         _paymentDesc + " - " + _cropYear + " Crop " + (_statementDate.Length > 0 ? "- " : "") +
                                         _statementDate, titleFont, "center");

                if (_pageNumber == 1)
                {
                    PdfReports.AddImage2Table(logoTable, _imgLogo);
                }
                else
                {
                    PdfReports.AddText2Table(logoTable, " ", normalFont);
                }
                PdfReports.AddTableNoSplit(document, this, logoTable);

                float[]   headerLayout = new float[] { 51.5F, 306.4F, 44.1F, 51.5F, 86.5F };
                PdfPTable table        = PdfReports.CreateTable(headerLayout, 1);

                p = new Paragraph(23F, " ", normalFont);
                _ct.AddElement(p);
                _ct.Go(false);

                // Add blank lines
                float[]   shareholderLayout = new float[] { 50F, 270F, 220F };
                PdfPTable addrTable         = PdfReports.CreateTable(shareholderLayout, 0);

                PdfReports.AddText2Table(addrTable, " ", normalFont, addrTable.NumberOfColumns);
                PdfReports.AddText2Table(addrTable, " ", normalFont, addrTable.NumberOfColumns);

                if (_pageNumber == 1)
                {
                    string csz = _city + ", " + _state + " " + _postalCode;
                    p = PdfReports.GetAddressBlock(_growerName, _adr1, _adr2,
                                                   csz, 0F, 12F, iTextSharp.text.Element.ALIGN_LEFT, uspsFont);
                    PdfReports.AddText2Table(addrTable, " ", uspsFont);
                    PdfReports.AddText2Table(addrTable, p);

                    PdfReports.AddText2Table(addrTable, _contractNumber.ToString() + "\n" +
                                             _factoryName + "\n" +
                                             _stationName, uspsFont, "right");
                    PdfReports.AddText2Table(addrTable, " ", normalFont, 3);
                    PdfReports.AddText2Table(addrTable, " ", normalFont, 3);

                    PdfReports.AddTableNoSplit(document, this, addrTable);
                }
                else
                {
                    PdfReports.AddText2Table(addrTable, " ", uspsFont);
                    PdfReports.AddText2Table(addrTable, _growerName, uspsFont);

                    PdfReports.AddText2Table(addrTable, _factoryName + "\n" +
                                             _stationName, uspsFont, "right");
                    PdfReports.AddText2Table(addrTable, " ", normalFont, addrTable.NumberOfColumns);
                    PdfReports.AddText2Table(addrTable, " ", normalFont, addrTable.NumberOfColumns);

                    PdfReports.AddTableNoSplit(document, this, addrTable);
                }

                _headerBottomYLine = _ct.YLine;
            }

            base.OnStartPage(writer, document);
        }
コード例 #9
0
        public override void OnStartPage(PdfWriter writer, Document document)
        {
            if (!_isDocumentClosing)
            {
                _pageNumber++;

                // ===========================================================================
                // Create header column -- in this report this is the page's column object
                // ===========================================================================
                _ct.SetSimpleColumn(PortraitPageSize.HdrLowerLeftX, PortraitPageSize.HdrLowerLeftY,
                                    PortraitPageSize.HdrUpperRightX, PortraitPageSize.HdrUpperRightY,
                                    PortraitPageSize.PgLeading, Element.ALIGN_CENTER);
                _ct.YLine = PortraitPageSize.HdrTopYLine;

                // =======================================================
                // Add Logo
                // =======================================================
                if (_pageNumber == 1)
                {
                    float[]   wscLogoLayout = new float[] { 413F, 127F };
                    PdfPTable logoTable     = PdfReports.CreateTable(wscLogoLayout, 0);
                    PdfReports.AddText2Table(logoTable, " ", _normalFont);
                    PdfReports.AddImage2Table(logoTable, _imgLogo);
                    PdfReports.AddText2Table(logoTable, " ", _titleFont, wscLogoLayout.Length);

                    PdfReports.AddTableNoSplit(document, this, logoTable);
                }

                float[]   headerLayout = new float[] { 50F, 200F, 290F };
                PdfPTable table        = PdfReports.CreateTable(headerLayout, 1);

                Paragraph p = new Paragraph(_title, _titleFont);
                PdfReports.AddText2Table(table, p, "center", headerLayout.Length);

                // Add blank lines
                PdfReports.AddText2Table(table, " ", _subNormalFont, headerLayout.Length);
                PdfReports.AddText2Table(table, " ", _normalFont, headerLayout.Length);

                // Add Header information
                PdfReports.AddText2Table(table, "SHID", _labelFont);
                PdfReports.AddText2Table(table, "Shareholder Name", _labelFont);
                PdfReports.AddText2Table(table, "Delivery Date", _labelFont);

                PdfReports.AddText2Table(table, _shid, _normalFont);
                PdfReports.AddText2Table(table, _shareholderName, _normalFont);
                PdfReports.AddText2Table(table, _deliveryDate, _normalFont);

                PdfReports.AddText2Table(table, " ", _normalFont, headerLayout.Length);
                PdfReports.AddText2Table(table, " ", _normalFont, headerLayout.Length);

                PdfReports.AddTableNoSplit(document, this, table);

                table = PdfReports.CreateTable(_hdrTableLayout, 1);
                PdfReports.FillHeaderLabels(ref table, _hdrTableNames, _labelFont);
                PdfReports.AddTableNoSplit(document, this, table);

                _headerBottomYLine = _ct.YLine;
            }

            base.OnStartPage(writer, document);
        }
コード例 #10
0
        public override void OnStartPage(PdfWriter writer, Document document)
        {
            if (!_isDocumentClosing)
            {
                _pageNumber++;

                if (_pageNumber == 1)
                {
                    _template = _cb.CreateTemplate(PortraitPageSize.HdrUpperRightX - PortraitPageSize.HdrLowerLeftX, 50);
                }

                // ===========================================================================
                // Create header column -- in this report this is the page's column object
                // ===========================================================================
                _ct.SetSimpleColumn(PortraitPageSize.HdrLowerLeftX, PortraitPageSize.HdrLowerLeftY,
                                    PortraitPageSize.HdrUpperRightX, PortraitPageSize.HdrUpperRightY,
                                    PortraitPageSize.PgLeading, Element.ALIGN_CENTER);
                _ct.YLine = PortraitPageSize.HdrTopYLine;

                // =======================================================
                // Add Header
                // =======================================================
                float[]   wscLogoLayout = new float[] { 60, 353F, 127F };
                PdfPTable logoTable     = PdfReports.CreateTable(wscLogoLayout, 0);

                PdfReports.AddText2Table(logoTable, _statementDate, _normalFont);
                PdfReports.AddText2Table(logoTable, _title, _titleFont, "center");

                // Only add actual logo on First page of set.
                if (_pageNumber == 1)
                {
                    PdfReports.AddImage2Table(logoTable, _imgLogo);
                }
                else
                {
                    PdfReports.AddText2Table(logoTable, " ", _normalFont);
                }
                PdfReports.AddText2Table(logoTable, " \n \n ", _titleFont, wscLogoLayout.Length);
                PdfReports.AddTableNoSplit(document, this, logoTable);

                float[]   addrLayout = new float[] { 50F, 355F, 135F };
                PdfPTable addrTable  = PdfReports.CreateTable(addrLayout, 0);

                if (_pageNumber == 1)
                {
                    PdfReports.AddText2Table(addrTable, " ", _normalFont, addrLayout.Length);
                    PdfReports.AddText2Table(addrTable, " ", _normalFont);

                    Paragraph p = PdfReports.GetAddressBlock(_groName, _groAdr1, _groAdr2, _groCSZ,
                                                             0F, 12F, iTextSharp.text.Element.ALIGN_LEFT, _uspsFont);
                    PdfReports.AddText2Table(addrTable, p);

                    PdfReports.AddText2Table(addrTable, " ", _normalFont);

                    PdfReports.AddText2Table(addrTable, " ", _normalFont, addrLayout.Length);
                }

                PdfReports.AddText2Table(addrTable, " ", _normalFont, addrLayout.Length);
                PdfReports.AddText2Table(addrTable, " ", _normalFont, addrLayout.Length);

                PdfReports.AddTableNoSplit(document, this, addrTable);
                _headerBottomYLine = _ct.YLine;
            }

            base.OnStartPage(writer, document);
        }
コード例 #11
0
        public override void OnStartPage(PdfWriter writer, Document document)
        {
            if (!_isDocumentClosing)
            {
                // ===========================================================================
                // Create header column -- in this report this is the page's column object
                // ===========================================================================
                ct.SetSimpleColumn(PortraitPageSize.HdrLowerLeftX, PortraitPageSize.HdrLowerLeftY,
                                   PortraitPageSize.HdrUpperRightX, PortraitPageSize.HdrUpperRightY,
                                   PortraitPageSize.PgLeading, Element.ALIGN_CENTER);
                ct.YLine = PortraitPageSize.HdrTopYLine;

                //float[] layout = new float[] { 403F, 137F };
                float[]   layout = new float[] { 371F, 137F };
                PdfPTable table  = PdfReports.CreateTable(layout, 0);

                // Line 1
                PdfReports.AddText2Table(table, " ", _normalFont);
                PdfReports.AddImage2Table(table, _imgLogo);

                // Line 2
                PdfReports.AddText2Table(table, " ", _normalFont, layout.Length);
                PdfReports.AddText2Table(table, " ", _normalFont);
                PdfReports.AddText2Table(table, _statementDate, _subTitleFont, "center");
                PdfReports.AddTableNoSplit(document, this, table);

                // Blank line: manuall adjust leading to get proper vertical spacing
                Paragraph p = new Paragraph(16F, " ", _normalFont);
                ct.AddElement(p);

                // Address block
                float adrLeading    = 12.5F;
                float adrLeftIndent = 50F;

                if (_ldoBusinessName.Length > 0)
                {
                    p = new Paragraph(adrLeading, _ldoBusinessName + " \n", _normalFont);
                    p.IndentationLeft = adrLeftIndent;
                    ct.AddElement(p);
                }
                if (_ldoAddressLine1.Length > 0)
                {
                    p = new Paragraph(adrLeading, _ldoAddressLine1 + " \n", _normalFont);
                    p.IndentationLeft = adrLeftIndent;
                    ct.AddElement(p);
                }
                if (_ldoAddressLine2.Length > 0)
                {
                    p = new Paragraph(adrLeading, _ldoAddressLine2 + " \n", _normalFont);
                    p.IndentationLeft = adrLeftIndent;
                    ct.AddElement(p);
                }
                if (_ldoCityStateZip.Length > 0)
                {
                    p = new Paragraph(adrLeading, _ldoCityStateZip + " \n", _normalFont);
                    p.IndentationLeft = adrLeftIndent;
                    ct.AddElement(p);
                }

                p = new Paragraph(50F, " ", _normalFont);
                ct.AddElement(p);
                ct.Go(false);

                _headerBottomYLine = ct.YLine;
            }

            base.OnStartPage(writer, document);
        }
コード例 #12
0
        public override void OnStartPage(PdfWriter writer, Document document)
        {
            if (!_isDocumentClosing)
            {
                _pageNumber++;

                // ===========================================================================
                // Create header column -- in this report this is the page's column object
                // ===========================================================================
                _ct.SetSimpleColumn(PortraitPageSize.HdrLowerLeftX, PortraitPageSize.HdrLowerLeftY,
                                    PortraitPageSize.HdrUpperRightX, PortraitPageSize.HdrUpperRightY,
                                    PortraitPageSize.PgLeading, Element.ALIGN_CENTER);
                _ct.YLine = PortraitPageSize.HdrTopYLine;

                // =======================================================
                // Add Header
                // =======================================================
                float[]   layout = new float[] { 413F, 127F };
                PdfPTable table  = PdfReports.CreateTable(layout, 0);
                Paragraph p      = null;

                PdfReports.AddText2Table(table, _title + "\n" +
                                         _paymentDesc + " - " + _cropYear + " Crop " + (_statementDate.Length > 0 ? "- " : "") +
                                         _statementDate, _titleFont, "center");

                if (_pageNumber == 1)
                {
                    PdfReports.AddImage2Table(table, _imgLogo);
                }
                else
                {
                    PdfReports.AddText2Table(table, " ", _normalFont);
                }
                PdfReports.AddTableNoSplit(document, this, table);

                // Add blank lines
                layout = new float[] { 50F, 270F, 220F };
                table  = PdfReports.CreateTable(layout, 0);

                PdfReports.AddText2Table(table, " ", _normalFont, layout.Length);
                PdfReports.AddText2Table(table, " ", _normalFont, layout.Length);
                PdfReports.AddText2Table(table, " ", _normalFont, layout.Length);
                PdfReports.AddText2Table(table, " ", FontFactory.GetFont("HELVETICA", 7F, Font.NORMAL), layout.Length);

                if (_pageNumber == 1)
                {
                    string csz = _city + ", " + _state + " " + _postalCode;
                    p = PdfReports.GetAddressBlock(_growerName, _adr1, _adr2,
                                                   csz, 0F, 12F, iTextSharp.text.Element.ALIGN_LEFT, _uspsFont);
                    PdfReports.AddText2Table(table, " ", _uspsFont);
                    PdfReports.AddText2Table(table, p);

                    PdfReports.AddText2Table(table, _contractNumber.ToString() + "\n" +
                                             _factoryName + "\n" +
                                             _stationName, _uspsFont, "right");
                    PdfReports.AddText2Table(table, " ", _normalFont, layout.Length);
                    PdfReports.AddText2Table(table, " ", _normalFont, layout.Length);
                }
                else
                {
                    PdfReports.AddText2Table(table, " ", _uspsFont);
                    PdfReports.AddText2Table(table, _growerName, _uspsFont);

                    PdfReports.AddText2Table(table, _factoryName + "\n" +
                                             _stationName, _uspsFont, "right");
                    PdfReports.AddText2Table(table, " ", _normalFont, layout.Length);
                    PdfReports.AddText2Table(table, " ", _normalFont, layout.Length);
                }

                PdfReports.AddTableNoSplit(document, this, table);
                _headerBottomYLine = _ct.YLine;
            }

            base.OnStartPage(writer, document);
        }
コード例 #13
0
        public override void OnStartPage(PdfWriter writer, Document document)
        {
            if (!_isDocumentClosing)
            {
                _pageNumber++;

                // ===========================================================================
                // Create header column -- in this report this is the page's column object
                // ===========================================================================
                _ct.SetSimpleColumn(PortraitPageSize.HdrLowerLeftX, PortraitPageSize.HdrLowerLeftY,
                                    PortraitPageSize.HdrUpperRightX, PortraitPageSize.HdrUpperRightY,
                                    PortraitPageSize.PgLeading, Element.ALIGN_CENTER);
                _ct.YLine = PortraitPageSize.HdrTopYLine;

                Paragraph p = null;

                // =======================================================
                // Add Logo
                // =======================================================
                if (_pageNumber == 1)
                {
                    float[]   wscLogoLayout = new float[] { 127F, 286F, 127F };
                    PdfPTable logoTable     = PdfReports.CreateTable(wscLogoLayout, 0);

                    PdfReports.AddText2Table(logoTable, " ", _normalFont);
                    PdfReports.AddText2Table(logoTable, _title + "\n" + _reportDate.ToShortDateString(), _titleFont, "center");
                    PdfReports.AddImage2Table(logoTable, _imgLogo);

                    PdfReports.AddTableNoSplit(document, this, logoTable);
                }

                float[]   addrLayout = new float[] { 50F, 270F, 220F };
                PdfPTable table      = PdfReports.CreateTable(addrLayout, 0);
                PdfReports.AddText2Table(table, " ", _normalFont, addrLayout.Length);
                PdfReports.AddText2Table(table, " ", _normalFont, addrLayout.Length);
                PdfReports.AddText2Table(table, " ", _normalFont, addrLayout.Length);

                if (_pageNumber == 1)
                {
                    PdfReports.AddText2Table(table, " ", _normalFont);

                    // Left column: Full Mailling Address
                    p = PdfReports.GetAddressBlock(_busName, _adrLine1, _adrLine2,
                                                   _csz, 0F, 12F, iTextSharp.text.Element.ALIGN_LEFT, _uspsFont);
                    PdfReports.AddText2Table(table, p);

                    // Right column: shid / tax id
                    PdfReports.AddText2Table(table, "Co-op ID: " + _shid.ToString() + "\n" + " ", _normalFont, "right");
                }
                else
                {
                    // Left column: Business Name
                    PdfReports.AddText2Table(table, " ", _normalFont);
                    PdfReports.AddText2Table(table, _busName, _normalFont);

                    // Right column: shid / tax id
                    PdfReports.AddText2Table(table, "Co-op ID: " + _shid.ToString() + "\n" + " ", _normalFont, "right");
                }
                PdfReports.AddText2Table(table, " ", _normalFont, addrLayout.Length);
                PdfReports.AddText2Table(table, " ", _normalFont, addrLayout.Length);
                PdfReports.AddText2Table(table, " ", _normalFont, addrLayout.Length);

                PdfReports.AddTableNoSplit(document, this, table);
                _headerBottomYLine = _ct.YLine;
            }

            base.OnStartPage(writer, document);
        }
コード例 #14
0
        public override void OnStartPage(PdfWriter writer, Document document)
        {
            if (!_isDocumentClosing)
            {
                _pageNumber++;

                if (_pageNumber == 1)
                {
                    _template = _cb.CreateTemplate(PortraitPageSize.HdrUpperRightX - PortraitPageSize.HdrLowerLeftX, 50);
                }

                // ===========================================================================
                // Create header column -- in this report this is the page's column object
                // ===========================================================================
                _ct.SetSimpleColumn(PortraitPageSize.HdrLowerLeftX, PortraitPageSize.HdrLowerLeftY,
                                    PortraitPageSize.HdrUpperRightX, PortraitPageSize.HdrUpperRightY,
                                    PortraitPageSize.PgLeading, Element.ALIGN_TOP);
                _ct.YLine = PortraitPageSize.HdrTopYLine;

                // =======================================================
                // Add Payment Header
                // =======================================================
                float[]   layout = new float[] { 413F, 127F };
                PdfPTable table  = PdfReports.CreateTable(layout, 0);
                PdfReports.AddText2Table(table, _title + "\n" +
                                         _paymentDesc + " - " + _cropYear + " Crop " + (_statementDate.Length > 0 ? "- " : "") +
                                         _statementDate, titleFont, "center");

                if (_pageNumber == 1)
                {
                    PdfReports.AddImage2Table(table, _imgLogo);
                }
                else
                {
                    PdfReports.AddText2Table(table, " ", normalFont);
                }
                PdfReports.AddText2Table(table, " ", normalFont, table.NumberOfColumns);
                PdfReports.AddTableNoSplit(document, this, table);

                float[] headerLayout = new float[] { 31.5F, 326.4F, 44.1F, 91.5F, 46.5F };
                table = PdfReports.CreateTable(headerLayout, 1);

                // Add blank lines
                float[]   shareholderLayout = new float[] { 50F, 270F, 220F };
                PdfPTable addrTable         = PdfReports.CreateTable(shareholderLayout, 0);
                PdfReports.AddText2Table(addrTable, " ", normalFont, addrTable.NumberOfColumns);
                PdfReports.AddText2Table(addrTable, " ", normalFont, addrTable.NumberOfColumns);
                PdfReports.AddText2Table(addrTable, " ", normalFont, addrTable.NumberOfColumns);

                if (_pageNumber == 1)
                {
                    string    csz = _city + ", " + _state + " " + _postalCode;
                    Paragraph p   = PdfReports.GetAddressBlock(_growerName, _adr1, _adr2,
                                                               csz, 0F, 12F, iTextSharp.text.Element.ALIGN_LEFT, uspsFont);
                    PdfReports.AddText2Table(addrTable, " ", uspsFont);
                    PdfReports.AddText2Table(addrTable, p);

                    PdfReports.AddText2Table(addrTable, "SHID: " + _shid + "\n" +
                                             "Amount: " + _checkAmount.ToString("N2"), uspsFont, "right");
                    PdfReports.AddText2Table(addrTable, " ", normalFont, addrTable.NumberOfColumns);
                    PdfReports.AddTableNoSplit(document, this, addrTable);

                    PdfReports.AddText2Table(table, " ", normalFont, table.NumberOfColumns);
                    PdfReports.AddText2Table(table, " ", normalFont, table.NumberOfColumns);

                    PdfReports.AddText2Table(table, " ", normalFont);
                    PdfReports.AddText2Table(table, "EH - Early Harvest", normalFont, table.NumberOfColumns - 1);

                    PdfReports.AddText2Table(table, " ", normalFont);
                    PdfReports.AddText2Table(table, "RH - Regular Harvest", normalFont, table.NumberOfColumns - 1);

                    PdfReports.AddText2Table(table, " ", normalFont);
                    PdfReports.AddText2Table(table, "SLM - Sugar Lost to Molasses", normalFont, table.NumberOfColumns - 1);

                    PdfReports.AddText2Table(table, " ", normalFont, table.NumberOfColumns);
                }
                else
                {
                    PdfReports.AddText2Table(addrTable, " ", uspsFont);
                    PdfReports.AddText2Table(addrTable, _growerName, uspsFont);

                    PdfReports.AddText2Table(addrTable, "SHID: " + _shid + "\n" +
                                             "Amount: " + _checkAmount.ToString("N2"), uspsFont, "right");
                    PdfReports.AddText2Table(addrTable, " ", normalFont, addrTable.NumberOfColumns);
                    PdfReports.AddTableNoSplit(document, this, addrTable);

                    PdfReports.AddText2Table(table, " ", normalFont, table.NumberOfColumns);
                    PdfReports.AddText2Table(table, " ", normalFont, table.NumberOfColumns);
                }

                PdfReports.AddTableNoSplit(document, this, table);

                if (_hdrTableLayout != null)
                {
                    PdfPTable hdrTab = PdfReports.CreateTable(_hdrTableLayout, 0);
                    PdfReports.FillHeaderLabels(ref hdrTab, _hdrNameList, labelFont);
                    PdfReports.AddTableNoSplit(document, this, hdrTab);
                }

                _headerBottomYLine = _ct.YLine;
            }

            base.OnStartPage(writer, document);
        }