예제 #1
0
        private string getTotalSummaries()
        {
            var row          = CurrentRowInfoData.LastRenderedRowNumber;
            var propertyName = _pdfRptCell.SharedData.PdfColumnAttributes.PropertyName;

            var result = SummaryCellsData.FirstOrDefault(x => x.CellData.PropertyName == propertyName &&
                                                         x.OverallRowNumber == row);

            if (result == null)
            {
                return(string.Empty);
            }

            object data;

            if (IsGroupingEnabled &&
                (_pdfRptCell.RowData.PdfRowType == RowType.SummaryRow ||
                 _pdfRptCell.RowData.PdfRowType == RowType.PreviousPageSummaryRow))
            {
                data = result.GroupAggregateValue;
            }
            else
            {
                data = result.OverallAggregateValue;
            }

            return(FuncHelper.ApplyFormula(_pdfRptCell.SharedData.PdfColumnAttributes.AggregateFunction.DisplayFormatFormula, data));
        }
예제 #2
0
        private string thisPageSummary()
        {
            var pageBoundary = CurrentRowInfoData.PagesBoundaries.OrderByDescending(x => x).Take(2).ToList();

            if (!pageBoundary.Any())
            {
                return(string.Empty);
            }

            int firstRowOfThePage, lastRowOfThePage;

            if (pageBoundary.Count == 1)
            {
                firstRowOfThePage = 1;
                lastRowOfThePage  = pageBoundary[0];
            }
            else
            {
                firstRowOfThePage = pageBoundary[1] + 1;
                lastRowOfThePage  = pageBoundary[0];
            }

            var propertyName = _pdfRptCell.SharedData.PdfColumnAttributes.PropertyName;
            var list         = SummaryCellsData.Where(x => x.CellData.PropertyName == propertyName &&
                                                      x.OverallRowNumber >= firstRowOfThePage && x.OverallRowNumber <= lastRowOfThePage)
                               .ToList();
            var result = _pdfRptCell.SharedData.PdfColumnAttributes.AggregateFunction.ProcessingBoundary(list);

            return(FuncHelper.ApplyFormula(_pdfRptCell.SharedData.PdfColumnAttributes.AggregateFunction.DisplayFormatFormula, result));
        }
예제 #3
0
        private void printSummary(Rectangle position, PdfContentByte[] canvases)
        {
            var rowSummaryDataObj = getRowSummaryData() ?? string.Empty;

            var rowSummaryData = FuncHelper.ApplyFormula(_pdfRptCell.SharedData.PdfColumnAttributes.AggregateFunction.DisplayFormatFormula, rowSummaryDataObj);

            if (!_pdfRptCell.BasicProperties.RunDirection.HasValue)
            {
                _pdfRptCell.BasicProperties.RunDirection = PdfRunDirection.LeftToRight;
            }

            if (_pdfRptCell.BasicProperties.RunDirection == PdfRunDirection.RightToLeft)
            {
                rowSummaryData = rowSummaryData.FixWeakCharacters();
            }

            var formattedValue = rowSummaryData.ToSafeString();

            setCellData(rowSummaryDataObj, formattedValue);
            setMainTableEvents();

            var phrase    = _pdfRptCell.BasicProperties.PdfFont.FontSelector.Process(_pdfRptCell.RowData.FormattedValue);
            var alignment = getAggregateValuePosition(position);

            ColumnText.ShowTextAligned(
                canvas: canvases[PdfPTable.TEXTCANVAS],
                alignment: (int)alignment.HorizontalAlignment,
                phrase: phrase,
                x: alignment.X,
                y: ((position.Bottom + position.Top) / 2) - 4,
                rotation: 0,
                runDirection: (int)_pdfRptCell.BasicProperties.RunDirection,
                arabicOptions: 0);
        }
예제 #4
0
        private void updateAggregates(ColumnAttributes col, CellAttributes cell)
        {
            if (cell == null || col.AggregateFunction == null)
            {
                return;
            }

            col.AggregateFunction.CellAdded(cell.RowData.Value, CurrentRowInfoData.IsNewGroupStarted);

            var columnRowSummary = new SummaryCellData
            {
                CellData = new CellData
                {
                    PropertyName  = col.PropertyName,
                    PropertyValue = cell.RowData.Value
                },
                GroupAggregateValue   = FuncHelper.ApplyFormula(col.AggregateFunction.DisplayFormatFormula, col.AggregateFunction.GroupValue),
                GroupRowNumber        = CurrentRowInfoData.LastGroupRowNumber,
                OverallAggregateValue = FuncHelper.ApplyFormula(col.AggregateFunction.DisplayFormatFormula, col.AggregateFunction.OverallValue),
                OverallRowNumber      = CurrentRowInfoData.LastOverallDataRowNumber,
                GroupNumber           = CurrentRowInfoData.LastGroupNumber
            };

            SharedData.ColumnCellsSummaryData.Add(columnRowSummary);
        }
