News Category

Set Shadow Effects for the Text on the Presentation Slides

2017-01-16 08:22:44 Written by  support iceblue
Rate this item
(0 votes)

Spire.Presentation for .NET offers classes of InnerShadowEffect and OuterShadowEffect to enable developers to set the shadow effects for the Text on the presentation slides. This article will focus on how to apply the Font outer shadow effects for the Text in C#.

Firstly, view the effective screenshot for the Text after apply the outer shadow effects via Spire.Presentation.

Set Shadow Effects for the Text on the Presentation Slides

Step 1: Create an instance of Presentation class.

Presentation presentation = new Presentation();

Step 2: Get reference of the slide.

ISlide slide = presentation.Slides[0];

Step 3: Add a new rectangle shape to the first slide.

IAutoShape shape = slide.Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(120, 70, 450, 300));
shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None;

Step 4: Add the text to the shape and set the font for the text.

shape.AppendTextFrame("Text shading on slides");
shape.TextFrame.Paragraphs[0].TextRanges[0].LatinFont = new TextFont("Arial Black");
shape.TextFrame.Paragraphs[0].TextRanges[0].Fill.FillType = FillFormatType.Solid;
shape.TextFrame.Paragraphs[0].TextRanges[0].Fill.SolidColor.Color = Color.Black;

Step 5: Add outer shadow and set all necessary parameters.

Spire.Presentation.Drawing.OuterShadowEffect Shadow = new Spire.Presentation.Drawing.OuterShadowEffect();

Shadow.BlurRadius = 0;
Shadow.Direction = 50;
Shadow.Distance = 10;
Shadow.ColorFormat.Color = Color.Green;

Step 6: Apply the shadow effects to the shape.

shape.TextFrame.TextRange.EffectDag.OuterShadowEffect = Shadow;

Step 7: Save the document.

presentation.SaveToFile("Result.pptx", FileFormat.Pptx2010);

We can also use the code as below to set the inner shadow for the text font. It is almost the same as how to set the outer shadow effects.

Spire.Presentation.Drawing.InnerShadowEffect Shadow = new Spire.Presentation.Drawing.InnerShadowEffect();

Full codes of how to apply the shadow effects for the text font:

using Spire.Presentation;
using Spire.Presentation.Drawing;
using System.Drawing;
namespace SetShadowEffect
{
    class Program
    {
        static void Main(string[] args)
        {
            Presentation presentation = new Presentation();
            ISlide slide = presentation.Slides[0];

            IAutoShape shape = slide.Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(120, 70, 450, 300));
            shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None;

            shape.AppendTextFrame("Text shading on slides");
            shape.TextFrame.Paragraphs[0].TextRanges[0].LatinFont = new TextFont("Arial Black");
            shape.TextFrame.Paragraphs[0].TextRanges[0].Fill.FillType = FillFormatType.Solid;
            shape.TextFrame.Paragraphs[0].TextRanges[0].Fill.SolidColor.Color = Color.Black;

            //Spire.Presentation.Drawing.InnerShadowEffect Shadow = new Spire.Presentation.Drawing.InnerShadowEffect();

            //Add Outer shadow and set all necessary parameters
            Spire.Presentation.Drawing.OuterShadowEffect Shadow = new Spire.Presentation.Drawing.OuterShadowEffect();

            Shadow.BlurRadius = 0;
            Shadow.Direction = 50;
            Shadow.Distance = 10;
            Shadow.ColorFormat.Color = Color.Green;

            shape.TextFrame.TextRange.EffectDag.OuterShadowEffect = Shadow;

            presentation.SaveToFile("Result.pptx", FileFormat.Pptx2010);

        }
    }
}

Additional Info

  • tutorial_title:
Last modified on Friday, 24 September 2021 09:16