Exemple #1
2
        public PdfPCell RenderingCell(CellAttributes attributes)
        {
            var data = attributes.RowData.TableRowData;
            var id = data.GetSafeStringValueOf<User>(x => x.Id);

            var qrcode = new BarcodeQRCode(id, 1, 1, null);
            var image = qrcode.GetImage();
            var mask = qrcode.GetImage();
            mask.MakeMask();
            image.ImageMask = mask; // making the background color transparent
            var pdfCell = new PdfPCell(image, fit: false);

            return pdfCell;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public PdfPCell RenderingCell(CellAttributes attributes)
        {
            var data = attributes.RowData.TableRowData;
            var id = data.GetSafeStringValueOf<Question>(x => x.Id);
            var questionText = data.GetSafeStringValueOf<Question>(x => x.QuestionText);
            var answer1 = data.GetSafeStringValueOf<Question>(x => x.Answer1);
            var answer2 = data.GetSafeStringValueOf<Question>(x => x.Answer2);
            var answer3 = data.GetSafeStringValueOf<Question>(x => x.Answer3);
            var answer4 = data.GetSafeStringValueOf<Question>(x => x.Answer4);
            var picturePath = data.GetSafeStringValueOf<Question>(x => x.PicturePath);

            var font = attributes.BasicProperties.PdfFont;

            var relativeWidths = getRelativeWidths();

            var mainTable = new PdfGrid(relativeWidths)
            {
                RunDirection = (int)_pdfRunDirection,
                WidthPercentage = 100,
                SpacingBefore = 5,
                SpacingAfter = 5
            };

            addQuestionText(id, questionText, font, mainTable);
            addOptions(answer1, answer2, answer3, answer4, font, mainTable);
            addImageCell(picturePath, mainTable);

            return new PdfPCell(mainTable);
        }
        /// <summary>
        /// Custom cell's content template as a PdfPCell
        /// </summary>
        /// <returns>Content as a PdfPCell</returns>
        public PdfPCell RenderingCell(CellAttributes attributes)
        {
            var data = attributes.RowData.Value as CalendarData;
            if (data == null)
                throw new InvalidOperationException("Calendar's cell data type is not PdfRpt.Calendar.CalendarData. Use DaysInfoToCalendarData.MapToCalendarDataList to map list of the DayInfo's to the list of CalendarData's.");

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

            if (MonthCalendarFieldData.RelativeColumnWidths == null)
                MonthCalendarFieldData.RelativeColumnWidths = new float[] { 1, 1, 1, 1, 1, 1, 1 };

            var table = new MonthCalendar
                {
                    CalendarData = data,
                    CalendarAttributes = new CalendarAttributes
                    {
                        BorderColor = attributes.SharedData.Template.CellBorderColor,
                        Font = attributes.BasicProperties.PdfFont,
                        RelativeColumnWidths = MonthCalendarFieldData.RelativeColumnWidths,
                        UseLongDayNamesOfWeek = MonthCalendarFieldData.UseLongDayNamesOfWeek,
                        CalendarType = MonthCalendarFieldData.CalendarType,
                        CellsCustomizer = MonthCalendarFieldData.CellsCustomizer,
                        GradientEndColor = MonthCalendarFieldData.GradientEndColor,
                        GradientStartColor = MonthCalendarFieldData.GradientStartColor,
                        DescriptionHorizontalAlignment = MonthCalendarFieldData.DescriptionHorizontalAlignment,
                        DayNamesRowBackgroundColor = MonthCalendarFieldData.DayNamesRowBackgroundColor
                    }
                }.CreateMonthCalendar();
            var cell = new PdfPCell(table);
            cell.Padding = MonthCalendarFieldData.Padding;
            return cell;
        }
Exemple #4
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public PdfPCell RenderingCell(CellAttributes attributes)
        {
            var numColumns = 10;
            var salePrice = attributes.RowData.TableRowData
                                              .GetSafeStringValueOf<Transaction>(x => x.SalePrice, nullValue: "0")
                                              .PadLeft(numColumns, ' ');

            var table = new PdfGrid(numColumns)
            {
                RunDirection = PdfWriter.RUN_DIRECTION_LTR,
                WidthPercentage = 100
            };
            for (int i = 0; i < numColumns; i++)
            {
                var character = salePrice[i].ToString();
                table.AddCell(new PdfPCell(attributes.BasicProperties.PdfFont.FontSelector.Process(character))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER,
                    BorderColor = BaseColor.GRAY,
                    UseAscender = true,
                    UseDescender = true,
                    VerticalAlignment = Element.ALIGN_MIDDLE,
                    BorderWidth = 1
                });
            }

            return new PdfPCell(table);
        }
        public PdfPCell RenderingCell(CellAttributes attributes)
        {
            var pdfCell = new PdfPCell();
            var table = new PdfGrid(1) { RunDirection = PdfWriter.RUN_DIRECTION_LTR };

            var filePath = System.IO.Path.Combine(AppPath.ApplicationPath, "Images\\" + _rnd.Next(1, 5).ToString("00") + ".png");
            var photo = PdfImageHelper.GetITextSharpImageFromImageFile(filePath);
            table.AddCell(new PdfPCell(photo, fit: false)
            {
                Border = 0,
                VerticalAlignment = Element.ALIGN_BOTTOM,
                HorizontalAlignment = Element.ALIGN_CENTER
            });

            var name = attributes.RowData.TableRowData.GetSafeStringValueOf("User");
            table.AddCell(new PdfPCell(attributes.BasicProperties.PdfFont.FontSelector.Process(name))
            {
                Border = 0,
                HorizontalAlignment = Element.ALIGN_CENTER
            });

            pdfCell.AddElement(table);

            return pdfCell;
        }
        /// <summary>
        /// Applies PdfCellAttributes to a PdfPCell.
        /// </summary>
        /// <param name="pdfPCell">A PdfPCell.</param>
        /// <param name="pdfRptTableCellDefinition">PdfCell Attributes</param>
        public static void ApplyStyles(this PdfPCell pdfPCell, CellAttributes pdfRptTableCellDefinition)
        {
            if (pdfRptTableCellDefinition.BasicProperties.RunDirection.HasValue)
                pdfPCell.RunDirection = (int)pdfRptTableCellDefinition.BasicProperties.RunDirection;

            pdfPCell.BorderColor = pdfRptTableCellDefinition.BasicProperties.BorderColor;
            pdfPCell.BackgroundColor = pdfRptTableCellDefinition.BasicProperties.BackgroundColor;

            if (pdfRptTableCellDefinition.BasicProperties.HorizontalAlignment != null)
                pdfPCell.HorizontalAlignment = (int)pdfRptTableCellDefinition.BasicProperties.HorizontalAlignment;

            pdfPCell.VerticalAlignment = Element.ALIGN_MIDDLE;
            pdfPCell.Rotation = pdfRptTableCellDefinition.BasicProperties.Rotation;
            pdfPCell.UseAscender = true;
            pdfPCell.UseDescender = true;

            if (pdfRptTableCellDefinition.BasicProperties.CellPadding > 0)
                pdfPCell.Padding = pdfRptTableCellDefinition.BasicProperties.CellPadding;

            if (pdfRptTableCellDefinition.BasicProperties.FixedHeight > 0)
                pdfPCell.FixedHeight = pdfRptTableCellDefinition.BasicProperties.FixedHeight;

            if (pdfRptTableCellDefinition.BasicProperties.MinimumHeight > 0)
                pdfPCell.MinimumHeight = pdfRptTableCellDefinition.BasicProperties.MinimumHeight;

            if (pdfRptTableCellDefinition.BasicProperties.BorderWidth > 0)
                pdfPCell.BorderWidth = pdfRptTableCellDefinition.BasicProperties.BorderWidth;

            if (!pdfRptTableCellDefinition.BasicProperties.ShowBorder)
                pdfPCell.BorderWidth = 0;
        }
        /// <summary>
        /// Custom cell's content template as a PdfPCell
        /// </summary>
        /// <returns>Content as a PdfPCell</returns>
        public PdfPCell RenderingCell(CellAttributes attributes)
        {
            if (OnSelectSymbol == null)
                throw new InvalidOperationException("Please set the OnSelectSymbol formula.");

            var font = FontFactory.GetFont(WingdingsFontPath, BaseFont.IDENTITY_H, true, attributes.BasicProperties.PdfFont.Size, Font.NORMAL, attributes.BasicProperties.FontColor);
            var symbol = (int)OnSelectSymbol.Invoke(attributes.RowData.TableRowData);
            return new PdfPCell(new Phrase(new Chunk((char)symbol, font)));
        }
