C # How to add text, picture watermark to PPT

Source: Internet
Author: User
Tags border color

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.