Skip to content

Instantly share code, notes, and snippets.

@GroupDocsGists
Last active May 1, 2021 20:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GroupDocsGists/c5637a7b8dd5d881e58e502c109ca4a0 to your computer and use it in GitHub Desktop.
Save GroupDocsGists/c5637a7b8dd5d881e58e502c109ca4a0 to your computer and use it in GitHub Desktop.
Apply Watermark to Presentation Slides in C# using .NET API
// Add image watermark to presentation slides in C# using .NET API
using (Watermarker watermarker = new Watermarker("presentation.pptx"))
{
// Set watermark image, coordinates and formatting
ImageWatermark imageWatermark = new ImageWatermark("watermark-image.png");
imageWatermark.Opacity = .7;
imageWatermark.X = 80;
imageWatermark.Y = 120;
// Apply Watermark to only second slide of the presentation
PresentationWatermarkSlideOptions ImageWatermarkOptions = new PresentationWatermarkSlideOptions();
ImageWatermarkOptions.SlideIndex = 1;
// Add watermark to presentation and save.
watermarker.Add(imageWatermark, ImageWatermarkOptions);
watermarker.Save("image-watermarked-presentation.pptx");
}
// Add text watermark to presentation slides in C# using .NET API
using (Watermarker watermarker = new Watermarker("presentation.pptx"))
{
// Set watermark text, coordinates and formatting
TextWatermark watermark = new TextWatermark("Watermark", new Font("Arial", 36))
{
RotateAngle = -45,
X = 100,
Y = 100,
Height = 400,
Width = 400,
Opacity = .2,
ForegroundColor = Color.DarkBlue,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center
};
// Apply Watermark to only first slide of the presentation
PresentationWatermarkSlideOptions textWatermarkOptions = new PresentationWatermarkSlideOptions();
textWatermarkOptions.SlideIndex = 0;
// Add watermark to presentation and save.
watermarker.Add(watermark, textWatermarkOptions);
watermarker.Save("text-watermarked-presentation.pptx");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment