Remove text and image watermarks in presentation slides

We have demonstrated how to use Spire.Presentation to add text watermark and image watermark to the presentation slides. This article will show how to remove text and image watermarks in presentation slides in C#.

Firstly, view the sample document contains the text and image watermark.

Remove text and image watermarks in presentation slides

Step 1: Create a presentation document and load the document from the file

Presentation ppt = new Presentation();
ppt.LoadFromFile("Sample.pptx", FileFormat.Pptx2013);

Step 2: Remove the text and image watermark.

Remove text watermark by removing the shape with contains the text string "Confidential".

for (int i = 0; i < ppt.Slides.Count; i++)
{
    for (int j = 0; j < ppt.Slides[i].Shapes.Count; j++)
    {
        if (ppt.Slides[i].Shapes[j] is IAutoShape)
        {
            IAutoShape shape = ppt.Slides[i].Shapes[j] as IAutoShape;
            if (shape.TextFrame.Text.Contains("Confidential"))
            {
                ppt.Slides[i].Shapes.Remove(shape);
            }
        }
    }
}

Remove image watermark by setting SlideBackground.Fill.FillType as none.

for (int i = 0; i < ppt.Slides.Count; i++)
{
    ppt.Slides[i].SlideBackground.Fill.FillType = FillFormatType.None;
}

Step 3: Save the document to file.

ppt.SaveToFile("RemoveWartermark.pptx", FileFormat.Pptx2013);

Effective screenshot after removing the text and image watermark:

Remove text and image watermarks in presentation slides

Remove text and image watermarks in presentation slides

Full codes:

Remove text watermark in presentation slides:

Presentation ppt = new Presentation();
ppt.LoadFromFile("Sample.pptx", FileFormat.Pptx2013);

for (int i = 0; i < ppt.Slides.Count; i++)
{
    for (int j = 0; j < ppt.Slides[i].Shapes.Count; j++)
    {
        if (ppt.Slides[i].Shapes[j] is IAutoShape)
        {
            IAutoShape shape = ppt.Slides[i].Shapes[j] as IAutoShape;
            if (shape.TextFrame.Text.Contains("Confidential"))
            {
                ppt.Slides[i].Shapes.Remove(shape);
            }
        }
    }
}
ppt.SaveToFile("RemoveTextWartermark.pptx", FileFormat.Pptx2013);

Remove image watermark in presentation slides:

Presentation ppt = new Presentation();
ppt.LoadFromFile("Sample2.pptx", FileFormat.Pptx2013);

for (int i = 0; i < ppt.Slides.Count; i++)
{
    ppt.Slides[i].SlideBackground.Fill.FillType = FillFormatType.None;
}

ppt.SaveToFile("RemovePicWatermak.pptx", FileFormat.Pptx2013);