PdfRpt.Core.Helper.TableCellDefinitionsExt.ApplyStyles C# (CSharp) Method

ApplyStyles() public static method

Applies PdfCellAttributes to a PdfPCell.
public static ApplyStyles ( this pdfPCell, PdfRpt.Core.Contracts.CellAttributes pdfRptTableCellDefinition ) : void
pdfPCell this A PdfPCell.
pdfRptTableCellDefinition PdfRpt.Core.Contracts.CellAttributes PdfCell Attributes
return void
        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.PaddingBottom > 0)
                pdfPCell.PaddingBottom = pdfRptTableCellDefinition.BasicProperties.PaddingBottom;

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

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

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

            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;
        }