Skip to content

Instantly share code, notes, and snippets.

@groupdocs-com-kb
Last active April 24, 2024 16:36

Revisions

  1. groupdocs-com-kb revised this gist Apr 24, 2024. No changes.
  2. groupdocs-com-kb revised this gist Apr 23, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Add Text Watermark to JPG Using C#.cs
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@ static void Main(string[] args)
    License lic = new License();
    lic.SetLicense(@"GroupDocs.Watermark.lic");

    // Specify an absolute or relative path to your JPG.
    // Specify an absolute or relative path to your JPG
    using (Watermarker watermarker = new Watermarker("input.jpg"))
    {
    // Specify the desired text and font for the watermark
  3. groupdocs-com-kb created this gist Apr 23, 2024.
    34 changes: 34 additions & 0 deletions Add Text Watermark to JPG Using C#.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    using GroupDocs.Watermark.Common;
    using GroupDocs.Watermark.Watermarks;
    using GroupDocs.Watermark;

    namespace AddTextWatermarktoJPGUsingCSharp
    {
    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 JPG.
    using (Watermarker watermarker = new Watermarker("input.jpg"))
    {
    // 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 JPG
    watermarker.Save("output.jpg");
    }
    }
    }
    }