Free Support Forum - groupdocs.com

Download and add watermark programmatically using C# .NET

Hi,When i’m downloading i need to add watermark to all file types(.pdf,.docx,.pptx,.xlsx)…Actually i’m getting document data in memory stream from blob…how to pass this to watermark().

watermark issue.png (31.7 KB)
watermark1.jpg (126.2 KB)

1 Like

@bharathiGK,

Please have a look at this documentation article. You can see that a document could be loaded from multiple sources and then watermark could be added. Loading a document from stream will help you out.

Okay.That Code i already checked.that not suits for me and i found another way to convert stream…Thank you

image.png (315.8 KB)

Hi.i have applied watermark on document,but i need to apply foreground watermark.

my watermark text should be visible above the image and i wish to divide watermark text,if length exceeds means,how it is possible in this.
image.jpg (168.9 KB)
like this screenshot i wish to apply.

i gone through the text watermark article and applied different scenario but fails.

1 Like

@bharathiGK,

We are investigating this scenario. Your investigation ticket ID is WATERMARKNET-1265. As there’s any update, you’ll be notified.

Do you mean split watermark text into multiple lines (add a line break)?

Yes correct.split string into multilines(it means line breaks)
“Confidential”
“UserName”
“TimeStamp”

like this i need to show watermark

1 Like

@bharathiGK,

Have a look at the code below, hopefully it’ll help you out.

string text= "Confidential" + System.Environment.NewLine + "UserName";
TextWatermark watermark= new TextWatermark(text, font);

Yeah…Thanks…I have applied same thing and i got correct output for .pdf files.
image.png (519.3 KB)

i’m dynamically getting .docx,.pdf,.pptx,.xlsx files…in that case its not coming properly.

string[] watermarkText = new string[] { “CONFIDENTIAL”, User.Identity.Name, $"{TimeZoneInfo.ConvertTimeToUtc(DateTime.Now, TimeZoneInfo.Local).ToString()} UTC" };
string VmText = Utilities.Text.AlignCenter(watermarkText);

        using (Watermarker watermarker = new Watermarker(stream))
        {
            Font font = new Font("Courier New", 20, FontStyle.Bold);
            TextWatermark watermark = new TextWatermark(VmText, font);
            watermark.ForegroundColor = Color.FromArgb(100, Color.LightGreen);
            watermark.Opacity = 0.5;
            watermark.TextAlignment = TextAlignment.Right;
            watermark.HorizontalAlignment = HorizontalAlignment.Center;
            watermark.VerticalAlignment = VerticalAlignment.Center;
            //watermark.ScaleFactor = 0.5;
            watermark.RotateAngle = -45;
            watermark.Height = 350;
            //watermark.Width = 200;

            watermarker.Add(watermark);
            watermarker.Save(filePathout);
        }

for word document i’m getting like below image.
image.png (237.4 KB)

@bharathiGK,

Can you please try to increase font size for the Word document? Watermark text is not readable.

I tried to increase the font size also.i’m getting like this if i increase font size…kindly help to do set up for word document.

image.png (270.5 KB)

like below pdf i need to get.same content i using for watermark.
image.png (519.3 KB)

if i give single word,its making correct.
image.png (288.3 KB)

@bharathiGK,

Thanks for the details. We are investigating this issue. Your investigation ticket ID is WATERMARKNET-1266. As there’s any update, you’ll be notified.

HI…I would like to get update soon.so can you make it possible…i’m the one of the user under frontedge consulting company…we already purchased license from you…
So what i want to do for getting update soonOrderid.jpg (7.7 KB)

1 Like

@bharathiGK,

Your issues are still under investigation. Please note that all issues are served on first come first served basis. We’ll surely let you know as there is any update.

However, in order to expedite resolution of these tickets, you may purchase the priority support.

Okay.Thank you for your information. Looking for the Investigation resuls.

1 Like

@bharathiGK,

We’ll surely notify you as there’s any update.

Hi how to apply redact by area selection and highlight on original document…
In viewer I’m showing original documents as a .png images and applying… coordinate s saving in document metadata storage…how to apply that on original document…
Because when i download a document i need to have redacted and highlight

1 Like

@bharathiGK,

You can use GroupDocs.Annotation API for text redaction. Please have a look at this article. Moreover, we’d recommend you to always create a new post for a new scenario/issue.