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; // ======================================================= // Add Header: Logo 2010 // ======================================================= PdfPTable logoTable = PdfReports.CreateTable(_logo2010Layout, 0); // Only add actual logo on First Page of set Paragraph p = new Paragraph("", _normalFont); 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); PdfReports.AddTableNoSplit(document, this, logoTable); float[] addrLayout = new float[] { _primaryLeftIndent, 540F - _primaryLeftIndent - _primaryRightIndent, _primaryRightIndent }; PdfPTable addrTable = PdfReports.CreateTable(addrLayout, 0); // Blank PdfReports.AddText2Table(addrTable, " ", _normalFont, addrLayout.Length); PdfReports.AddText2Table(addrTable, " ", _normalFont, addrLayout.Length); PdfReports.AddTableNoSplit(document, this, addrTable); //----------------------------------------------- // Address block //----------------------------------------------- addrTable = PdfReports.CreateTable(addrLayout, 0); // SHID ONLY PdfReports.AddText2Table(addrTable, " ", _normalFont); PdfReports.AddText2Table(addrTable, "Shareholder ID#: " + _shid, _uspsFont, "right"); PdfReports.AddText2Table(addrTable, " ", _normalFont); PdfReports.AddText2Table(addrTable, " ", _normalFont, addrLayout.Length); // Modified address block: address only. 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, " ", _uspsFont, addrLayout.Length); PdfReports.AddText2Table(addrTable, " ", _uspsFont, addrLayout.Length); PdfReports.AddText2Table(addrTable, " ", _uspsFont, addrLayout.Length); PdfReports.AddTableNoSplit(document, this, addrTable); _headerBottomYLine = _ct.YLine; } base.OnStartPage(writer, document); }
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); }
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); }
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); }
public override void OnStartPage(PdfWriter writer, Document document) { int borderTypeAll = Rectangle.TOP_BORDER | Rectangle.RIGHT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.LEFT_BORDER; 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[] { 320F, 180F, 40F }; PdfPTable table = PdfReports.CreateTable(layout, 0); PdfReports.AddText2Table(table, _title + "\n", _titleFont, "center", layout.Length); PdfReports.AddText2Table(table, " ", _normalFont, layout.Length); //PdfReports.AddText2Table(table, " ", _normalFont, layout.Length); PdfReports.AddText2Table(table, _statementDate, _normalFont, "left"); //PdfReports.AddText2Table(table, " ", _normalFont); iTextSharp.text.pdf.PdfPCell cell = PdfReports.AddText2Cell("URGENT TAX\n" + "NOTIFICATION", _superTitleFont, PdfPCell.ALIGN_CENTER, PdfPCell.ALIGN_BOTTOM, 3F, 1.0F, borderTypeAll, Color.BLACK); table.AddCell(cell); PdfReports.AddText2Table(table, " ", _normalFont); PdfReports.AddText2Table(table, " ", _superTitleFont, layout.Length); // larger font to push address line down PdfReports.AddTableNoSplit(document, this, table); // Address string csz = _city + ", " + _state + " " + _postalCode; Paragraph p = PdfReports.GetAddressBlock(_memberName, _adr1, _adr2, csz, 0F, 12F, iTextSharp.text.Element.ALIGN_LEFT, _uspsFont); float[] addrLayout = new float[] { 50F, 270F, 220F }; table = PdfReports.CreateTable(addrLayout, 0); PdfReports.AddText2Table(table, " ", _normalFont); PdfReports.AddText2Table(table, p); PdfReports.AddText2Table(table, " ", _normalFont); PdfReports.AddText2Table(table, " ", _normalFont, layout.Length); PdfReports.AddText2Table(table, " ", _normalFont, layout.Length); PdfReports.AddTableNoSplit(document, this, table); _headerBottomYLine = _ct.YLine; } base.OnStartPage(writer, document); }
public static void ReportBuilder(int cropYear, int contractNumber, string logoUrl, System.IO.FileStream fs) { const string METHOD_NAME = "ReportBuilder"; Document document = null; PdfWriter writer = null; PdfPTable table = null; ContractDeliverySummaryEvent pgEvent = null; iTextSharp.text.Image imgLogo = null; int contractID = 0; int stationNo = 0; int factoryNo = 0; int acresContracted = 0; int acresHarvested = 0; int acresLost = 0; int acresPlanted = 0; try { if (document == null) { // IF YOU CHANGE MARGINS, CHANGE YOUR TABLE LAYOUTS !!! // *** US LETTER: 612 X 792 *** // margins: L, R, T, B //document = new Document(iTextSharp.text.PageSize.LETTER, 36, 36, 54, 72); 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); imgLogo = PdfReports.GetImage(logoUrl, 127, 50, iTextSharp.text.Element.ALIGN_CENTER); // Attach my override event handler(s) pgEvent = new ContractDeliverySummaryEvent(); pgEvent.FillEvent(imgLogo, cropYear.ToString()); writer.PageEvent = pgEvent; // Open the document document.Open(); } // ======================================================= // Build Report // ======================================================= int staExSugar = 0; int ftyExSugar = 0; decimal extractableSugarPerTon = 0; PdfPTable addrTable = null; List <ContractGorwerLandownerItem> stateList = WSCReportsExec.ContractDeliverySummary1(cropYear, contractNumber); float[] addrLayout = new float[] { 9.3F, 67.6F, 23.1F }; addrTable = PdfReports.CreateTable(addrLayout, 0); if (stateList.Count > 0) { ContractGorwerLandownerItem item = stateList[0]; PdfReports.AddText2Table(addrTable, "Contract", _normalFont); PdfReports.AddText2Table(addrTable, "Grower#: " + item.Gro_Address_Number, _normalFont); PdfReports.AddText2Table(addrTable, "Landowner#: " + item.Ldo_Address_Number, _normalFont); PdfReports.AddText2Table(addrTable, item.Contract_Number, _normalFont); Paragraph p = PdfReports.GetAddressBlock(item.Grower_Name, item.Gro_Address_1, item.Gro_Address_2, item.Grower_City + ", " + item.Grower_State + " " + item.Grower_Zip, 0F, 12F, iTextSharp.text.Element.ALIGN_LEFT, _uspsFont); PdfReports.AddText2Table(addrTable, p); p = PdfReports.GetAddressBlock(item.Landowner_Name, item.Ldo_Address_1, item.Ldo_Address_2, item.Ldo_City + ", " + item.Ldo_State + " " + item.Ldo_Zip, 0F, 12F, iTextSharp.text.Element.ALIGN_LEFT, _normalFont); PdfReports.AddText2Table(addrTable, p); PdfReports.AddText2Table(addrTable, " ", _normalFont, 3); PdfReports.AddText2Table(addrTable, " ", _normalFont, 3); PdfReports.AddTableNoSplit(document, pgEvent, addrTable); acresContracted = item.Contract_Acres; acresHarvested = item.Harvest_Acres; acresPlanted = item.Planted_Acres; acresLost = acresPlanted - acresHarvested; contractID = item.cnt_contract_id; stationNo = Convert.ToInt32(item.Station_Number); factoryNo = Convert.ToInt32(item.Factory_Number); } table = PdfReports.CreateTable(_primaryTableLayout, 0); List <ContractDeliverySummary2Item> cntDelSumList = WSCReportsExec.ContractDeliverySummary2(contractID); if (cntDelSumList.Count > 0) { ContractDeliverySummary2Item cntdsItem = cntDelSumList[0]; PdfReports.AddText2Table(table, "Contract Tons: " + cntdsItem.ContractTons.ToString("#,###.0000"), _normalFont, 3); PdfReports.AddText2Table(table, "Contract % Sugar: " + cntdsItem.SugarPct.ToString("0.00") + "%", _normalFont, 3); PdfReports.AddText2Table(table, "Contract % SLM: " + cntdsItem.SLMPct.ToString("0.0000") + "%", _normalFont, 3); string tonsPerAcre = null; if (acresHarvested == 0) { tonsPerAcre = String.Format("{0:#,##0.00}", 0); } else { tonsPerAcre = (cntdsItem.ContractTons / acresHarvested).ToString("#,###.00"); } PdfReports.AddText2Table(table, "Tons Per Acre: " + tonsPerAcre, _normalFont, 3); PdfReports.AddText2Table(table, " ", _normalFont, 3); extractableSugarPerTon = cntdsItem.ExtractableSugarPerTon; PdfReports.AddText2Table(table, "Pounds Extractable Sugar Per Ton Contract: " + extractableSugarPerTon.ToString("#,##0"), _normalFont, 3); } int factoryExtSugarAvg, stationExtSugarAvg; WSCReportsExec.FactoryStationGetExtractSugarAvg(factoryNo, stationNo, cropYear, out factoryExtSugarAvg, out stationExtSugarAvg); if (stationExtSugarAvg != 0) { PdfReports.AddText2Table(table, "Pounds Extractable Sugar Per Ton Receiving Station: " + stationExtSugarAvg.ToString("#,##0"), _normalFont, 3); } if (factoryExtSugarAvg != 0) { PdfReports.AddText2Table(table, "Pounds Extractable Sugar Per Ton Factory: " + factoryExtSugarAvg.ToString("#,##0"), _normalFont, 3); } string percentOfStation = String.Format("{0:##0.00}", 0); string percentOfFactory = String.Format("{0:##0.00}", 0); if (stationExtSugarAvg != 0) { percentOfStation = String.Format("{0:##0.00}", (extractableSugarPerTon / stationExtSugarAvg) * 100); } if (factoryExtSugarAvg != 0) { percentOfFactory = String.Format("{0:##0.00}", (extractableSugarPerTon / factoryExtSugarAvg) * 100); } PdfReports.AddText2Table(table, "Percent of Station: " + percentOfStation + "%", _normalFont, 3); PdfReports.AddText2Table(table, "Percent of Factory: " + percentOfFactory + "%", _normalFont, 3); PdfReports.AddText2Table(table, " ", _normalFont, 3); PdfReports.AddText2Table(table, "Acres Contracted: " + acresContracted.ToString("#,##0"), _normalFont, 3); PdfReports.AddText2Table(table, "Acres Planted: " + acresPlanted.ToString("#,##0"), _normalFont, 3); PdfReports.AddText2Table(table, "Acres Lost: " + acresLost.ToString("#,##0"), _normalFont, 3); PdfReports.AddText2Table(table, "Acres Harvested: " + acresHarvested.ToString("#,##0"), _normalFont, 3); PdfReports.AddTableNoSplit(document, pgEvent, table); // ====================================================== // Close document // ====================================================== if (document != null) { pgEvent.IsDocumentClosing = true; document.Close(); document = null; } if (addrTable == 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(); } } }
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 Report Header // ======================================================= float[] headerLayout = new float[] { 40F, 120F, 220F, 160F }; PdfPTable table = PdfReports.CreateTable(headerLayout, 1); if (_isSummary) { PdfReports.AddText2Table(table, "Process Summary", _titleFont, "center", headerLayout.Length); PdfReports.AddText2Table(table, " ", _normalFont, headerLayout.Length); PdfReports.AddText2Table(table, " ", _normalFont, headerLayout.Length); PdfReports.AddTableNoSplit(document, this, table); } else { PdfReports.AddText2Table(table, " ", _normalFont, headerLayout.Length); PdfReports.AddText2Table(table, _contractNumber.ToString(), _normalFont); PdfReports.AddText2Table(table, " ", _normalFont); PdfReports.AddText2Table(table, _title, _titleFont, "center"); PdfReports.AddText2Table(table, " ", _normalFont); PdfReports.AddTableNoSplit(document, this, table); float[] addrLayout = new float[] { 50F, 270F, 220F }; PdfPTable addrTable = PdfReports.CreateTable(addrLayout, 0); PdfReports.AddText2Table(addrTable, " ", _normalFont, addrLayout.Length); PdfReports.AddText2Table(addrTable, " ", _normalFont, addrLayout.Length); PdfReports.AddText2Table(addrTable, " ", _normalFont, addrLayout.Length); PdfReports.AddText2Table(addrTable, " ", _normalFont, addrLayout.Length); if (_pageNumber == 1) { PdfReports.AddText2Table(addrTable, _contractNumber.ToString(), _normalFont); // Left column: Full Mailling Address Paragraph p = PdfReports.GetAddressBlock(_busName, _address1, _address2, _csz, 0F, 12F, iTextSharp.text.Element.ALIGN_LEFT, _uspsFont); PdfReports.AddText2Table(addrTable, p); // Right column: shid / tax id PdfReports.AddText2Table(addrTable, "Factory: " + _factoryNo, _normalFont, "right"); } else { // Left column PdfReports.AddText2Table(addrTable, _contractNumber.ToString(), _normalFont); PdfReports.AddText2Table(addrTable, _busName, _normalFont); // Right column PdfReports.AddText2Table(addrTable, "Factory: " + _factoryNo, _normalFont, "right"); } PdfReports.AddText2Table(addrTable, " ", _normalFont, addrLayout.Length); PdfReports.AddText2Table(addrTable, " ", _normalFont, addrLayout.Length); PdfReports.AddText2Table(addrTable, " ", _normalFont, addrLayout.Length); PdfReports.AddTableNoSplit(document, this, addrTable); 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); }
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); }
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); }
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); }
private static void ReportBuilder(SqlDataReader dr, int cropYear, string logoUrl, System.IO.FileStream fs) { const string METHOD_NAME = "rptFieldContracting.ReportBuilder: "; string rptTitle = ""; StringBuilder sb = new StringBuilder(); Document document = null; PdfWriter writer = null; PdfPTable table = null; ContractingReportEvent pgEvent = null; iTextSharp.text.Image imgLogo = null; Font titleFont = FontFactory.GetFont("HELVETICA", 12F, Font.BOLD); Font subTitleFont = FontFactory.GetFont("HELVETICA", 9F, Font.NORMAL); Font headerFont = FontFactory.GetFont("HELVETICA", 8F, Font.NORMAL); Font normalFont = FontFactory.GetFont("HELVETICA", 8F, Font.NORMAL); Font labelFont = FontFactory.GetFont("HELVETICA", 8F, Font.BOLD); try { while (dr.Read()) { try { if (document == null) { // IF YOU CHANGE MARGINS, CHANGE YOUR TABLE LAYOUTS !!! // *** US LETTER: 612 X 792 *** //document = new Document(iTextSharp.text.PageSize.LETTER, 36, 36, 54, 72); 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); imgLogo = PdfReports.GetImage(logoUrl, 127, 50, iTextSharp.text.Element.ALIGN_CENTER); rptTitle = cropYear.ToString() + " Shareholder Contracting\nJanuary 15th through March 30th"; // Attach my override event handler(s) pgEvent = new ContractingReportEvent(); pgEvent.FillEvent(DateTime.Now.ToShortDateString(), 0, rptTitle, imgLogo); writer.PageEvent = pgEvent; // Open the document document.Open(); } // ====================================================== // Generate a new page. // ====================================================== if (table != null) { pgEvent.FillEvent(DateTime.Now.ToShortDateString(), 0, rptTitle, imgLogo); document.NewPage(); } // ====================================================== // Shareholder Block // ====================================================== string cntNo = "Contract #: " + dr.GetString(dr.GetOrdinal("cntg_contract_no")); float[] addrLayout = new float[] { 270F, 270F }; table = PdfReports.CreateTable(addrLayout, 0); PdfReports.AddText2Table(table, "\nSHID: " + dr.GetString(dr.GetOrdinal("cntg_shid")), normalFont, "left"); PdfReports.AddText2Table(table, cntNo, normalFont, "right"); Paragraph p = PdfReports.GetAddressBlock(dr.GetString(dr.GetOrdinal("cntg_business_name")), dr.GetString(dr.GetOrdinal("cntg_address1")), dr.GetString(dr.GetOrdinal("cntg_address2")), dr.GetString(dr.GetOrdinal("cntg_city")) + ", " + dr.GetString(dr.GetOrdinal("cntg_state")) + " " + dr.GetString(dr.GetOrdinal("cntg_zip")), 0F, 15F, iTextSharp.text.Element.ALIGN_LEFT, normalFont); PdfReports.AddText2Table(table, p); string landOwner = "Land Owner: " + dr.GetString(dr.GetOrdinal("cntg_landowner_name")); PdfReports.AddText2Table(table, landOwner, normalFont, "right"); // Add a blank line. PdfReports.AddText2Table(table, " ", normalFont, "center", addrLayout.Length); PdfReports.AddTableNoSplit(document, pgEvent, table); // ====================================================== // Legal Land Description // ====================================================== // *** ROW 1 *** float[] tmpLayout = new float[] { 13F, 13.5F, 11F, 13.5F, 11F, 13.5F, 11F, 13.5F }; table = PdfReports.CreateTable(tmpLayout, 0); PdfReports.AddText2Table(table, "Field Name: ", labelFont); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_field_name")), normalFont); PdfReports.AddText2Table(table, "Acres: ", labelFont); PdfReports.AddText2Table(table, dr.GetInt32(dr.GetOrdinal("cntg_acres")).ToString(), normalFont); PdfReports.AddText2Table(table, "State: ", labelFont); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_lld_state")), normalFont); PdfReports.AddText2Table(table, "County: ", labelFont); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_lld_county")), normalFont); // *** ROW 2 *** PdfReports.AddText2Table(table, "1/4 Quadrant: ", labelFont); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_lld_quarter_quadrant")), normalFont); PdfReports.AddText2Table(table, "Quadrant: ", labelFont); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_lld_quadrant")), normalFont); PdfReports.AddText2Table(table, "Section: ", labelFont); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_lld_section")), normalFont); PdfReports.AddText2Table(table, "Township: ", labelFont); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_lld_township")), normalFont); // *** ROW 3 *** PdfReports.AddText2Table(table, "Range: ", labelFont); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_lld_range")), normalFont); PdfReports.AddText2Table(table, "Latitude: ", labelFont); PdfReports.AddText2Table(table, dr.GetDecimal(dr.GetOrdinal("cntg_latitude")).ToString(), normalFont); PdfReports.AddText2Table(table, "Longitude: ", labelFont); PdfReports.AddText2Table(table, dr.GetDecimal(dr.GetOrdinal("cntg_longitude")).ToString(), normalFont); PdfReports.AddText2Table(table, "FSA Official: ", labelFont); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_fsa_official")), normalFont); // *** ROW 4 *** PdfReports.AddText2Table(table, "FSA Number: ", labelFont); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_fsa_number")), normalFont, 3); PdfReports.AddText2Table(table, "FSA State: ", labelFont); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_fsa_state")), normalFont); PdfReports.AddText2Table(table, "FSA County: ", labelFont); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_fsa_county")), normalFont); // *** ROW 5 *** PdfReports.AddText2Table(table, "Farm No: ", labelFont); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_farm_number")), normalFont); PdfReports.AddText2Table(table, "Tract No: ", labelFont); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_tract_number")), normalFont); PdfReports.AddText2Table(table, "Field No: ", labelFont); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_field_number")), normalFont); PdfReports.AddText2Table(table, "1/4 Field: ", labelFont); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_quarter_field")), normalFont, 7); // *** ROW 6 *** PdfReports.AddText2Table(table, "Description", labelFont); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_description")), normalFont, 7); PdfReports.AddText2Table(table, " ", normalFont, tmpLayout.Length); PdfReports.AddTableNoSplit(document, pgEvent, table); // ====================================================== // Field Contracting // ====================================================== float[] fcLayout = new float[] { 120.0F, 150.0F, 100.0F, 170.0F }; table = PdfReports.CreateTable(fcLayout, 1); table.DefaultCell.PaddingTop = 3.0F; table.DefaultCell.PaddingBottom = 0; table.DefaultCell.PaddingLeft = 0; table.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT; table.DefaultCell.VerticalAlignment = Element.ALIGN_BOTTOM; // Row 1 PdfReports.AddText2Table(table, "Land Ownership: ", labelFont); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_ownership")).ToString(), normalFont); PdfReports.AddText2Table(table, " ", normalFont, 2); // Row 2 PdfReports.AddText2Table(table, "Rotation Length (years): ", labelFont); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_rotation_len")).ToString(), normalFont); PdfReports.AddText2Table(table, "Prior Crop: ", labelFont); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_prev_crop_type")).ToString(), normalFont); // Row 3 PdfReports.AddText2Table(table, "Years field has had beets: ", labelFont); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_beet_years")).ToString(), normalFont); PdfReports.AddText2Table(table, "Tillage: ", labelFont); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_tillage")).ToString(), normalFont); // blank PdfReports.AddText2Table(table, " ", normalFont, fcLayout.Length); PdfReports.AddText2Table(table, " ", normalFont); PdfReports.AddText2Table(table, "Pre-Harvest", labelFont, "center"); PdfReports.AddText2Table(table, "Post-Harvest", labelFont, "center"); PdfReports.AddText2Table(table, " ", normalFont); PdfReports.AddText2Table(table, "Rhizomania Suspect: ", labelFont); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_suspect_rhizomania")).ToString(), normalFont, "center"); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_post_rhizomania")).ToString(), normalFont, "center"); PdfReports.AddText2Table(table, " ", normalFont); PdfReports.AddText2Table(table, "Aphanomyces Suspect: ", labelFont); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_suspect_aphanomyces")).ToString(), normalFont, "center"); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_post_aphanomyces")).ToString(), normalFont, "center"); PdfReports.AddText2Table(table, " ", normalFont); PdfReports.AddText2Table(table, "Curly Top Suspect: ", labelFont); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_suspect_curly_top")).ToString(), normalFont, "center"); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_post_curlytop")).ToString(), normalFont, "center"); PdfReports.AddText2Table(table, " ", normalFont); PdfReports.AddText2Table(table, "Fusarium Suspect: ", labelFont); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_suspect_fusarium")).ToString(), normalFont, "center"); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_post_fusarium")).ToString(), normalFont, "center"); PdfReports.AddText2Table(table, " ", normalFont); PdfReports.AddText2Table(table, "Rhizoctonia Suspect: ", labelFont); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_suspect_rhizoctonia")).ToString(), normalFont, "center"); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_post_rhizoctonia")).ToString(), normalFont, "center"); PdfReports.AddText2Table(table, " ", normalFont); PdfReports.AddText2Table(table, "Nematode Suspect: ", labelFont); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_suspect_nematode")).ToString(), normalFont, "center"); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_post_nematode")).ToString(), normalFont, "center"); PdfReports.AddText2Table(table, " ", normalFont); PdfReports.AddText2Table(table, "Cercospora Suspect: ", labelFont); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_suspect_cercospora")).ToString(), normalFont, "center"); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_post_cercospora")).ToString(), normalFont, "center"); PdfReports.AddText2Table(table, " ", normalFont); PdfReports.AddText2Table(table, "Root Aphid Suspect: ", labelFont); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_suspect_root_aphid")).ToString(), normalFont, "center"); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_post_rootaphid")).ToString(), normalFont, "center"); PdfReports.AddText2Table(table, " ", normalFont); PdfReports.AddText2Table(table, "Powdery Mildew Suspect: ", labelFont); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_suspect_powdery_mildew")).ToString(), normalFont, "center"); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_post_powderymildew")).ToString(), normalFont, "center"); PdfReports.AddText2Table(table, " ", normalFont); PdfReports.AddText2Table(table, " ", normalFont, 4); PdfReports.AddTableNoSplit(document, pgEvent, table); float[] lld2Layout = new float[] { 67.5F, 67.5F, 55F, 80F, 67.5F, 67.5F, 67.5F, 67.5F }; table = PdfReports.CreateTable(lld2Layout, 1); PdfReports.AddText2Table(table, "Irrigation System: ", labelFont, 2); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_irrigation_method")).ToString(), normalFont, "left", 2); PdfReports.AddText2Table(table, " ", labelFont, 4); PdfReports.AddText2Table(table, "Water Source: ", labelFont, 2); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_irrigation_source")).ToString(), normalFont, "left", 2); PdfReports.AddText2Table(table, "Water: ", labelFont); PdfReports.AddText2Table(table, dr.GetString(dr.GetOrdinal("cntg_post_water")).ToString(), normalFont, "left"); PdfReports.AddText2Table(table, " ", labelFont, 2); PdfReports.AddTableNoSplit(document, pgEvent, table); } catch (System.Exception ex) { WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(METHOD_NAME, ex); throw (wscEx); } } // ====================================================== // 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 = "sb is null: " + (sb == null).ToString() + "; " + "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(); } } }