private void InitReport() { try { m_TextStyle = new Infragistics.Documents.Report.Text.Style(new Font("Arial", 8), Brushes.Black); //---------------------------------------------------- //create PDF doument m_PDFDoc = new Infragistics.Documents.Report.Report(); //---------------------------------------------------- //standard CELL pattern m_PDFCellPattern = new Infragistics.Documents.Report.Grid.GridCellPattern(); m_PDFCellPattern.Alignment = new ContentAlignment(Alignment.Center, Alignment.Middle); //header CELL pattern m_PDFCellPatternHeader = new Infragistics.Documents.Report.Grid.GridCellPattern(); m_PDFCellPatternHeader.Background = new Background(Brushes.LightSteelBlue); m_PDFCellPatternHeader.Alignment = new ContentAlignment(Alignment.Center, Alignment.Middle); //---------------------------------------------------- m_PDFSection = m_PDFDoc.AddSection(); m_PDFSection.PageOrientation = PageOrientation.Landscape; // Create a new GRID pattern for the grid as a whole. //---------------------------------------------------- } catch (Exception e) { throw new Exception("Failed to init PDF GRID pattern .\n" + e.Message); } } private void InitGridPDFpatern() { try { IGroup sect1HeadGroup = m_PDFSection.AddGroup(); Infragistics.Documents.Report.Grid.GridPattern gridPattern = new GridPattern(); //Create the grid and apply the GridPattern m_PDFGrid = sect1HeadGroup.AddGrid(); m_PDFGrid.ApplyPattern(gridPattern); //---------------------------------------------------- //add columns to greed int ct = (m_CheckColumnCount >= m_RemitColumnCount) ? m_CheckColumnCount : m_RemitColumnCount; m_PDFColumnCount = (ct >= m_GeneralColumnCount) ? (ct + m_DataLevel) : (m_GeneralColumnCount + m_DataLevel); for (int i = 0; i < m_PDFColumnCount; i++) { m_PDFGrid.AddColumn(); } //---------------------------------------------------- } catch (Exception e) { throw new Exception("Failed to init PDF GRID pattern .\n" + e.Message); } } private void AddRowToPDF(String ElementName, List RowValueList, int Level, bool IsHeader, long ItemID) { try { //add ROW Infragistics.Documents.Report.Grid.IGridRow gridRow = null; Infragistics.Documents.Report.Grid.IGridCell gridCell = null; gridRow = m_PDFGrid.AddRow(); //------------------------------------------------------------- //check if any number format exists List numberPositions = new List(); if (m_NumberFormatRecordPosTbl.ContainsKey(ElementName)) { numberPositions = m_NumberFormatRecordPosTbl[ElementName]; } //------------------------------------------------------------- //add EMPTY cell before first VALUE cell for (int ii = 0; ii < Level; ii++) { gridCell = gridRow.AddCell(); m_PDFCellPattern.Apply(gridCell); gridCell.AddText().AddContent(String.Empty, m_TextStyle); } //------------------------------------------------------------- //add VALUE cells int dataCt = RowValueList.Count; int columnCount = 0; bool isNumberFormat = false; bool isFrontExists = false; bool isBackExists = false; string frontUrl = String.Empty; string backUrl = String.Empty; foreach (String columnValue in RowValueList) { gridCell = gridRow.AddCell(); isNumberFormat = false; if (IsHeader && columnCount > 0)//do not need gray box for first empty column row { m_PDFCellPatternHeader.Apply(gridCell); } else { m_PDFCellPattern.Apply(gridCell); } //check for number format positions if (!IsHeader && numberPositions.Count > 0) { int foundIndex = Array.FindIndex(numberPositions.ToArray(), delegate(int pos) { return (columnCount == pos); }); isNumberFormat = foundIndex >= 0 ? true : false; } int currentColumn = columnCount + Level; if (isNumberFormat) { // "\"$\"#,##0.00_);[Red](\"$\"#,##0.00)"; // "\"$\"#,##0.00_);(\"$\"#,##0.00)"; //m_PDFWorksheet.Rows[m_PDFRowCount].Cells[columnCount + Level].CellFormat.FormatString = "0.00"; //m_PDFWorksheet.Rows[m_PDFRowCount].Cells[columnCount + Level].Value = double.Parse(columnValue);//must be double } else { //m_PDFWorksheet.Rows[m_PDFRowCount].Cells[columnCount + Level].Value = columnValue; } gridCell.AddText().AddContent(columnValue, m_TextStyle); columnCount++; } //------------------------------------------------------------- //add EMPTY cell after first VALUE cell for (int iii = (Level + columnCount); iii < m_PDFColumnCount; iii++) { gridCell = gridRow.AddCell(); m_PDFCellPattern.Apply(gridCell); gridCell.AddText().AddContent(String.Empty, m_TextStyle); } //------------------------------------------------------------- m_PDFRowCount++; //------------------------------------------------------------- if (ItemID > 0) { m_PDFItemCount++; //add IMAGEs GetUrls(ItemID, out isFrontExists, out isBackExists, out frontUrl, out backUrl); if (isFrontExists || isBackExists) { AddImages(Level, isFrontExists, isBackExists, frontUrl, backUrl); } } } catch (Exception e) { throw new Exception("Failed to add row to PDF document.\nElement [" + ElementName + "].\n" + e.Message); } }