Last active
April 28, 2024 09:38
Add Text Watermark to RTF Using C#. For more information, please follow link: https://kb.groupdocs.com/watermark/net/add-text-watermark-to-rtf-using-csharp/
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
using GroupDocs.Watermark.Common; | |
using GroupDocs.Watermark.Watermarks; | |
using GroupDocs.Watermark; | |
namespace AddTextWatermarktoRTFUsingCSharp | |
{ | |
internal class Program | |
{ | |
static void Main(string[] args) | |
{ | |
// Set License to avoid the limitations of Watermark library | |
License lic = new License(); | |
lic.SetLicense(@"GroupDocs.Watermark.lic"); | |
// Specify an absolute or relative path to your RTF | |
using (Watermarker watermarker = new Watermarker("input.rtf")) | |
{ | |
// Specify the desired text and font for the watermark | |
TextWatermark watermark = new TextWatermark("Watermark Text", | |
new Font("Arial", 60, FontStyle.Bold)); | |
// Specify font color and text opacity, rotation and alignments | |
watermark.ForegroundColor = Color.DarkGreen; | |
watermark.Opacity = 0.5; | |
watermark.HorizontalAlignment = HorizontalAlignment.Center; | |
watermark.VerticalAlignment = VerticalAlignment.Center; | |
watermark.RotateAngle = -45; | |
// Apply the watermark | |
watermarker.Add(watermark); | |
// Save the resulting RTF | |
watermarker.Save("output.rtf"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment