public static string GetFillStyle <T>(IFillFormatEffectiveData format, TemplateContext <T> model)
        {
            string result = "";

            switch (format.FillType)
            {
            case FillType.Solid:
                result = string.Format("background-color: {0};", ColorHelper.GetRrbaColorString(format.SolidFillColor));
                break;

            case FillType.Picture:
                result = string.Format("background-image: url(\"{0}\");", ImageHelper.GetImageURL(format.PictureFillFormat.Picture.Image, model));
                break;

            case FillType.Gradient:
                result = string.Format("background: {0};", FillHelper.GetGradientFill(format.GradientFormat));
                break;

            case FillType.Pattern:
                result = string.Format("background: url(\"{0}\") repeat;", PatternGenerator.GetPatternImage(format.PatternFormat.PatternStyle, format.PatternFormat.ForeColor, format.PatternFormat.BackColor));
                break;
            }

            return(result);
        }
        public static string GetTextBulletStyle <T>(IParagraphFormatEffectiveData format, ITextFrameFormatEffectiveData textFrameFormat, bool isTableContent, TemplateContext <T> model)
        {
            var firstPortionFormatEffective = (model.Object as Paragraph).Portions[0].PortionFormat.GetEffective();

            string fontBoldItalicStyle = GetTextFontItalicStyle(firstPortionFormatEffective);

            string fontFill = "";

            switch (format.Bullet.Type)
            {
            case BulletType.Symbol:
            case BulletType.Numbered:
                if (format.Bullet.IsBulletHardColor)
                {
                    fontFill = string.Format("color: {0};", ColorHelper.GetRrbaColorString(format.Bullet.FillFormat.SolidFillColor));
                }
                else
                {
                    fontFill = FillHelper.GetFillStyle(firstPortionFormatEffective.FillFormat, model);
                    if (fontFill.StartsWith("background-color: "))
                    {
                        // fix for solid fill
                        fontFill = fontFill.Replace("background-color: ", "color: ");
                    }
                    else
                    {
                        // additional css for non-solid fills
                        fontFill += " -webkit-text-fill-color: transparent; -webkit-background-clip: text;";
                    }
                }
                break;

            case BulletType.Picture:
                // picture bullet
                break;
            }

            IFontData bulletFont = firstPortionFormatEffective.LatinFont;

            if (format.Bullet.IsBulletHardFont && format.Bullet.Type != BulletType.Numbered)
            {
                bulletFont = format.Bullet.Font;
            }

            var shadowFix = (textFrameFormat.TextVerticalType == TextVerticalType.Vertical || textFrameFormat.TextVerticalType == TextVerticalType.Vertical270 ? -1 : 1)
                            * (isTableContent ? 0.5f : 1);

            string outerShadowStyle = "";

            if (firstPortionFormatEffective.EffectFormat.OuterShadowEffect != null)
            {
                outerShadowStyle = string.Format("text-shadow: {0}px {1}px {2}px {3};",
                                                 shadowFix * firstPortionFormatEffective.EffectFormat.OuterShadowEffect.Distance * Math.Cos((Math.PI / 180) * firstPortionFormatEffective.EffectFormat.OuterShadowEffect.Direction),
                                                 shadowFix * firstPortionFormatEffective.EffectFormat.OuterShadowEffect.Distance * Math.Sin((Math.PI / 180) * firstPortionFormatEffective.EffectFormat.OuterShadowEffect.Direction),
                                                 firstPortionFormatEffective.EffectFormat.OuterShadowEffect.BlurRadius,
                                                 ColorHelper.GetRrbaColorString(firstPortionFormatEffective.EffectFormat.OuterShadowEffect.ShadowColor));
            }

            string fontHeightStyle = string.Format("font-size: {0}px;", format.Bullet.Height * firstPortionFormatEffective.FontHeight / 100);
            string fontFamilyStyle = string.Format("font-family: {0};", bulletFont);

            return(string.Join(" ", fontBoldItalicStyle, fontFill, outerShadowStyle, fontHeightStyle, fontFamilyStyle));
        }
        public static string GetTextStyle <T>(IPortionFormatEffectiveData format, ITextFrameFormatEffectiveData textFrameFormat, bool isTableContent, TemplateContext <T> model)
        {
            float fontHeight = format.FontHeight;

            string fontFillStyle = FillHelper.GetFillStyle(format.FillFormat, model);

            if (fontFillStyle.StartsWith("background-color: "))
            {
                // fix for solid fill
                fontFillStyle = fontFillStyle.Replace("background-color: ", "color: ");
            }
            else
            {
                // additional css for non-solid fills
                fontFillStyle += " -webkit-text-fill-color: transparent; -webkit-background-clip: text;";
            }

            string escapedTextStyle = "";

            if (format.Escapement != 0)
            {
                escapedTextStyle = string.Format("position: relative; top: {0}px;", -fontHeight * format.Escapement / 100);
                fontHeight      *= 0.67f;
            }

            string textDecorationStyle = "";

            if (format.StrikethroughType != TextStrikethroughType.None)
            {
                string underlineStyle = "";
                switch (format.StrikethroughType)
                {
                case TextStrikethroughType.Double:
                    underlineStyle = "double";
                    break;

                default:
                    underlineStyle = "solid";
                    break;
                }

                textDecorationStyle = string.Format("text-decoration: line-through {0};", underlineStyle);
            }

            if (format.FontUnderline != TextUnderlineType.None)
            {
                string underlineStyle = "";
                switch (format.FontUnderline)
                {
                case TextUnderlineType.Dotted:
                case TextUnderlineType.HeavyDotted:
                    underlineStyle = "dotted";
                    break;

                case TextUnderlineType.Dashed:
                case TextUnderlineType.DotDash:
                case TextUnderlineType.DotDotDash:
                case TextUnderlineType.LongDashed:
                case TextUnderlineType.HeavyDashed:
                case TextUnderlineType.HeavyDotDash:
                case TextUnderlineType.HeavyDotDotDash:
                case TextUnderlineType.HeavyLongDashed:
                    underlineStyle = "dashed";
                    break;

                case TextUnderlineType.Wavy:
                case TextUnderlineType.DoubleWavy:
                case TextUnderlineType.HeavyWavy:
                    underlineStyle = "wavy";
                    break;

                case TextUnderlineType.Double:
                    underlineStyle = "double";
                    break;

                default:
                    underlineStyle = "solid";
                    break;
                }

                textDecorationStyle = string.Format("text-decoration: underline {0} {1};", underlineStyle, ColorHelper.GetRrbaColorString(format.UnderlineFillFormat.SolidFillColor));
            }

            var shadowFix = (textFrameFormat.TextVerticalType == TextVerticalType.Vertical || textFrameFormat.TextVerticalType == TextVerticalType.Vertical270 ? -1 : 1)
                            * (isTableContent ? 0.5f : 1);

            string outerShadowStyle = "";

            if (format.EffectFormat.OuterShadowEffect != null)
            {
                outerShadowStyle = string.Format("text-shadow: {0}px {1}px {2}px {3};",
                                                 shadowFix * format.EffectFormat.OuterShadowEffect.Distance * Math.Cos((Math.PI / 180) * format.EffectFormat.OuterShadowEffect.Direction),
                                                 shadowFix * format.EffectFormat.OuterShadowEffect.Distance * Math.Sin((Math.PI / 180) * format.EffectFormat.OuterShadowEffect.Direction),
                                                 format.EffectFormat.OuterShadowEffect.BlurRadius,
                                                 ColorHelper.GetRrbaColorString(format.EffectFormat.OuterShadowEffect.ShadowColor));
            }

            string strokeStyle = "";

            if (format.LineFormat.FillFormat.FillType == FillType.Solid)
            {
                strokeStyle = string.Format("-webkit-text-stroke: {0}px {1};", format.LineFormat.Width, ColorHelper.GetRrbaColorString(format.LineFormat.FillFormat.SolidFillColor));
            }
            else if (format.LineFormat.FillFormat.FillType == FillType.Gradient)
            {
                strokeStyle = "";
            }

            string spacingStyle = "";

            if (format.Spacing != 0)
            {
                spacingStyle = string.Format("letter-spacing: {0}px;", format.Spacing);
            }

            string fontBoldItalicStyle = GetTextFontItalicStyle(format);
            string fontFamilyStyle     = string.Format("font-family: {0};", format.LatinFont);
            string fontHeightStyle     = string.Format("font-size: {0}px;", fontHeight);
            string fontCapStyle        = "";

            if (format.TextCapType == TextCapType.All)
            {
                fontCapStyle = "text-transform: uppercase;";
            }
            else if (format.TextCapType == TextCapType.Small)
            {
                fontCapStyle = "font-variant: small-caps;";
            }

            return(string.Join(" ",
                               fontBoldItalicStyle,
                               fontFamilyStyle,
                               fontHeightStyle,
                               fontFillStyle,
                               escapedTextStyle,
                               textDecorationStyle,
                               outerShadowStyle,
                               strokeStyle,
                               spacingStyle,
                               fontCapStyle));
        }