/// <summary> /// Creates a new empty cell. /// </summary> /// <param name="useTestMode">Indicates if draw a border in testmode.</param> /// <param name="borders">The borders color, it allows defining the background color so as not to draw a border when we do not use test mode.</param> /// <returns> /// A new <see cref="PdfPCell"/> with visual style defined in the model. /// </returns> public static PdfPCell CreateEmptyCell(YesNo useTestMode = YesNo.No, BordersCollection borders = null) { return(useTestMode.AsBoolean() ? CreateEmptyWithBorderCell(BordersCollection.FromKnownColor(KnownBorderColor.Red)) : borders == null ? CreateEmptyWithoutBorderCell() : CreateEmptyWithBorderCell(borders)); }
/// <summary> /// Sets visual style for specified cell. /// </summary> /// <param name="cell">Cell which receives visual style.</param> /// <param name="style">Style to apply.</param> /// <param name="useTestMode">Indicates if draw a border in testmode.</param> /// <returns> /// A <see cref="PdfPCell"/> object which contains specified visual style. /// </returns> public static PdfPCell SetVisualStyle(this PdfPCell cell, PdfTextStyle style, YesNo useTestMode = YesNo.No) { Logger.Instance.Debug("External Call"); Logger.Instance.Info(" Sets visual style for specified cell"); Logger.Instance.Info(" > Library: iTin.Utilities.Pdf"); Logger.Instance.Info(" > Class: PdfExtensions"); Logger.Instance.Info(" > Method: SetVisualStyle(this PdfPCell, StyleModel)"); Logger.Instance.Info(" > Output: PdfPCell"); SentinelHelper.ArgumentNull(cell, nameof(cell)); SentinelHelper.ArgumentNull(style, nameof(style)); cell.BackgroundColor = new BaseColor(style.Content.GetColor()); cell.SetAlignmentVisualStyle(style.Content.Alignment); if (useTestMode.AsBoolean()) { cell.SetBordersVisualStyle( new BordersCollection { new BaseBorder { Color = "Red", Position = KnownBorderPosition.Left, Show = YesNo.Yes }, new BaseBorder { Color = "Red", Position = KnownBorderPosition.Top, Show = YesNo.Yes }, new BaseBorder { Color = "Red", Position = KnownBorderPosition.Right, Show = YesNo.Yes }, new BaseBorder { Color = "Red", Position = KnownBorderPosition.Bottom, Show = YesNo.Yes } }); } else { cell.SetBordersVisualStyle(style.Borders); } return(cell); }