Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aspose-com-kb/bd2cdda24eaf14ccbb16717a30d3818a to your computer and use it in GitHub Desktop.
Save aspose-com-kb/bd2cdda24eaf14ccbb16717a30d3818a to your computer and use it in GitHub Desktop.
This code can be used to add image watermark in PPTX presentation using C#. Refer to this article for more details: https://kb.aspose.com/slides/net/how-to-add-image-watermark-in-pptx-presentation-using-c-sharp/
using System;
using System.Drawing;
using Aspose.Slides;
using Aspose.Slides.Export;
namespace SlidesWatermark
{
class Program
{
static void Main(string[] args)
{
string PathForWatermarkPptFile = @"Y:\Downloads\";
License license = new License();
license.SetLicense(PathForWatermarkImageFile + "Conholdate.Total.Product.Family.lic");
//Load the presentation to insert watermark
Presentation WatermarkPptxPresentation = new Presentation(PathForWatermarkPptFile + "PictureWatermark.pptx");
// Loading watermark image to add in PPTX
System.Drawing.Image WatermarkLogo = (System.Drawing.Image)new Bitmap("Picture Watermark Logo.jpg");
IPPImage WatermarkImage = WatermarkPptxPresentation.Images.AddImage(WatermarkLogo);
//Accessing the master slides for adding watermark image
foreach (IMasterSlide masterSlide in WatermarkPptxPresentation.Masters)
{
//Adding a Ppt watermark shape for logo image
IPictureFrame PptxWatermark = masterSlide.Shapes.AddPictureFrame(ShapeType.Rectangle,0, 0,
200, 50, WatermarkImage);
//Set the rotation angle of the shape
PptxWatermark.Rotation = 325;
//Lock Pptx watermark image shape for protection in PowerPoint
PptxWatermark.ShapeLock.SizeLocked = true;
PptxWatermark.ShapeLock.SelectLocked = true;
PptxWatermark.ShapeLock.PositionLocked = true;
}
//Saving the image watermark PPTX presentation file
WatermarkPptxPresentation.Save(PathForWatermarkPptFile + "ImageWatermarkedPresentation.pptx",
SaveFormat.Pptx);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment