I'm trying to add a watermark to each slide in a PPTX and I'm having three issues:
- I cannot figure out how to set the color of the text
- I cannot figure out how to set the background color - I want it transparent
- I cannot figure out how to put it behind the image on the slide and make it look like a watermark
Here is the code I'm using:
private void AddDraftWatermark2(PresentationEx pres)
{
int watermarkWidth = 250;
int watermarkHeight = 100;
System.Drawing.SizeF slideSize = pres.SlideSize.Size;
float xPos = (slideSize.Width / 2) - (watermarkWidth / 2);
float yPos = (slideSize.Height / 2) - (watermarkHeight / 2);
foreach (SlideEx slide in pres.Slides)
{
int idx = slide.Shapes.AddAutoShape(ShapeTypeEx.Rectangle, xPos, yPos, watermarkWidth, watermarkHeight);
AutoShapeEx shp = (AutoShapeEx)slide.Shapes[idx];
shp.ShapeLock.PositionLocked = true;
shp.ShapeLock.SelectLocked = true;
shp.ShapeLock.SizeLocked = true;
shp.AddTextFrame("Draft");
ParagraphEx para1 = shp.TextFrame.Paragraphs[0];
para1.ParagraphFormat.Alignment = TextAlignmentEx.Center;
para1.ParagraphFormat.FontAlignment = FontAlignmentEx.Center;
para1.ParagraphFormat.DefaultPortionFormat.FillFormat.FillType = FillTypeEx.Solid;
PortionEx port1 = shp.TextFrame.Paragraphs[0].Portions[0];
port1.RawLatinFont = new FontDataEx("Arial");
port1.RawFontHeight = 96;
port1.RawFontBold = NullableBool.True;
port1.FillFormat.SolidFillColor.Color = System.Drawing.Color.FromArgb(50, 236, 236, 236);
}
}