Created
August 16, 2022 15:17
-
-
Save conholdate-docs-gists/448470d79d85d0f2ff66b57a55bec360 to your computer and use it in GitHub Desktop.
Adding text watermark | https://docs.conholdate.com/net/adding-text-watermark/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Constants.InImagePng is an absolute or relative path to your document. Ex: @"C:\Docs\image.png" | |
using (Watermarker watermarker = new Watermarker(Constants.InImagePng)) | |
{ | |
// Initialize the font to be used for watermark | |
Font font = new Font("Arial", 19, FontStyle.Bold | FontStyle.Italic); | |
// Create the watermark object | |
TextWatermark watermark = new TextWatermark("Test watermark", font); | |
// Set watermark properties | |
watermark.ForegroundColor = Color.Red; | |
watermark.BackgroundColor = Color.Blue; | |
watermark.TextAlignment = TextAlignment.Right; | |
watermark.Opacity = 0.5; | |
// Add watermark | |
watermarker.Add(watermark); | |
watermarker.Save(Constants.OutImagePng); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Read the complete article: https://docs.conholdate.com/net/adding-text-watermark/