예제 #5
0
        private string getText(CellAttributes attributes)
        {
            var text = FuncHelper.ApplyFormula(attributes.BasicProperties.DisplayFormatFormula, attributes.RowData.Value);

            if (!string.IsNullOrEmpty(TextPropertyName))
            {
                text = attributes.RowData.TableRowData.GetSafeStringValueOf(TextPropertyName);
            }
            attributes.RowData.FormattedValue = text;
            return(text);
        }
예제 #6
0
        /// <summary>
        /// Custom cell's content template as a PdfPCell.
        /// </summary>
        /// <returns>Content as a PdfPCell</returns>
        public PdfPCell RenderingCell(CellAttributes attributes)
        {
            var data = FuncHelper.ApplyFormula(attributes.BasicProperties.DisplayFormatFormula, attributes.RowData.Value);

            attributes.RowData.FormattedValue = data;
            var img = _barcode.GetBarcodeImage(data, attributes.SharedData.PdfWriter.DirectContent);

            return(new PdfPCell(img)
            {
                PaddingTop = 5,
            });
        }
예제 #7
0
        /// <summary>
        /// Custom cell's content template as a PdfPCell
        /// </summary>
        /// <returns>Content as a PdfPCell</returns>
        public PdfPCell RenderingCell(CellAttributes attributes)
        {
            var html = FuncHelper.ApplyFormula(attributes.BasicProperties.DisplayFormatFormula, attributes.RowData.Value);

            attributes.RowData.FormattedValue = html;
            var cell = new HtmlWorkerHelper
            {
                PdfFont             = attributes.BasicProperties.PdfFont,
                HorizontalAlignment = attributes.BasicProperties.HorizontalAlignment.Value,
                Html         = html,
                RunDirection = attributes.BasicProperties.RunDirection.Value,
                StyleSheet   = StyleSheet
            }.RenderHtml();

            return(cell);
        }
예제 #8
0
        /// <summary>
        /// Custom cell's content template as a PdfPCell
        /// </summary>
        /// <returns>Content as a PdfPCell</returns>
        public PdfPCell RenderingCell(CellAttributes attributes)
        {
            var html = FuncHelper.ApplyFormula(attributes.BasicProperties.DisplayFormatFormula, attributes.RowData.Value);

            attributes.RowData.FormattedValue = html;
            var cell = new XmlWorkerHelper
            {
                Html         = html,
                RunDirection = attributes.BasicProperties.RunDirection.Value,
                CssFilesPath = CssFilesPath,
                InlineCss    = InlineCss,
                ImagesPath   = ImagesPath
            }.RenderHtml();

            return(cell);
        }
예제 #9
0
        private Image getImage(CellAttributes attributes)
        {
            var path = FuncHelper.ApplyFormula(attributes.BasicProperties.DisplayFormatFormula, attributes.RowData.Value);

            attributes.RowData.FormattedValue = path;
            if (!string.IsNullOrEmpty(path) && File.Exists(path))
            {
                return(path.GetITextSharpImageFromImageFile(_cacheImages));
            }

            if (!string.IsNullOrEmpty(_defaultImageFilePath) && File.Exists(_defaultImageFilePath))
            {
                return(_defaultImageFilePath.GetITextSharpImageFromImageFile(this._cacheImages));
            }
            throw new FileNotFoundException(string.Format(CultureInfo.InvariantCulture, "{0} does not exists & defaultImageFilePath was not found.", path));
        }
예제 #10
0
        /// <summary>
        /// Custom cell's content template as a PdfPCell
        /// </summary>
        /// <returns>Content as a PdfPCell</returns>
        public PdfPCell RenderingCell(CellAttributes attributes)
        {
            if (ShowPercentText)
            {
                var data = FuncHelper.ApplyFormula(attributes.BasicProperties.DisplayFormatFormula, attributes.RowData.Value);
                attributes.RowData.FormattedValue = data;

                if (attributes.BasicProperties != null && attributes.BasicProperties.RunDirection == PdfRunDirection.RightToLeft)
                {
                    data = data.FixWeakCharacters();
                }

                var phrase = attributes.BasicProperties.PdfFont.FontSelector.Process(data.ToSafeString());
                return(new PdfPCell(phrase));
            }
            var emptyPhrase = attributes.BasicProperties.PdfFont.FontSelector.Process(string.Empty);

            return(new PdfPCell(emptyPhrase));
        }
        /// <summary>
        /// Custom cell's content template as a PdfPCell
        /// </summary>
        /// <returns>Content as a PdfPCell</returns>
        public PdfPCell RenderingCell(CellAttributes attributes)
        {
            var data = FuncHelper.ApplyFormula(attributes.BasicProperties.DisplayFormatFormula, attributes.RowData.Value);

            attributes.RowData.FormattedValue = data;

            if (attributes.BasicProperties != null && attributes.BasicProperties.RunDirection == PdfRunDirection.RightToLeft)
            {
                data = data.FixWeakCharacters();
            }

            if (attributes.BasicProperties.PdfFont == null)
            {
                return(new PdfPCell());
            }

            data = showEmptyCell(data);

            var phrase = attributes.BasicProperties.PdfFont.FontSelector.Process(data);

            return(new PdfPCell(phrase));
        }