Is there a way to add a text watermark that would be on every slide in the PPT or PPTX file using Aspose.Slides?
Thanks, Shannon
Is there a way to add a text watermark that would be on every slide in the PPT or PPTX file using Aspose.Slides?
Thanks, Shannon
Hi Shannon,
Here is sample code to add a simple water mark on a PPT slide:
Presentation pres = new Presentation();
Slide sld = pres.GetSlideByPosition(1);
TextFrame tf = sld.Shapes.AddRectangle(0, 0, 500, 500).AddTextFrame("Water Mark Text");
tf.LineFormat.ShowLines = false;
tf.Protection = ShapeProtection.LockSelect;
To learn how to apply formatting to the text in a TextFrame, visit here.
Thanks. After being sent to another project for a while, I am back on this and have two follow questions:
Dear Shannon,
There are two options for adding the watermark. You can add a shape containing watermark in master slide that is used by every slide or most of slides. This way the watermark will also be added on every slide. Secondly, you may add the watermark shape on each slide. You can use the Shape.AlternativeText property to add the name to the shape alternative text name. So, in future, if you want to delete that shape, you may find that shape by comparing equivalent text as that of stored in Shape.AlternativeText.
Thanks and Regards,
Thanks. One last set of questions. I followed your example, but am having trouble figuring out how to center the watermark and bring it to the front so it is not getting hidden behind other shapes. Also, using the Portion object for font does not seem to have a property for opacity, is there a way to make the watermark semi-transparent and on top?
Dear Shannon,
You can use the following code snippet to bring the shape forward and back ward from other shapes. You may use ZOrderCmd enumeration to for shapes to bring them forward and backward. Please follow this link for further details.
slide.Shapes[0].ZOrder(ZOrderCmd.BringToFront);
In order to know how to set the transparency to text in the portion, please proceed to this thread link.
Thanks and Regards,
Thanks,
Hi Shannon,
I am sorry for the delayed response.
I have worked with Shape.zOrder property and have been able to observe the effect of zOrder with shapes. For your kind reference, I have shared the code snippet for you as well.
Presentation pres = new Presentation();
Slide sld = pres.GetSlideByPosition(1);
TextFrame tf1 = sld.Shapes.AddRectangle(0, 0, 500, 500).AddTextFrame("Water Mark Text");
tf1.LineFormat.ShowLines = false;
tf1.Protection = ShapeProtection.LockSelect;
TextFrame tf2 = sld.Shapes.AddRectangle(0, 0, 1100, 700).AddTextFrame("Hello World");
//sld.FollowMasterObjects = false;
// sld.Shapes[1].ZOrder(ZOrderCmd.SendToBack);
sld.Shapes[0].ZOrder(ZOrderCmd.BringToFront);
Shape shp = sld.Shapes[1];
shp.FillFormat.Type = FillType.Solid;
shp.FillFormat.ForeColor. = System.Drawing.Color.Blue;
shp = sld.Shapes[0];
shp.FillFormat.Type = FillType.Solid;
shp.FillFormat.ForeColor = System.Drawing.Color.Yellow;
pres.Write("D:\\lock.ppt");
The equivalent property to zOrder in PPTX is using ShapesEx.Reorder() method in PPTX. Please proceed to this link for further details. AlternativeText is also property of ShapeEx class. Please follow this link for further details. The rectangle shape is one of AutoShapeEx type. Please share with us, if there is anything I can offer you.
Thanks and Regards,