Exemple #8
0
        /// <summary>
        /// Custom cell's content template as a PdfPCell
        /// </summary>
        /// <returns>Content as a PdfPCell</returns>
        public PdfPCell RenderingCell(CellAttributes attributes)
        {
            if (shouldUseCachedImage)
            {
                return new PdfPCell(_image, true);
            }

            createImageFromImportedPage(attributes);
            return new PdfPCell(_image, true);
        }
Exemple #9
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,
     };
 }
 /// <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;
 }
 /// <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;
 }
Exemple #12
0
        /// <summary>
        /// This method is called at the end of the cell's rendering.
        /// </summary>
        /// <param name="cell">The current cell</param>
        /// <param name="position">The coordinates of the cell</param>
        /// <param name="canvases">An array of PdfContentByte to add text or graphics</param>
        /// <param name="attributes">Current cell's custom attributes</param>
        public void CellRendered(PdfPCell cell, Rectangle position, PdfContentByte[] canvases, CellAttributes attributes)
        {
            if (DrawOnCell == null)
                return;

            DrawOnCell(new InlineFieldData
            {
                Attributes = attributes,
                BasicProperties = BasicProperties,
                Canvases = canvases,
                Cell = cell,
                ConditionalFormatFormula = ConditionalFormatFormula,
                Position = position
            });
        }
