public static void Run()
        {
            // ExStart:ShadowEffects
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Text();

            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);

            if (!IsExists)
            {
                System.IO.Directory.CreateDirectory(dataDir);
            }

            // Instantiate a PPTX class
            using (Presentation pres = new Presentation())
            {
                // Get reference of the slide
                ISlide sld = pres.Slides[0];

                // Add an AutoShape of Rectangle type
                IAutoShape ashp = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 150, 75, 150, 50);


                // Add TextFrame to the Rectangle
                ashp.AddTextFrame("Aspose TextBox");

                // Disable shape fill in case we want to get shadow of text
                ashp.FillFormat.FillType = FillType.NoFill;

                // Add outer shadow and set all necessary parameters
                ashp.EffectFormat.EnableOuterShadowEffect();
                IOuterShadow shadow = ashp.EffectFormat.OuterShadowEffect;
                shadow.BlurRadius              = 4.0;
                shadow.Direction               = 45;
                shadow.Distance                = 3;
                shadow.RectangleAlign          = RectangleAlignment.TopLeft;
                shadow.ShadowColor.PresetColor = PresetColor.Black;

                //Write the presentation to disk
                pres.Save(dataDir + "pres_out.pptx", SaveFormat.Pptx);
            }
            // ExEnd:ShadowEffects
        }
Example #2
0
        public static void Run()
        {
            //ExStart:SetTransparencyOfTextInShadow
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Text();

            using (Presentation pres = new Presentation(dataDir + "transparency.pptx"))
            {
                IAutoShape    shape   = (IAutoShape)pres.Slides[0].Shapes[0];
                IEffectFormat effects = shape.TextFrame.Paragraphs[0].Portions[0].PortionFormat.EffectFormat;

                IOuterShadow outerShadowEffect = effects.OuterShadowEffect;

                Color shadowColor = outerShadowEffect.ShadowColor.Color;
                Console.WriteLine($"{shadowColor} - transparency is: {((float)shadowColor.A / byte.MaxValue) * 100}");

                // set transparency to zero percent
                outerShadowEffect.ShadowColor.Color = Color.FromArgb(255, shadowColor);

                pres.Save(dataDir + "transparency-2.pptx", SaveFormat.Pptx);
            }
            //ExEnd:SetTransparencyOfTextInShadow
        }