I have been trying to create watermark in powerpoint I have a code below where I could add picture now how do I create transparency for picture so it looks like watermark
private void watermark_Click(object sender, RibbonControlEventArgs e)
{
PowerPoint.Application ppApp = Globals.ThisAddIn.Application;
PowerPoint.SlideRange ppslr = ppApp.ActiveWindow.Selection.SlideRange;
//ppApp.ActivePresentation.Slides.InsertFromFile("NepaSlide.pptx",2, 1,1);
//PowerPoint.ShapeRange ppShR = ppApp.ActiveWindow.Selection.ShapeRange;
int count= ppslr.Shapes.Count;
PowerPoint.Shape shape = ppslr.Shapes[count];
ppslr.Shapes.AddPicture("N-symbol.png",
Microsoft.Office.Core.MsoTriState.msoFalse,
Microsoft.Office.Core.MsoTriState.msoTrue,
shape.Left, shape.Top, shape.Width, shape.Height);
}
I know this is an old question but I didn't find a solution so I wrote the code myself.
public void AddWaterMarkToPowerPoint(string filePath)
{
string waterMarkText = "Top secret";
PowerPoint.Application ppApp = new PowerPoint.Application();
PowerPoint.Presentations pres = ppApp.Presentations;
PowerPoint.Presentation pptPresentation = pres.Open(filePath, MsoTriState.msoTrue, MsoTriState.msoTrue, MsoTriState.msoFalse);
for (int i = 1; i <= pptPresentation.Slides.Count; i++)
{
var test = pptPresentation.Slides[i].CustomLayout.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 200, 200, 600, 100);
test.TextFrame.TextRange.Text = waterMarkText;
test.Rotation = -45;
test.TextFrame.TextRange.Font.Color.RGB = Color.LightGray.ToArgb();
test.TextFrame.TextRange.Font.Size = 48;
}
pptPresentation.SaveAs(filePath);
pptPresentation.Close();
}
This code adds text to every slide in presentation. PowerPoint doesn't have the ability to add waterMark so we have to manufacture one by adding a light grey text.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.