Exemple #13
0
        /// <summary>
        /// Custom cell's content template as a PdfPCell
        /// </summary>
        /// <returns>Content as a PdfPCell</returns>
        public PdfPCell RenderingCell(CellAttributes attributes)
        {
            if (RenderCell == null)
                return new PdfPCell();

            return RenderCell(new InlineFieldData
            {
                Attributes = attributes,
                BasicProperties = BasicProperties,
                Canvases = null,
                Cell = null,
                ConditionalFormatFormula = ConditionalFormatFormula,
                Position = null
            });
        }
        /// <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();
            }

            var phrase = attributes.BasicProperties.PdfFont.FontSelector.Process(data.ToSafeString());
            return new PdfPCell(phrase);
        }
 /// <summary>
 /// This method is called at the end of the cell's rendering.
 /// </summary>
 /// <param name="cell">The current cell</param>
 /// <param name="position">The coordinates of the cell</param>
 /// <param name="canvases">An array of PdfContentByte to add text or graphics</param>
 /// <param name="attributes">Current cell's custom attributes</param>
 public void CellRendered(PdfPCell cell, Rectangle position, PdfContentByte[] canvases, CellAttributes attributes)
 {
     var contentByte = canvases[PdfPTable.BACKGROUNDCANVAS];
     contentByte.SaveState();
     if (ProgressBarColorFormula != null)
     {
         ProgressBarColor = ProgressBarColorFormula(attributes.RowData.TableRowData);
     }
     contentByte.SetColorFill(new BaseColor(ProgressBarColor));
     contentByte.Rectangle(
                   position.Left,
                   position.Bottom,
                   position.Width * getPercent(attributes) / 100,
                   position.Height);
     contentByte.Fill();
     contentByte.RestoreState();
 }
