Set border and shading in PowerPoint document in C#, VB.NET

Suppose you want your doc document more attract and prominent your content. You would use a kind of border and shading style to beatify your document and give prominence to the key points. AS well as doc document the PPT document also can set shape to as border and shading.

Spire.Presentation for .NET, a professional .NET PPT component to allow users to manipulate PPT documents without automation. It can set kinds of shape types which can help users to beatify their document as their expectation

Below demonstrate the effect by a screenshot which shows a shape type in PPT document with C#, VB.NET via Spire.Presentation for .NET.

Set border and shading in PPT document

There is a guide to introduce a method to set shape type to achieve above screenshot with C#, VB.NET via Spire.Presentation for .NET.

This method is:

First, new a PPT document and set its slide. Then, new a shape and set its line color and gradient color. Last set the font and fill style for the paragraph. Now Download and install Spire.Presentation for .NET and use below code to experience this method to set shape type in PPT document.

The full code:

[C#]
using System;
using System.Drawing;
using Spire.Presentation;
using Spire.Presentation.Drawing;

namespace BorderAndShading
{
    class Program
    {
        static void Main(string[] args)
        {
            Presentation presentation = new Presentation();

            //set background Image
            string ImageFile = @" bg.png";
            RectangleF rect = new RectangleF(0, 0, presentation.SlideSize.Size.Width, presentation.SlideSize.Size.Height);
            presentation.Slides[0].Shapes.AppendEmbedImage(ShapeType.Rectangle, ImageFile, rect);
            presentation.Slides[0].Shapes[0].Line.FillFormat.SolidFillColor.Color = Color.FloralWhite;

            //append new shape
            IAutoShape shape = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle,
                new RectangleF(120, 70, 450, 300));

            //set the LineColor
            shape.ShapeStyle.LineColor.Color = Color.Green;

            //set the gradient color of shape
            shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Gradient;
            shape.Fill.Gradient.GradientShape = Spire.Presentation.Drawing.GradientShapeType.Rectangle;
            shape.Fill.Gradient.GradientStyle = Spire.Presentation.Drawing.GradientStyle.FromCorner1;
            shape.Fill.Gradient.GradientStops.Append(1f, KnownColors.GreenYellow);
            shape.Fill.Gradient.GradientStops.Append(0, KnownColors.PowderBlue);
            shape.AppendTextFrame("Borders and Shading");

            //set the Font
            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;

            //save the document
            presentation.SaveToFile("BordersAndShading.pptx", FileFormat.Pptx2007);
            System.Diagnostics.Process.Start("BordersAndShading.pptx");
        }
    }
}
[VB.NET]
Imports System.Text
Imports System.Drawing
Imports Spire.Presentation
Imports Spire.Presentation.Drawing

Module Module1

    Sub Main()
        'create PPT document
        Dim presentation As New Presentation()

        'set background Image
        Dim ImageFile As String = "bg.png"
        Dim rect As New RectangleF(0, 0, presentation.SlideSize.Size.Width, presentation.SlideSize.Size.Height)
        presentation.Slides(0).Shapes.AppendEmbedImage(ShapeType.Rectangle, ImageFile, rect)
        presentation.Slides(0).Shapes(0).Line.FillFormat.SolidFillColor.Color = Color.FloralWhite

        'append new shape
        Dim shape As IAutoShape = presentation.Slides(0).Shapes.AppendShape(ShapeType.Rectangle, New RectangleF(30, 70, 550, 300))

        'set the LineColor
        shape.ShapeStyle.LineColor.Color = Color.Green

        'set the gradient color of shape
        shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Gradient
        shape.Fill.Gradient.GradientShape = Spire.Presentation.Drawing.GradientShapeType.Rectangle
        shape.Fill.Gradient.GradientStyle = Spire.Presentation.Drawing.GradientStyle.FromCorner1
        shape.Fill.Gradient.GradientStops.Append(1.0F, KnownColors.GreenYellow)

        shape.Fill.Gradient.GradientStops.Append(0, KnownColors.PowderBlue)
        shape.AppendTextFrame("Borders and Shading")

        'set the Font
        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

        'save the document
        presentation.SaveToFile("BordersAndShading.pptx", FileFormat.Pptx2007)
        System.Diagnostics.Process.Start("BordersAndShading.pptx")

    End Sub

End Module

Additional Info

  • tutorial_title: Set border and shading in PowerPoint
Last modified on Friday, 24 September 2021 09:17