Adding a watermark to a document effectively declares and protects the document, which is one way to protect important files. In the PPT document can also set watermark, including text watermark and picture watermark, this article will tell how to pass spire.presentation for. NET to add watermarks to ppt, download and install free spire.presentationfor. NET, add reference DLL file, refer to the following procedure to complete the watermark Add.
1. Add a text watermark
Step One: Initialize Presentation class instance and loads the document
New Presentation ();pp T. LoadFromFile (@ "C:\Users\Administrator\Desktop\sample.pptx", fileformat.pptx2010 );
Step Two: Initializes an instance of the font class and instantiates the font format
New Font ("Arial"= Textrenderer.measuretext (" internal data ", Stringfont);
Step Three: draw a shape and specify size, fill color, border color, and rotation angle
New 2 2 = ppt. slides[0== =-;
Step Four: set shape properties to protect properties
True= Fillformattype.none;
Step Five: set Text size, color
" Internal Information " = = = Color.FromArgb (;
Step Six: Save the document
Ppt. SaveToFile ("textwatermark.pptx", fileformat.pptx2010);
After completing the preceding code steps, debug run the project program, generate the file (which can be viewed in the project file in Bin>debug) as shown in:
2. Add image watermark
Step One: Initialize a Presentation class instance and loads the document
New Presentation ();pp T. LoadFromFile (@ "C:\Users\Administrator\Desktop\sample.pptx", fileformat.pptx2010 );
Step Two: Set the background picture type and style for the first slide
Ppt. slides[0]. Slidebackground.type = spire.presentation.drawing.backgroundtype.custom;ppt. slides[0]. SlideBackground.Fill.FillType = fillformattype.picture;ppt. slides[0]. SlideBackground.Fill.PictureFill.FillType = Picturefilltype.stretch;
Step three: Load the picture and set the watermark for the first slide
Image img = image.fromfile (@ "C:\Users\Administrator\Desktop\images\1.jpg"= ppt. Images.append (IMG);pp T. slides[0]. SlideBackground.Fill.PictureFill.Picture.EmbedImage = image;
Step four: Save the document
Ppt. SaveToFile ("imagewatermark1.pptx", fileformat.pptx2010);
The above is to add a watermark to the PPT code operation, I hope this method can provide help, thanks to read!
C # How to add text, picture watermark to PPT