Exemple #16
0
        /// <summary>
        /// This method is called at the end of the cell's rendering.
        /// </summary>
        /// <param name="cell">The current cell</param>
        /// <param name="position">The coordinates of the cell</param>
        /// <param name="canvases">An array of PdfContentByte to add text or graphics</param>
        /// <param name="attributes">Current cell's custom attributes</param>
        public void CellRendered(PdfPCell cell, Rectangle position, PdfContentByte[] canvases, CellAttributes attributes)
        {
            checkNulls();
            var cb = canvases[PdfPTable.BACKGROUNDCANVAS];
            cb.SaveState();
            var data = (bool)attributes.RowData.Value;

            if (_cachedCheckmark == null)
                _cachedCheckmark = VectorImages.CheckmarkImage(cb, CheckmarkFillColor.Value);

            if (_cachedCross == null)
                _cachedCross = VectorImages.CrossImage(cb, CrossSignFillColor.Value);

            var image = data ? _cachedCheckmark.DrawCheckmarkImageAtPosition(position) :
                               _cachedCross.DrawCrossImageAtPosition(position);
            cb.AddImage(image);
            cb.RestoreState();
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public PdfPCell RenderingCell(CellAttributes attributes)
        {
            var pdfCell = new PdfPCell();
            var table = new PdfGrid(1) { RunDirection = PdfWriter.RUN_DIRECTION_LTR };

            var photo = PdfImageHelper.GetITextSharpImageFromImageFile(System.IO.Path.Combine(AppPath.ApplicationPath, "Images\\" + _rnd.Next(1, 5).ToString("00") + ".png"));
            table.AddCell(new PdfPCell(photo) { Border = 0, MinimumHeight = photo.Height, VerticalAlignment = Element.ALIGN_BOTTOM });

            var name = attributes.RowData.TableRowData.GetSafeStringValueOf<User>(x => x.Name);
            table.AddCell(new PdfPCell(attributes.BasicProperties.PdfFont.FontSelector.Process(name)) { Border = 0 });

            var lastName = attributes.RowData.TableRowData.GetSafeStringValueOf<User>(x => x.LastName);
            table.AddCell(new PdfPCell(attributes.BasicProperties.PdfFont.FontSelector.Process(lastName)) { Border = 0 });

            pdfCell.AddElement(table);

            return pdfCell;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public PdfPCell RenderingCell(CellAttributes attributes)
        {
            var pdfCell = new PdfPCell();
            var table = new PdfGrid(1) { RunDirection = PdfWriter.RUN_DIRECTION_LTR };

            // Please note that All columns and properties of an object will create a single cell here.

            var idx = attributes.RowData.ColumnNumber;
            var data = attributes.RowData.TableRowData;

            var character = data.GetSafeStringValueOf<CharacterInfo>(x => x.Character, propertyIndex: idx);
            table.AddCell(new PdfPCell(_customFont.FontSelector.Process(character)) { Border = 0, HorizontalAlignment = Element.ALIGN_CENTER });

            var characterCode = data.GetSafeStringValueOf<CharacterInfo>(x => x.CharacterCode, propertyIndex: idx);
            table.AddCell(new PdfPCell(attributes.BasicProperties.PdfFont.FontSelector.Process(characterCode)) { Border = 0, HorizontalAlignment = Element.ALIGN_CENTER });

            pdfCell.AddElement(table);

            return pdfCell;
        }
Exemple #19
0
        /// <summary>
        /// Custom cell's content template as a PdfPCell
        /// </summary>
        /// <returns>Content as a PdfPCell</returns>
        public PdfPCell RenderingCell(CellAttributes attributes)
        {
            if (OnPrintAnnotation == null)
                throw new InvalidOperationException("Please set the OnPrintAnnotation formula.");

            var data = OnPrintAnnotation.Invoke(attributes.RowData.TableRowData);
            if (data == null) return new PdfPCell();

            var defaultFont = attributes.BasicProperties.PdfFont.Fonts[0];
            var chunk = new Chunk(".", defaultFont);
            chunk.SetAnnotation(
                    PdfAnnotation.CreateText(
                           attributes.SharedData.PdfWriter,
                           new Rectangle(100, 100),
                           data.Title,
                           data.Text,
                           false,
                           _annotationIcon[data.Icon]));

            return new PdfPCell(new Phrase(chunk));
        }
 public void CellRendered(PdfPCell cell, Rectangle position, PdfContentByte[] canvases, CellAttributes attributes)
 {
 }
        // Public Methods (7)
        /// <summary>
        /// Adds a new PdfPCell to the MainTable
        /// </summary>
        /// <param name="backgroundColor"></param>
        /// <param name="foreColor"></param>        
        /// <param name="rawData"></param>
        /// <param name="columnNumber"></param>
        /// <param name="pdfRowType"></param>
        /// <param name="pdfCellType"></param>
        /// <param name="rowValues"></param>
        /// <param name="horizontalAlignment"></param>
        /// <param name="pdfFontStyle"></param>
        /// <param name="rotation"></param>
        /// <param name="setItemTemplate"></param>
        /// <param name="colSpan"></param>         
        /// <returns></returns>
        public CellAttributes AddGeneralCell(
                    BaseColor backgroundColor,
                    BaseColor foreColor,
                    object rawData,
                    int columnNumber,
                    RowType pdfRowType,
                    CellType pdfCellType,
                    IList<CellData> rowValues = null,
                    HorizontalAlignment horizontalAlignment = HorizontalAlignment.None,
                    DocumentFontStyle pdfFontStyle = DocumentFontStyle.None,
                    int rotation = 0,
                    bool setItemTemplate = false,
                    int colSpan = 1)
        {
            var col = SharedData.PdfColumnsAttributes[columnNumber];

            var cellData = new CellAttributes
            {
                RowData = new CellRowData
                {
                    TableRowData = rowValues,
                    Value = rawData,
                    PdfRowType = pdfRowType,
                    ColumnNumber = columnNumber
                },
                SharedData = new CellSharedData
                {
                    PdfColumnAttributes = col,
                    DataRowNumber = CurrentRowInfoData.LastOverallDataRowNumber,
                    GroupNumber = CurrentRowInfoData.LastGroupRowNumber,
                    PdfDoc = SharedData.PdfDoc,
                    PdfWriter = SharedData.PdfWriter,
                    SummarySettings = SharedData.SummarySettings,
                    Template = SharedData.Template
                },
                ItemTemplate = setItemTemplate ? col.ColumnItemsTemplate : null,
                BasicProperties = new CellBasicProperties
                {
                    PdfFont = SharedData.PdfFont,
                    Rotation = rotation,
                    PdfFontStyle = (pdfFontStyle == DocumentFontStyle.None) ? DocumentFontStyle.Normal : pdfFontStyle,
                    BackgroundColor = backgroundColor,
                    BorderColor = SharedData.Template.CellBorderColor,
                    FontColor = foreColor,
                    RunDirection = SharedData.PageSetup.PagePreferences.RunDirection,
                    ShowBorder = SharedData.Template.ShowGridLines,
                    HorizontalAlignment = (horizontalAlignment == HorizontalAlignment.None) ? col.CellsHorizontalAlignment : horizontalAlignment,
                    FixedHeight = pdfRowType == RowType.DataTableRow ? col.FixedHeight : 0,
                    MinimumHeight = pdfRowType == RowType.DataTableRow ? col.MinimumHeight : 0
                }
            };

            if (SharedData.MainTableEvents != null) SharedData.MainTableEvents.CellCreated(new EventsArguments { PdfDoc = SharedData.PdfDoc, PdfWriter = SharedData.PdfWriter, Cell = cellData, CellType = pdfCellType, RowType = pdfRowType, ColumnNumber = columnNumber, ColumnCellsSummaryData = SharedData.ColumnCellsSummaryData, PreviousTableRowData = CurrentRowInfoData.PreviousTableRowData, PageSetup = SharedData.PageSetup, PdfFont = SharedData.PdfFont, PdfColumnsAttributes = SharedData.PdfColumnsAttributes });
            var cell = cellData.CreateSafePdfPCell(new TextBlockField());
            cell.CellEvent = new MainTableCellsEvent(cellData)
            {
                SummaryCellsData = SharedData.ColumnCellsSummaryData,
                IsGroupingEnabled = SharedData.IsGroupingEnabled,
                CurrentRowInfoData = CurrentRowInfoData
            };

            if (colSpan > 1) cell.Colspan = colSpan;

            MainTable.AddCell(cell);
            if (SharedData.MainTableEvents != null) SharedData.MainTableEvents.CellAdded(new EventsArguments { PdfDoc = SharedData.PdfDoc, PdfWriter = SharedData.PdfWriter, Cell = cellData, CellType = pdfCellType, RowType = pdfRowType, ColumnNumber = columnNumber, ColumnCellsSummaryData = SharedData.ColumnCellsSummaryData, PreviousTableRowData = CurrentRowInfoData.PreviousTableRowData, PageSetup = SharedData.PageSetup, PdfFont = SharedData.PdfFont, PdfColumnsAttributes = SharedData.PdfColumnsAttributes });

            return cellData;
        }
        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));
        }
