/// <summary>
        /// Writes the title
        /// </summary>
        public virtual void WriteFundingApplicationApproval(PdfStructureElement tag)
        {
            SetWidths(twelvecolumns);
            SetColumns();

            PdfStructureElement partCover = new PdfStructureElement(tag, new PdfName("Part"));
            content.BeginMarkedContentSequence(partCover);
            content.EndMarkedContentSequence();


            helper.AddLine(1);
            tTable table = new tTable(this, string.Empty);
            table.ParentTag = partCover;

            foreach (var group in helper.Portfolio.Groups)
            {
                WriteApplicationsHeader(table, group.Name);
                WriteApplicationsColumnHeaders(table);
                foreach (var application in group.Applications)
                {
                    WriteApplication(table, (FDApplication)application);
                }

            }

            table.Write();
        }
        public override void GetDetails(PdfStructureElement tag)
        {
            helper.SetMargins(0.75f);
            SetWidths(threecolumns);
            SetColumns();

            var table = new tTable(this, "");
            table.ParentTag = tag;

            // row 1
            var cell = new tCell(0, "H2", it.Element.ALIGN_RIGHT, GrantFonts.BOLD, "SRG:");
            var row = new tRow();
            row.Add(cell);
            row.Add(new tCell(2, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, helper.RFA.Irgcomb));
            table.Add(row);

            // row 2
            cell = new tCell(0, "H2", it.Element.ALIGN_RIGHT, GrantFonts.BOLD, "SRO:");
            row = new tRow();
            row.Add(cell);
            row.Add(new tCell(2, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, helper.RFA.SRAName));
            table.Add(row);

            // row 3
            cell = new tCell(0, "H2", it.Element.ALIGN_RIGHT, GrantFonts.BOLD, "Program Administrator:");
            row = new tRow();
            row.Add(cell);
            row.Add(new tCell(2, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, helper.RFA.ProgramAdmin));
            table.Add(row);

            // row 4
            cell = new tCell(0, "H2", it.Element.ALIGN_RIGHT, GrantFonts.BOLD, "Council Assignment:");
            row = new tRow();
            row.Add(cell);
            row.Add(new tCell(2, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, helper.RFA.CouncilAssignment));
            table.Add(row);

            // row 5
            cell = new tCell(0, "H2", it.Element.ALIGN_RIGHT, GrantFonts.BOLD, "Conflict of Interest:");
            row = new tRow();
            row.Add(cell);
            row.Add(new tCell(2, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, helper.RFA.ConflictOfInterest));
            table.Add(row);

            table.Write();
        }
        private void WriteFundingPlanComments(PdfStructureElement tag)
        {
            if (helper.Portfolio.Information.Comment != string.Empty && helper.Portfolio.Information.Comment.Trim() == string.Empty)
                return;

            SetWidths(twelvecolumns);
            SetColumns();

            PdfStructureElement part = new PdfStructureElement(tag, new PdfName("Part"));
            content.BeginMarkedContentSequence(part);
            content.EndMarkedContentSequence();

            helper.AddLine(1);
            tTable table = new tTable(this, string.Empty);
            table.ParentTag = part;

            var row = new tRow(table);
            var cell = new tCell(0, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, helper.Portfolio.Information.Comment);
            cell.fontSize = 6.0f;
            cell.Colspan = 12;
            row.Add(cell);
            table.Add(row);
            table.Write();

            helper.AddLine(1);
        }
        public void WriteOERApprovalSignature(PdfStructureElement tag)
        {
            if (this.Strategy.isIncludeOERSignature == false)
                return;

            PdfStructureElement part = new PdfStructureElement(tag, new PdfName("Part"));
            content.BeginMarkedContentSequence(part);
            content.EndMarkedContentSequence();

            helper.AddLine(2);
            helper.SetMargins(1f);
            SetWidths(signaturecolumns);
            SetColumns();

            var table = new tTable(this, "");
            table.ParentTag = part;
            table.ColumnCount = Columns.Length;

            var dict = new PdfDictionary();

            // row 1
            var cell = new tCell(0, "P", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "");
            dict = new PdfDictionary();
            dict.Put(PdfName.ACTUALTEXT, new PdfString("Deputy Director OER Approval"));
            cell.Dictionary = dict;
            cell.fontSize = 6.0f;
            var row = new tRow();
            row.Add(cell);

            cell = new tCell(1, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, "");
            dict = new PdfDictionary();
            dict.Put(PdfName.ACTUALTEXT, new PdfString("Date "));
            cell.Dictionary = dict;
            cell.fontSize = 6.0f;
            row.Add(cell);
            table.Add(row);


            //  row 2
            row = new tRow();
            cell = new tCell();
            cell.MakeDoubleLine(0, 2);
            row.Add(cell);
            table.Add(row);


            // row 3
            row = new tRow();
            cell = new tCell(0, "P", "Deputy Director OER Approval");
            cell.isSpoken = false;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(1, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, "Date");
            cell.isSpoken = false;
            cell.fontSize = 6.0f;
            row.Add(cell);
            table.Add(row);

            table.Write();
        }
        public void WriteSignatures(PdfStructureElement tag)
        {
            if (this.Strategy.isIncludeFinalSignature == false)
                return;

            PdfStructureElement part = new PdfStructureElement(tag, new PdfName("Part"));
            content.BeginMarkedContentSequence(part);
            content.EndMarkedContentSequence();

            helper.AddLine(2);
            helper.SetMargins(1f);
            SetWidths(signaturecolumns);
            SetColumns();

            var ChiefGMO = helper.Portfolio.History[1].UpdatedBy;
            var BranchChief = helper.Portfolio.History[0].UpdatedBy;

            var DivisionDirector = helper.Portfolio.History[2].UpdatedBy;
            var NIEHSDirector = helper.Portfolio.History[3].UpdatedBy;

            var BranchChief_ApprovalDate = helper.Portfolio.History[0].UpdateDate.ToString("d");
            var ChiefGMO_ApprovalDate = helper.Portfolio.History[0].UpdateDate.ToString("d");
            var DivisionDirector_ApprovalDate = helper.Portfolio.History[0].UpdateDate.ToString("d");
            var NIEHSDirector_ApprovalDate = helper.Portfolio.History[0].UpdateDate.ToString("d");

            var TitleProxyOrDirector = helper.Portfolio.History[3].ValueOld.Contains("Pending NIEHS Director") ? "Director NIEHS" : "Deputy Director OER";

            var table = new tTable(this, "");
            table.ParentTag = part;
            table.ColumnCount = Columns.Length;

            var dict = new PdfDictionary();

            // row 1
            var cell = new tCell(0, "P", it.Element.ALIGN_LEFT, GrantFonts.BOLD, BranchChief );
            dict = new PdfDictionary();
            dict.Put(PdfName.ACTUALTEXT, new PdfString(string.Format("Branch Chief {0}",BranchChief)));
            cell.Dictionary = dict;
            cell.fontSize = 6.0f;
            var row = new tRow();
            row.Add(cell);

            cell = new tCell(1, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, BranchChief_ApprovalDate);
            dict = new PdfDictionary();
            dict.Put(PdfName.ACTUALTEXT, new PdfString(string.Format("Date {0}", ChiefGMO_ApprovalDate)));
            cell.Dictionary = dict;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(3, "P", it.Element.ALIGN_LEFT, GrantFonts.BOLD, ChiefGMO);
            dict = new PdfDictionary();
            dict.Put(PdfName.ACTUALTEXT, new PdfString(string.Format("Chief GMO {0}",ChiefGMO)));
            cell.Dictionary = dict;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(4, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL,ChiefGMO_ApprovalDate);
            dict = new PdfDictionary();
            dict.Put(PdfName.ACTUALTEXT, new PdfString(string.Format("Date {0}",BranchChief_ApprovalDate)));
            cell.Dictionary = dict;
            cell.fontSize = 6.0f;
            row.Add(cell);

            // 6, 7
            cell = new tCell(6, "P", DivisionDirector);
            dict = new PdfDictionary();
            dict.Put(PdfName.ACTUALTEXT, new PdfString(string.Format("Division Director {0}",DivisionDirector)));
            cell.Dictionary = dict;
            cell.Font = GrantFonts.BOLD;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(7, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, DivisionDirector_ApprovalDate);
            dict = new PdfDictionary();
            dict.Put(PdfName.ACTUALTEXT, new PdfString(string.Format("Date {0}",DivisionDirector_ApprovalDate)));
            cell.Dictionary = dict;
            cell.fontSize = 6.0f;
            row.Add(cell);

            // 9, 10
            cell = new tCell(9, "P", it.Element.ALIGN_LEFT, GrantFonts.BOLD, NIEHSDirector);
            dict = new PdfDictionary();
            dict.Put(PdfName.ACTUALTEXT, new PdfString(string.Format("{0} {1}",TitleProxyOrDirector, NIEHSDirector)));
            cell.Dictionary = dict;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(10, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, NIEHSDirector_ApprovalDate);
            dict = new PdfDictionary();
            dict.Put(PdfName.ACTUALTEXT, new PdfString(string.Format("Date {0}", NIEHSDirector_ApprovalDate)));
            cell.Dictionary = dict;
            cell.fontSize = 6.0f;
            row.Add(cell);
            table.Add(row);


            //  row 2
            row = new tRow();
            cell = new tCell();
            cell.MakeDoubleLine(0, 2);
            row.Add(cell);

            cell = new tCell();
            cell.MakeDoubleLine(3, 2);
            row.Add(cell);

            cell = new tCell();
            cell.MakeDoubleLine(6, 2);
            row.Add(cell);

            cell = new tCell();
            cell.MakeDoubleLine(9, 2);
            row.Add(cell);
            table.Add(row);


            // row 3
            row = new tRow();
            cell = new tCell(0, "P", "Branch Chief"); 
            cell.isSpoken = false;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(1, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, "Date");
            cell.isSpoken = false;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(3, "P", "Chief GMO");
            cell.isSpoken = false;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(4, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, "Date");
            cell.isSpoken = false;
            cell.fontSize = 6.0f;
            row.Add(cell);

            // 6, 7
            cell = new tCell(6, "P", "Division Director");
            cell.isSpoken = false;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(7, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, "Date");
            cell.isSpoken = false;
            cell.fontSize = 6.0f;
            row.Add(cell);

            // 9, 10
            cell = new tCell(9, "P", TitleProxyOrDirector);
            cell.isSpoken = false;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(10, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, "Date");
            cell.isSpoken = false;
            cell.fontSize = 6.0f;
            row.Add(cell);
            table.Add(row);

            table.Write();
        }
        private void WriteApplication(tTable table, FDApplication application)
        {
            var row = new tRow(table);

            var cell = new tCell(0, "TD", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, application.IsActive ? "Approved" : "Disapproved");
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(1, "TD", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, application.SpecialType);
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(2, "TD", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, application.ProjectNumber);
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            var percent = application.IrgPercentileNum == 0 ? "" : application.IrgPercentileNum.ToString();
            cell = new tCell(3, "TD", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, percent);
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            var priorityscore = application.PriorityScoreNum == 0 ? "" : application.PriorityScoreNum.ToString();
            cell = new tCell(4, "TD", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, priorityscore);
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(5, "TD", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, application.PIName);
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(6, "TD", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, application.ProjectTitle);
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(7, "TD", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, application.OrgName);
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(8, "TD", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, application.POName);
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(9, "TD", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, application.RFAPANumber);
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(10, "TD", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, application.DirectCostRequestedAmt);
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);


            cell = new tCell(11, "TD", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, application.ESTotalCostRecommendedAmt);
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            table.Add(row);
        }
        private void WriteApplicationsColumnHeaders(tTable table)
        {
            var row = new tRow(table);

            var cell = new tCell(0, "TH", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, "Approval");
            cell.FontColor = GrantFonts.White;
            cell.Color = GrantFonts.CMWBlue;
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(1, "TH", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, "Type");
            cell.FontColor = GrantFonts.White;
            cell.Color = GrantFonts.CMWBlue;
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(2, "TH", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, "Project Num");
            cell.FontColor = GrantFonts.White;
            cell.Color = GrantFonts.CMWBlue;
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(3, "TH", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, "% Tile");
            cell.FontColor = GrantFonts.White;
            cell.Color = GrantFonts.CMWBlue;
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(4, "TH", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, "PS");
            cell.FontColor = GrantFonts.White;
            cell.Color = GrantFonts.CMWBlue;
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(5, "TH", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, "PI");
            cell.FontColor = GrantFonts.White;
            cell.Color = GrantFonts.CMWBlue;
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(6, "TH", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, "Project Title");
            cell.FontColor = GrantFonts.White;
            cell.Color = GrantFonts.CMWBlue;
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(7, "TH", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, "Institution");
            cell.FontColor = GrantFonts.White;
            cell.Color = GrantFonts.CMWBlue;
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(8, "TH", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, "PO");
            cell.FontColor = GrantFonts.White;
            cell.Color = GrantFonts.CMWBlue;
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(9, "TH", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, "FOA");
            cell.FontColor = GrantFonts.White;
            cell.Color = GrantFonts.CMWBlue;
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(10, "TH", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, "Req DC$");
            cell.FontColor = GrantFonts.White;
            cell.Color = GrantFonts.CMWBlue;
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(11, "TH", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, "ES Rec TC$");
            cell.FontColor = GrantFonts.White;
            cell.Color = GrantFonts.CMWBlue;
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);


            table.Add(row);
        }
        private void WriteApplicationsHeader(tTable table, string name)
        {
            var row = new tRow(table);
            var cell = new tCell(0, "TH", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, name);
            cell.FontColor = GrantFonts.Black;
            cell.Color = GrantFonts.CMWLightBlue;
            cell.Border = Borders.All;
            cell.fontSize = 8.5f;
            cell.Colspan = 12;
            row.Add(cell);

            table.Add(row);
        }
        /// <summary>
        /// Formats text for details section
        /// </summary>
        public override void GetDetails(PdfStructureElement tag)
        {
            helper.AddLine(1);
            helper.SetMargins(0.75f);
            SetWidths(fourcolumns);
            SetColumns();

            var grant = helper.Grant;

            var table = new tTable(this, "");
            table.ParentTag = tag;

            // row 1
            var cell = new tCell(0, "H2", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "Application/ Grant:");
            var row = new tRow();
            row.Add(cell);
            row.Add(new tCell(1, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, grant.FullGrantNum));
            row.Add(new tCell(2, "H2", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "Priority Score/Percentile:"));
            string priority = grant.PriorityScoreNumber.ToString() + "/" + grant.IRGPercentileNum.FormatTwoDecimals();
            row.Add(new tCell(3, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, priority));
            table.Add(row);

            // row 2
            cell = new tCell(0, "H2", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "PI:");
            row = new tRow();
            row.Add(cell);
            row.Add(new tCell(1, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, grant.PIName));
            row.Add(new tCell(2, "H2", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "SRG:"));
            row.Add(new tCell(3, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, grant.Irgcomb));
            table.Add(row);

            // row 3
            cell = new tCell(0, "H2", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "Institution:");
            row = new tRow();
            row.Add(cell);
            row.Add(new tCell(1, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, grant.OrgName));
            row.Add(new tCell(2, "H2", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "SRO:"));
            row.Add(new tCell(3, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, grant.SRAName));
            table.Add(row);

            // row 4
            cell = new tCell(0, "H2", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "Title:");
            row = new tRow();
            row.Add(cell);
            cell = new tCell(1, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, grant.ProjectTitle);
            cell.Colspan = 3;
            row.Add(cell);
            table.Add(row);

            //row 5
            cell = new tCell(0, "H2", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "Last Competing Council Review Date:");
            row = new tRow();
            row.Add(cell);
            cell = new tCell(1, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, grant.OriginalCouncilMeetingDate);
            cell.Colspan = 3;
            row.Add(cell);
            table.Add(row);

            // row 6
            cell = new tCell(0, "H2", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "Current Council Review Date:");
            row = new tRow();
            row.Add(cell);
            row.Add(new tCell(1, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, grant.CouncilMeetingDate));
            row.Add(new tCell(2, "H2", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "Program Administrator:"));
            row.Add(new tCell(3, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, grant.ProgramAdmin));
            table.Add(row);

            // row 7
            cell = new tCell(0, "H2", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "Council Assignment:");
            row = new tRow();
            row.Add(cell);
            row.Add(new tCell(1, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, grant.CouncilAssignment));
            row.Add(new tCell(2, "H2", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "RFA/PA#:"));
            row.Add(new tCell(3, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, grant.RFAPANumber));
            table.Add(row);

            // row 8
            var conflictOfinterest = (grant.ConflictOfInterest.Trim().Length > 0) ? grant.ConflictOfInterest.Trim() : "None Known";
            cell = new tCell(0, "H2", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "Conflict of Interest:");
            row = new tRow();
            row.Add(cell);
            cell = new tCell(1, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, conflictOfinterest);
            cell.Colspan = 3;
            row.Add(cell);
            table.Add(row);
            table.Write();
        }
        /// <summary>
        /// Formats the data for funding details
        /// </summary>
        /// <param name="application">application</param>
        /// <param name="table">table</param>
        public void GetFundingDetails(PdfStructureElement tag)
        {

            float[] fourcolumns = { 1.75f, 1.75f, 1.75f, 1.75f };
            helper.SetMargins(0.75f);
            SetWidths(fourcolumns);
            SetColumns();

            string rHeader = "Funding Details:";
            helper.AddLine(1);
            content.BeginMarkedContentSequence(new PdfStructureElement(tag, new PdfName("H2")));
            content.BeginText();
            content.SetFontAndSize(GrantFonts.bf_times_bold, 12);
            content.ShowTextAligned(it.Element.ALIGN_LEFT, rHeader, document.LeftMargin, helper.CurrentY, 0);
            content.EndText();
            content.EndMarkedContentSequence();
            helper.AddLine();

            var table = new tTable(this, "Table");
            table.ParentTag = tag;

            // row 

            var dict = new PdfDictionary();
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(new PdfName("Scope"), new PdfName("Column"));

            var row = new tRow("TR");
            var cell = new tCell(0, "TH", it.Element.ALIGN_CENTER, GrantFonts.BOLD, "Year");
            cell.Dictionary.Put(PdfName.A, dict);
            row.Add(cell);
            cell = new tCell(1, "TH", it.Element.ALIGN_CENTER, GrantFonts.BOLD, "Direct Cost");
            cell.Dictionary.Put(PdfName.A, dict);
            row.Add(cell);
            cell = new tCell(2, "TH", it.Element.ALIGN_CENTER, GrantFonts.BOLD, "Total Cost");
            cell.Dictionary.Put(PdfName.A, dict);
            row.Add(cell);
            table.Add(row);

            int exist = helper.Grant.FundingDetail.Count;
            int numToAdd = 5 - exist;
            int  lastYear = helper.Grant.FundingDetail.Last().Year;

            for (int ii = 0; ii < numToAdd; ii++)
            {
                int adjust = ii + 1;
                helper.Grant.FundingDetail.Add(new CMWGrantFundingDetail() { Year = lastYear + adjust, DirectCost = 0, TotalCost = 0 });
                
            }

            foreach (var item in helper.Grant.FundingDetail)
            {
                var year = string.Format("{0}", item.Year);
                var dCost = string.Format("{0:C}", item.DirectCost);
                var tCost = string.Format("{0:C}", item.TotalCost);

                row = new tRow("TR");
                cell = new tCell(0, "TD", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, year);
                row.Add(cell);
                row.Add(new tCell(1, "TD", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, dCost));
                row.Add(new tCell(2, "TD", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, tCost));
                table.Add(row);
            }

            table.Write();
        }
        public override void WriteSignatures(PdfStructureElement tag)
        {

            PdfStructureElement part = new PdfStructureElement(tag, new PdfName("Part"));
            content.BeginMarkedContentSequence(part);
            content.EndMarkedContentSequence();

            helper.AddLine(2);
            helper.SetMargins(1f);
            SetWidths(fivecolumns);
            SetColumns();

            CMWApprovalSignature pAdmin = helper.RFA.ApprovalSignatureBlock.ProgramOfficer;
            CMWApprovalSignature bChief = helper.RFA.ApprovalSignatureBlock.BranchChief;
            CMWApprovalSignature dirOEP = helper.RFA.ApprovalSignatureBlock.DirectorOEP;
            CMWApprovalSignature dirDER = helper.RFA.ApprovalSignatureBlock.DirectorDER;

            var table = new tTable(this, "");
            table.ParentTag = part;
            table.ColumnCount = Columns.Length;

            var dict = new PdfDictionary();

            // row 1
            var cell = new tCell(0, "P", it.Element.ALIGN_LEFT, GrantFonts.BOLD, pAdmin.FullName);
            dict = new PdfDictionary();
            dict.Put(PdfName.ACTUALTEXT, new PdfString("Program Administrator " + pAdmin.FullName));
            cell.Dictionary = dict;
            var row = new tRow();
            row.Add(cell);

            cell = new tCell(1, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, pAdmin.ApprovalDate.ToString("d"));
            dict = new PdfDictionary();
            dict.Put(PdfName.ACTUALTEXT, new PdfString("Date " + pAdmin.ApprovalDate.ToString("d")));
            cell.Dictionary = dict;
            row.Add(cell);

            cell = new tCell(3, "P", it.Element.ALIGN_LEFT, GrantFonts.BOLD, bChief.FullName);
            dict = new PdfDictionary();
            dict.Put(PdfName.ACTUALTEXT, new PdfString("Branch Chief " + bChief.FullName));
            cell.Dictionary = dict;
            row.Add(cell);

            cell = new tCell(4, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, bChief.ApprovalDate.ToString("d"));
            dict = new PdfDictionary();
            dict.Put(PdfName.ACTUALTEXT, new PdfString("Date " + bChief.ApprovalDate.ToString("d")));
            cell.Dictionary = dict;
            row.Add(cell);
            table.Add(row);

            //  row 2
            row = new tRow();
            cell = new tCell();
            cell.MakeDoubleLine(0, 2);
            row.Add(cell);

            cell = new tCell();
            cell.MakeDoubleLine(3, 2);
            row.Add(cell);
            table.Add(row);

            // row 3
            row = new tRow();
            cell = new tCell(0, "P", "Program Administrator");
            cell.isSpoken = false;
            row.Add(cell);

            cell = new tCell(1, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, "Date");
            cell.isSpoken = false;
            row.Add(cell);

            cell = new tCell(3, "P", "Branch Chief");
            cell.isSpoken = false;
            row.Add(cell);

            cell = new tCell(4, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, "Date");
            cell.isSpoken = false;
            row.Add(cell);
            table.Add(row);

            // row 4
            row = new tRow();
            table.Add(row);

            // row 5
            row = new tRow();
            cell = new tCell(0, "P", dirOEP.FullName);
            dict = new PdfDictionary();
            dict.Put(PdfName.ACTUALTEXT, new PdfString("Director, Office of Extramural Policy " + dirOEP.FullName));
            cell.Dictionary = dict;
            cell.Font = GrantFonts.BOLD;
            row.Add(cell);

            cell = new tCell(1, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, dirOEP.ApprovalDate.ToString("d"));
            dict = new PdfDictionary();
            dict.Put(PdfName.ACTUALTEXT, new PdfString("Date " + dirOEP.ApprovalDate.ToString("d")));
            cell.Dictionary = dict;
            row.Add(cell);

            string dirDERFullName = (dirDER.IsProxy == false) ? dirDER.FullName : dirDER.FullName + @" for Director, Division of Extramural Research";
            cell = new tCell(3, "P", it.Element.ALIGN_LEFT, GrantFonts.BOLD, dirDERFullName);
            dict = new PdfDictionary();
            dict.Put(PdfName.ACTUALTEXT, new PdfString("Director, Division of Extramural Research " + dirDERFullName));
            cell.Dictionary = dict;
            row.Add(cell);

            cell = new tCell(4, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, dirDER.ApprovalDate.ToString("d"));
            dict = new PdfDictionary();
            dict.Put(PdfName.ACTUALTEXT, new PdfString("Date " + dirDER.ApprovalDate.ToString("d")));
            cell.Dictionary = dict;
            row.Add(cell);
            table.Add(row);

            // row 6
            row = new tRow();
            cell = new tCell();
            cell.MakeDoubleLine(0, 2);
            row.Add(cell);

            cell = new tCell();
            cell.MakeDoubleLine(3, 2);
            row.Add(cell);
            table.Add(row);

            // row 7
            row = new tRow();
            cell = new tCell(0, "P", "Director, Office of Extramural Policy");
            cell.isSpoken = false;
            row.Add(cell);

            cell = new tCell(1, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, "Date");
            cell.isSpoken = false;
            row.Add(cell);

            cell = new tCell(3, "P", "Director, Division of Extramural Research");
            cell.isSpoken = false;
            row.Add(cell);

            cell = new tCell(4, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, "Date");
            cell.isSpoken = false;
            row.Add(cell);
            table.Add(row);

            table.Write();
            AddSignatureComment(part, dirDER);
        }
        /// <summary>
        /// Writes Complex Application Funding Table
        /// </summary>
        public void WriteAppFundingDetails(PdfStructureElement tag)
        {
            int TotalNICHD_DC = 0;
            int TotalOtherIC_DC = 0;
            int TotalGrand_DC = 0;

            int TotalNICHD_TC = 0;
            int TotalOtherIC_TC = 0;
            int TotalGrand_TC = 0;

            // Create part
            PdfStructureElement partFunding = new PdfStructureElement(tag, new PdfName("Part"));
            content.BeginMarkedContentSequence(partFunding);
            content.EndMarkedContentSequence(); // end grant table

            // write the section header including the set aside amount

            helper.AddLine(2);
            string rHeader = "5. Funding Details:";
            content.BeginMarkedContentSequence(new PdfStructureElement(partFunding, new PdfName("H2")));
            content.BeginText();
            content.SetFontAndSize(GrantFonts.bf_times_bold, 12);
            content.ShowTextAligned(it.Element.ALIGN_LEFT, rHeader, document.LeftMargin, helper.CurrentY, 0);
            content.EndText();
            content.EndMarkedContentSequence();
            helper.AddLine();
            rHeader = "Set Aside =" + string.Format("$ {0:#,0}", helper.RFA.SAFundSetAside);
            content.BeginMarkedContentSequence(new PdfStructureElement(partFunding, new PdfName("P")));
            content.BeginText();
            content.SetFontAndSize(GrantFonts.bf_times_bold, 12);
            content.ShowTextAligned(it.Element.ALIGN_LEFT, rHeader, document.LeftMargin, helper.CurrentY, 0);
            content.EndText();
            content.EndMarkedContentSequence();

            helper.AddLine(2);
            helper.SetMargins(0.75f);
            SetWidths(sevencolumns);
            SetColumns();

            var dict = new PdfDictionary();
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(PdfName.ID, new PdfString("funding_details"));
            dict.Put(PdfName.COLSPAN, new PdfNumber(7));
            var list = new PdfArray();

            // New Title Row for the table
            var table = new tTable(this, "Table");
            table.ParentTag = partFunding;
            /*  FUNDING DETAILS  */
            var row = new tRow("TR");
            var cell = new tCell(0, "TH", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "FUNDING DETAILS");
            cell.Dictionary.Put(PdfName.A, dict);
            cell.Colspan = 7;
            cell.FontColor = GrantFonts.White;
            cell.Color = GrantFonts.CMWBlue;
            cell.Border = Borders.All;
            cell.fontSize = 9.5f;
            row.Add(cell);
            table.Add(row);

            /*  FUNDING DETAILS COLUMNS  */
            dict = new PdfDictionary();                                                             /* dictionary PS */
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(new PdfName("Scope"), new PdfName("Column"));
            dict.Put(PdfName.ID, new PdfString("ps"));

            row = new tRow("TR");
            cell = new tCell(0, "TH", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "PS");
            cell.Dictionary.Put(PdfName.A, dict);
            cell.Border = Borders.All;
            cell.VerticalAlign = it.Element.ALIGN_BOTTOM;
            cell.fontSize = 9.5f;
            row.Add(cell);

            dict = new PdfDictionary();                                                             /* dictionary INSTITUTION */
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(new PdfName("Scope"), new PdfName("Column"));
            dict.Put(PdfName.ID, new PdfString("institution"));


            cell = new tCell(1, "TH", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "Institution");
            cell.Dictionary.Put(PdfName.A, dict);
            cell.Border = Borders.All;
            cell.VerticalAlign = it.Element.ALIGN_BOTTOM;
            cell.fontSize = 9.5f;
            row.Add(cell);

            dict = new PdfDictionary();                                                             /* dictionary TITLE */
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(new PdfName("Scope"), new PdfName("Column"));
            dict.Put(PdfName.ID, new PdfString("title"));

            cell = new tCell(2, "TH", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "Title");
            cell.Dictionary.Put(PdfName.A, dict);
            cell.Border = Borders.All;
            cell.VerticalAlign = it.Element.ALIGN_BOTTOM;
            cell.fontSize = 9.5f;
            row.Add(cell);

            dict = new PdfDictionary();                                                             /* dictionary PI REQUESTED DC */
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(new PdfName("Scope"), new PdfName("Column"));
            dict.Put(PdfName.ID, new PdfString("pi"));

            cell = new tCell(3, "TH", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "PI Requested DC");
            cell.Dictionary.Put(PdfName.A, dict);
            cell.Border = Borders.All;
            cell.VerticalAlign = it.Element.ALIGN_BOTTOM;
            cell.fontSize = 9.5f;
            row.Add(cell);

            dict = new PdfDictionary();                                                             /* dictionary FUNDING IC */
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(new PdfName("Scope"), new PdfName("Column"));
            dict.Put(PdfName.ID, new PdfString("funding_ic"));

            cell = new tCell(4, "TH", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "Funding IC");
            cell.Dictionary.Put(PdfName.A, dict);
            cell.Border = Borders.All;
            cell.fontSize = 9.5f;
            row.Add(cell);

            dict = new PdfDictionary();                                                             /* dictionary STAFF REC DIRECT COST */
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(new PdfName("Scope"), new PdfName("Column"));
            dict.Put(PdfName.ID, new PdfString("staff_dc"));

            cell = new tCell(5, "TH", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "Staff Rec Direct Cost");
            cell.Dictionary.Put(PdfName.A, dict);
            cell.Border = Borders.All;
            cell.fontSize = 9.5f;
            row.Add(cell);

            dict = new PdfDictionary();                                                             /* dictionary STAFF REC TOTAL COSTS*/
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(new PdfName("Scope"), new PdfName("Column"));
            dict.Put(PdfName.ID, new PdfString("staff_tc"));

            cell = new tCell(6, "TH", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "Staff Rec Total Costs");
            cell.Dictionary.Put(PdfName.A, dict);
            cell.Border = Borders.All;
            cell.VerticalAlign = it.Element.ALIGN_BOTTOM;
            cell.fontSize = 9.5f;
            row.Add(cell);
            table.Add(row);

            //mainTable = table.ChildTag;

            for (int ii = 0; ii < helper.RFA.Grants.Count(); ii++)
            {
                var grant = helper.RFA.Grants[ii];

                dict = new PdfDictionary();                                                             /* dictionary APPLICATION DETAILS */
                dict.Put(PdfName.O, PdfName.TABLE);
                dict.Put(new PdfName("Scope"), new PdfName("Column"));
                dict.Put(PdfName.ID, new PdfString(grant.FullGrantNum));
                dict.Put(PdfName.COLSPAN, new PdfNumber(7));

                cell = new tCell(0, "TH", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "Application Details for " + grant.FullGrantNum + "/ " + grant.PIName);
                cell.Dictionary.Put(PdfName.A, dict);
                cell.Border = Borders.All;
                cell.Color = GrantFonts.CMWLightBlue;
                cell.fontSize = 9.5f;
                cell.Colspan = 7;
                row = new tRow("TR");
                row.Add(cell);
                table.Add(row);

                /*  FUNDING DETAILS LINE ITEMS */
                for (int jj = 0; jj < grant.FundingDetail.Count(); jj++)
                {
                    var detail = grant.FundingDetail[jj];

                    if (jj == 0)        //////////////////////////////////////////////////////                                                                                                                                                          FIRST ROW
                    {
                        row = new tRow("TR");

                        dict = new PdfDictionary();                                                             /* dictionary  PS */
                        dict.Put(PdfName.O, PdfName.TABLE);
                        dict.Put(new PdfName("Scope"), new PdfName("Column"));
                        list = new PdfArray();
                        list.Add(new PdfString("ps"));
                        list.Add(new PdfString("funding_details"));
                        list.Add(new PdfString(grant.FullGrantNum));
                        dict.Put(PdfName.HEADERS, list);

                        cell = new tCell(0, "TD", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, grant.PriorityScoreNumber.ToString());
                        cell.Dictionary.Put(PdfName.A, dict);
                        cell.Border = Borders.All;
                        cell.VerticalAlign = it.Element.ALIGN_BOTTOM;
                        cell.fontSize = 9.5f;
                        row.Add(cell);
                        //PS

                        dict = new PdfDictionary();                                                             /* dictionary INSTITUTION */
                        dict.Put(PdfName.O, PdfName.TABLE);
                        dict.Put(new PdfName("Scope"), new PdfName("Column"));
                        list = new PdfArray();
                        list.Add(new PdfString("institution"));
                        list.Add(new PdfString("funding_details"));
                        list.Add(new PdfString(grant.FullGrantNum));
                        dict.Put(PdfName.HEADERS, list);

                        cell = new tCell(1, "TD", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, grant.OrgName);
                        cell.Dictionary.Put(PdfName.A, dict);
                        cell.Border = Borders.All;
                        cell.VerticalAlign = it.Element.ALIGN_BOTTOM;
                        cell.fontSize = 9.5f;
                        row.Add(cell);
                        // Institution

                        dict = new PdfDictionary();                                                             /* dictionary TITLE */
                        dict.Put(PdfName.O, PdfName.TABLE);
                        dict.Put(new PdfName("Scope"), new PdfName("Column"));
                        list = new PdfArray();
                        list.Add(new PdfString("title"));
                        list.Add(new PdfString("funding_details"));
                        list.Add(new PdfString(grant.FullGrantNum));
                        dict.Put(PdfName.HEADERS, list);

                        cell = new tCell(2, "TD", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, grant.ProjectTitle);
                        cell.Dictionary.Put(PdfName.A, dict);
                        cell.Border = Borders.All;
                        cell.VerticalAlign = it.Element.ALIGN_BOTTOM;
                        cell.fontSize = 9.5f;
                        row.Add(cell);
                        // Title

                        dict = new PdfDictionary();                                                             /* dictionary PI */
                        dict.Put(PdfName.O, PdfName.TABLE);
                        dict.Put(new PdfName("Scope"), new PdfName("Column"));
                        list = new PdfArray();
                        list.Add(new PdfString("pi"));
                        list.Add(new PdfString("funding_details"));
                        list.Add(new PdfString(grant.FullGrantNum));
                        dict.Put(PdfName.HEADERS, list);

                        cell = new tCell(3, "TD", it.Element.ALIGN_RIGHT, GrantFonts.NORMAL, string.Format("$ {0:#,0}", grant.SRGDirectCost));
                        cell.Dictionary.Put(PdfName.A, dict);
                        cell.Border = Borders.All;
                        cell.VerticalAlign = it.Element.ALIGN_BOTTOM;
                        cell.fontSize = 9.5f;
                        row.Add(cell);
                        // PI Requested DC

                        dict = new PdfDictionary();                                                             /* dictionary FUNDING IC */
                        dict.Put(PdfName.O, PdfName.TABLE);
                        dict.Put(new PdfName("Scope"), new PdfName("Column"));
                        list = new PdfArray();
                        list.Add(new PdfString("funding_ic"));
                        list.Add(new PdfString(grant.FullGrantNum));
                        list.Add(new PdfString("funding_details"));
                        dict.Put(PdfName.HEADERS, list);

                        cell = new tCell(4, "TD", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, detail.SourceName);
                        cell.Dictionary.Put(PdfName.A, dict);
                        cell.Border = Borders.All;
                        cell.VerticalAlign = it.Element.ALIGN_BOTTOM;
                        cell.fontSize = 9.5f;
                        row.Add(cell);
                        //// Funding IC

                        dict = new PdfDictionary();                                                             /* dictionary STAFF REC DIRECT COST */
                        dict.Put(PdfName.O, PdfName.TABLE);
                        dict.Put(new PdfName("Scope"), new PdfName("Column"));
                        list = new PdfArray();
                        list.Add(new PdfString("staff_dc"));
                        list.Add(new PdfString(grant.FullGrantNum));
                        list.Add(new PdfString("funding_details"));
                        dict.Put(PdfName.HEADERS, list);

                        cell = new tCell(5, "TD", it.Element.ALIGN_RIGHT, GrantFonts.NORMAL, string.Format("$ {0:#,0}", detail.DirectCost));
                        cell.Dictionary.Put(PdfName.A, dict);
                        cell.Border = Borders.All;
                        cell.VerticalAlign = it.Element.ALIGN_BOTTOM;
                        cell.fontSize = 9.5f;
                        row.Add(cell);
                        //// Staff Rec Direct Cost

                        dict = new PdfDictionary();                                                             /* dictionary STAFF REC TOTAL COST */
                        dict.Put(PdfName.O, PdfName.TABLE);
                        dict.Put(new PdfName("Scope"), new PdfName("Column"));
                        list = new PdfArray();
                        list.Add(new PdfString("staff_tc"));
                        list.Add(new PdfString(grant.FullGrantNum));
                        list.Add(new PdfString("funding_details"));
                        dict.Put(PdfName.HEADERS, list);

                        cell = new tCell(6, "TD", it.Element.ALIGN_RIGHT, GrantFonts.NORMAL, string.Format("$ {0:#,0}", detail.TotalCost));
                        cell.Dictionary.Put(PdfName.A, dict);
                        cell.Border = Borders.All;
                        cell.VerticalAlign = it.Element.ALIGN_BOTTOM;
                        cell.fontSize = 9.5f;
                        row.Add(cell);
                        table.Add(row);
                        // Staff Rec Total Costs
                    }
                    else        //////////////////////////////////////////////////////                                                                                                                                                          NOT THE FIRST ROW
                    {
                        row = new tRow("TR");

                        cell = new tCell();
                        cell.MakeEmpty(0, 1);
                        cell.Border = Borders.All;
                        row.Add(cell);
                        //PS

                        cell = new tCell();
                        cell.MakeEmpty(1, 1);
                        cell.Border = Borders.All;
                        row.Add(cell);
                        // Institution

                        cell = new tCell();
                        cell.MakeEmpty(2, 1);
                        cell.Border = Borders.All;
                        row.Add(cell);
                        // Title

                        cell = new tCell();
                        cell.MakeEmpty(3, 1);
                        cell.Border = Borders.All;
                        row.Add(cell);
                        // PI Requested DC

                        string sourceID = grant.FullGrantNum + "_" + detail.SourceName;

                        dict = new PdfDictionary();                                                             /* dictionary  FUNDING IC*/
                        dict.Put(PdfName.O, PdfName.TABLE);
                        dict.Put(new PdfName("Scope"), new PdfName("Row"));
                        dict.Put(PdfName.ID, new PdfString(sourceID));
                        dict.Put(PdfName.COLSPAN, new PdfNumber(5));

                        cell = new tCell(4, "TH", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, detail.SourceName);
                        cell.Dictionary.Put(PdfName.A, dict);
                        cell.Border = Borders.All;
                        cell.VerticalAlign = it.Element.ALIGN_BOTTOM;
                        cell.fontSize = 9.5f;
                        row.Add(cell);
                        //// Funding IC


                        dict = new PdfDictionary();                                                             /* dictionary STAFF REC DIRECT COST*/
                        dict.Put(PdfName.O, PdfName.TABLE);
                        dict.Put(new PdfName("Scope"), new PdfName("Column"));
                        list = new PdfArray();
                        list.Add(new PdfString("staff_dc"));
                        list.Add(new PdfString(sourceID));
                        list.Add(new PdfString(grant.FullGrantNum));
                        list.Add(new PdfString("funding_details"));
                        dict.Put(PdfName.HEADERS, list);

                        cell = new tCell(5, "TD", it.Element.ALIGN_RIGHT, GrantFonts.NORMAL, string.Format("$ {0:#,0}", detail.DirectCost));
                        cell.Dictionary.Put(PdfName.A, dict);
                        cell.Border = Borders.All;
                        cell.VerticalAlign = it.Element.ALIGN_BOTTOM;
                        cell.fontSize = 9.5f;
                        row.Add(cell);
                        //// Staff Rec Direct Cost

                        dict = new PdfDictionary();                                                             /* dictionary STAFF REC TOTAL COST */
                        dict.Put(PdfName.O, PdfName.TABLE);
                        dict.Put(new PdfName("Scope"), new PdfName("Column"));
                        list = new PdfArray();
                        list.Add(new PdfString("staff_tc"));
                        list.Add(new PdfString(sourceID));
                        list.Add(new PdfString(grant.FullGrantNum));
                        list.Add(new PdfString("funding_details"));
                        dict.Put(PdfName.HEADERS, list);

                        cell = new tCell(6, "TD", it.Element.ALIGN_RIGHT, GrantFonts.NORMAL, string.Format("$ {0:#,0}", detail.TotalCost));
                        cell.Dictionary.Put(PdfName.A, dict);
                        cell.Border = Borders.All;
                        cell.VerticalAlign = it.Element.ALIGN_BOTTOM;
                        cell.fontSize = 9.5f;
                        row.Add(cell);
                        table.Add(row);
                        // Staff Rec Total Costs
                    }


                    /*
                                                                                                                                Direct and Total Costs
                    */
                    if (detail.SourceName.Trim().Equals("NICHD", StringComparison.InvariantCultureIgnoreCase))
                    {
                        TotalNICHD_DC += detail.DirectCost;
                        TotalNICHD_TC += detail.TotalCost;
                    }
                    else
                    {
                        TotalOtherIC_DC += detail.DirectCost;
                        TotalOtherIC_TC += detail.TotalCost;
                    }
                    TotalGrand_DC += detail.DirectCost;
                    TotalGrand_TC += detail.TotalCost;
                }
            }

            /*  FUNDING TOTALS */
            row = new tRow("TR");

            dict = new PdfDictionary();                                                             /* dictionary FUNDING TOTALS */
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(PdfName.ID, new PdfString("funding_totals"));
            dict.Put(PdfName.COLSPAN, new PdfNumber(7));

            cell = new tCell(0, "TH", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "FUNDING TOTALS");
            cell.Dictionary = dict;
            cell.Colspan = 7;
            cell.FontColor = GrantFonts.White;
            cell.Color = GrantFonts.CMWBlue;
            cell.Border = Borders.All;
            cell.fontSize = 9.5f;
            row.Add(cell);
            table.Add(row);
            // Funding Totals

            /*  FUNDING TOTALS LINE ITEMS*/
            dict = new PdfDictionary();                                                             /* dictionary Total NICHD */
            dict.Put(PdfName.ID, new PdfString("total_nichd"));
            dict.Put(PdfName.COLSPAN, new PdfNumber(5));
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(new PdfName("Scope"), new PdfName("Row"));

            row = new tRow("TR");
            cell = new tCell(0, "TH", it.Element.ALIGN_RIGHT, GrantFonts.BOLD, "Total NICHD");
            cell.Colspan = 5;
            cell.Border = Borders.All;
            cell.fontSize = 9.5f;
            row.Add(cell);
            // Total NICHD

            dict = new PdfDictionary();                                                             /* dictionary DC */
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(new PdfName("Scope"), new PdfName("Column"));
            list = new PdfArray();
            list.Add(new PdfString("staff_dc"));
            list.Add(new PdfString("funding_totals"));
            list.Add(new PdfString("total_nichd"));
            dict.Put(PdfName.HEADERS, list);

            cell = new tCell(5, "TD", it.Element.ALIGN_RIGHT, GrantFonts.NORMAL, string.Format("$ {0:#,0}", TotalNICHD_DC));
            cell.Dictionary.Put(PdfName.A, dict);
            cell.Border = Borders.All;
            cell.fontSize = 9.5f;
            row.Add(cell);

            dict = new PdfDictionary();                                                             /* dictionary TC */
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(new PdfName("Scope"), new PdfName("Column"));
            list = new PdfArray();
            list.Add(new PdfString("staff_tc"));
            list.Add(new PdfString("funding_totals"));
            list.Add(new PdfString("total_nichd"));
            dict.Put(PdfName.HEADERS, list);

            cell = new tCell(6, "TD", it.Element.ALIGN_RIGHT, GrantFonts.NORMAL, string.Format("$ {0:#,0}", TotalNICHD_TC));
            cell.Dictionary.Put(PdfName.A, dict);
            cell.Border = Borders.All;
            cell.fontSize = 9.5f;
            row.Add(cell);
            table.Add(row);

            dict = new PdfDictionary();                                                             /* dictionary Total From All Other ICs*/
            dict.Put(PdfName.ID, new PdfString("total_from"));
            dict.Put(PdfName.COLSPAN, new PdfNumber(5));
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(new PdfName("Scope"), new PdfName("Row"));

            row = new tRow("TR");
            cell = new tCell(0, "TH", it.Element.ALIGN_RIGHT, GrantFonts.BOLD, "Total From All Other ICs");
            cell.Colspan = 5;
            cell.fontSize = 9.5f;
            cell.Border = Borders.All;
            row.Add(cell);
            // Total From All Other ICs

            dict = new PdfDictionary();                                                             /* dictionary DC */
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(new PdfName("Scope"), new PdfName("Column"));
            list = new PdfArray();
            list.Add(new PdfString("staff_dc"));
            list.Add(new PdfString("total_from"));
            list.Add(new PdfString("funding_totals"));
            dict.Put(PdfName.HEADERS, list);

            cell = new tCell(5, "TD", it.Element.ALIGN_RIGHT, GrantFonts.NORMAL, string.Format("$ {0:#,0}", TotalOtherIC_DC));
            cell.Dictionary.Put(PdfName.A, dict);
            cell.Border = Borders.All;
            cell.fontSize = 9.5f;
            row.Add(cell);

            dict = new PdfDictionary();                                                             /* dictionary TC */
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(new PdfName("Scope"), new PdfName("Column"));
            list = new PdfArray();
            list.Add(new PdfString("staff_tc"));
            list.Add(new PdfString("total_from"));
            list.Add(new PdfString("funding_totals"));
            dict.Put(PdfName.HEADERS, list);

            cell = new tCell(6, "TD", it.Element.ALIGN_RIGHT, GrantFonts.NORMAL, string.Format("$ {0:#,0}", TotalOtherIC_TC));
            cell.Dictionary.Put(PdfName.A, dict);
            cell.Border = Borders.All;
            cell.fontSize = 9.5f;
            row.Add(cell);
            table.Add(row);

            dict = new PdfDictionary();                                                             /* dictionary GRAND TOTAL */
            dict.Put(PdfName.ID, new PdfString("grand_total"));
            dict.Put(PdfName.COLSPAN, new PdfNumber(5));
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(new PdfName("Scope"), new PdfName("Row"));

            row = new tRow("TR");
            cell = new tCell(0, "TH", it.Element.ALIGN_RIGHT, GrantFonts.BOLD, "GRAND TOTAL");
            cell.Colspan = 5;
            cell.fontSize = 9.5f;
            cell.Border = Borders.All;
            row.Add(cell);
            // GRAND TOTAL

            dict = new PdfDictionary();                                                             /* dictionary DC */
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(new PdfName("Scope"), new PdfName("Column"));
            list = new PdfArray();
            list.Add(new PdfString("staff_dc"));
            list.Add(new PdfString("grand_total"));
            list.Add(new PdfString("funding_totals"));
            dict.Put(PdfName.HEADERS, list);

            cell = new tCell(5, "TD", it.Element.ALIGN_RIGHT, GrantFonts.NORMAL, string.Format("$ {0:#,0}", TotalGrand_DC));
            cell.Dictionary.Put(PdfName.A, dict);
            cell.Border = Borders.All;
            cell.fontSize = 9.5f;
            row.Add(cell);

            dict = new PdfDictionary();                                                             /* dictionary TC */
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(new PdfName("Scope"), new PdfName("Column"));
            list = new PdfArray();
            list.Add(new PdfString("staff_tc"));
            list.Add(new PdfString("grand_total"));
            list.Add(new PdfString("funding_totals"));
            dict.Put(PdfName.HEADERS, list);

            cell = new tCell(6, "TD", it.Element.ALIGN_RIGHT, GrantFonts.NORMAL, string.Format("$ {0:#,0}", TotalGrand_TC));
            cell.Dictionary.Put(PdfName.A, dict);
            cell.Border = Borders.All;
            cell.fontSize = 9.5f;
            row.Add(cell);
            table.Add(row);

            table.Write();
        }
        /// <summary>
        /// Get Details for Application Recommendation
        /// </summary>
        public void GetDetailsAppRecommendation(PdfStructureElement tag, CMWGrant grant)
        {
            PdfStructureElement partIndiv = new PdfStructureElement(tag, new PdfName("Part"));
            content.BeginMarkedContentSequence(partIndiv);
            content.EndMarkedContentSequence();

            var table = new tTable(this, "");
            table.ParentTag = partIndiv;

            // row 1
            var cell = new tCell(0, "H2", it.Element.ALIGN_RIGHT, GrantFonts.BOLD, "Application/Grant #:");
            var row = new tRow();
            row.Add(cell);
            row.Add(new tCell(2, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, grant.FullGrantNum));
            table.Add(row);

            // row 2
            cell = new tCell(0, "H2", it.Element.ALIGN_RIGHT, GrantFonts.BOLD, "Principal Investigator:");
            row = new tRow();
            row.Add(cell);
            row.Add(new tCell(2, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, grant.PIName));
            table.Add(row);

            // row 3
            cell = new tCell(0, "H2", it.Element.ALIGN_RIGHT, GrantFonts.BOLD, "Institution:");
            row = new tRow();
            row.Add(cell);
            row.Add(new tCell(2, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, grant.OrgName));
            table.Add(row);

            // row 4
            cell = new tCell(0, "H2", it.Element.ALIGN_RIGHT, GrantFonts.BOLD, "Title:");
            row = new tRow();
            row.Add(cell);
            row.Add(new tCell(2, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, grant.ProjectTitle));
            table.Add(row);

            var numerator = new NICHDMATH(grant.PriorityScoreNumber);
            var denominator = new NICHDMATH(grant.IRGPercentileNum);
            var answer = numerator / denominator;

            // row 4
            cell = new tCell(0, "H2", it.Element.ALIGN_RIGHT, GrantFonts.BOLD, @"PS/%ile:");
            row = new tRow();
            row.Add(cell);
            row.Add(new tCell(2, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, answer.Value.ToString()));
            table.Add(row);
            table.Write();

            string rHeader = "Recommendation:";
            helper.AddLine(2);
            content.BeginMarkedContentSequence(new PdfStructureElement(partIndiv, new PdfName("H2")));
            content.BeginText();
            content.SetFontAndSize(GrantFonts.bf_times_bold, 12);
            content.ShowTextAligned(it.Element.ALIGN_LEFT, rHeader, document.LeftMargin, helper.CurrentY, 0);
            content.EndText();
            content.EndMarkedContentSequence();

            helper.AddLine(2);
            float YPosition = AddTextAppRecommendation(partIndiv, grant, helper.CurrentY);
            helper.GetLineFromY(YPosition);

        }
        /// <summary>
        /// Get Details for Competition
        /// </summary>
        public void GetDetailsCompetition(PdfStructureElement tag)
        {
            helper.AddLine(1);
            helper.SetMargins(0.75f);
            SetWidths(threecolumns);
            SetColumns();

            var table = new tTable(this, "");
            table.ParentTag = tag;

            // row 1
            var cell = new tCell(0, "H2", it.Element.ALIGN_RIGHT, GrantFonts.BOLD, "Application Received:");
            var row = new tRow();
            row.Add(cell);
            row.Add(new tCell(2, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, helper.RFA.AppsReceived.ToString()));
            table.Add(row);


            // row 2
            cell = new tCell(0, "H2", it.Element.ALIGN_RIGHT, GrantFonts.BOLD, "Nonresponsive Applications:");
            row = new tRow();
            row.Add(cell);
            row.Add(new tCell(2, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, helper.RFA.AppsNonResponsive.ToString()));
            table.Add(row);


            // row 4
            cell = new tCell(0, "H2", it.Element.ALIGN_RIGHT, GrantFonts.BOLD, "Noncompetitive Applications:");
            row = new tRow();
            row.Add(cell);
            row.Add(new tCell(2, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, helper.RFA.AppsNonCompetitive.ToString()));
            table.Add(row);

            // row 5
            cell = new tCell(0, "H2", it.Element.ALIGN_RIGHT, GrantFonts.BOLD, "Competitive Applications:");
            row = new tRow();
            row.Add(cell);
            row.Add(new tCell(2, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, helper.RFA.AppsCompetitive.ToString()));
            table.Add(row);

            table.Write();
        }