Exemple #23
0
 /// <summary>
 /// Custom cell's content template as a PdfPCell
 /// </summary>
 /// <returns>Content as a PdfPCell</returns>
 public PdfPCell RenderingCell(CellAttributes attributes)
 {
     var font = setFontStyles(attributes);
     var anchor = getAnchor(font, attributes);
     return new PdfPCell(anchor);
 }
Exemple #24
0
 private string getUrl(CellAttributes attributes)
 {
     var url = attributes.RowData.Value.ToSafeString();
     if (!string.IsNullOrEmpty(NavigationUrlPropertyName))
     {
         url = attributes.RowData.TableRowData.GetSafeStringValueOf(NavigationUrlPropertyName);
     }
     return url;
 }
Exemple #25
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;
 }
Exemple #26
0
 private Anchor getAnchor(FontSelector fontSelector, CellAttributes attributes)
 {
     var text = getText(attributes);
     var url = getUrl(attributes);
     var anchor = new Anchor(fontSelector.Process(text.ToSafeString())) { Reference = url };
     return anchor;
 }
        /// <summary>
        /// Custom cell's content template as a PdfPCell
        /// </summary>
        /// <returns>Content as a PdfPCell</returns>
        public PdfPCell RenderingCell(CellAttributes attributes)
        {
            if (attributes.RowData.Value == null) return new PdfPCell();

            var iTextImg = getImage(attributes);
            var pdfCell = new PdfPCell(iTextImg, fit: _fitImages)
            {
                PaddingTop = 2,
                PaddingBottom = 2,
            };

            if (!_fitImages)
            {
                pdfCell.MinimumHeight = iTextImg.Height + 5;
                pdfCell.VerticalAlignment = Element.ALIGN_BOTTOM;
            }

            return pdfCell;
        }
Exemple #28
0
 /// <summary>
 /// Custom cell's content template as a PdfPCell
 /// </summary>
 /// <returns>Content as a PdfPCell</returns>
 public PdfPCell RenderingCell(CellAttributes attributes)
 {
     return new PdfPCell();
 }
        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);
        }
Exemple #30
0
 private FontSelector setFontStyles(CellAttributes attributes)
 {
     foreach (var font in attributes.BasicProperties.PdfFont.Fonts)
     {
         font.Color = _foreColor;
         if (_fontUnderline) font.SetStyle(Font.UNDERLINE);
     }
     return attributes.BasicProperties.PdfFont.FontSelector;
 }