Add and protect watermark in DOC, PPT using .NET

@RR00371658,

Thanks for using GroupDocs.Watermark and sharing your concerns with us. GroupDocs.Watermark allows you to lock the watermark and make the editing of the watermark forbidden in PowerPoint and Excel documents. However, this feature is not supported for Word documents. Following is the sample code to lock the watermark in PowerPoint documents.

            using (SlidesDocument doc = Document.Load<SlidesDocument>("D:\\storage\\watermark.pptx"))
            {
                // Initialize text watermark
                TextWatermark watermark = new TextWatermark("Protected Document", new Font("Arial", 8));
                watermark.HorizontalAlignment = HorizontalAlignment.Center;
                watermark.VerticalAlignment = VerticalAlignment.Center;
                watermark.RotateAngle = 45;
                watermark.SizingType = SizingType.ScaleToParentDimensions;
                watermark.ScaleFactor = 1;

                watermark.IsBackground = true;
                
                // Settings to lock watermark
                SlidesShapeSettings setting = new SlidesShapeSettings();
                setting.IsLocked = true;

                foreach (SlidesSlide slide in doc.Slides)
                {
                     slide.AddWatermark(watermark, setting);
                }

                // Save document
                doc.Save();
            }

We are also checking if there are any plans to provide the feature of watermark locking in Word documents. We have logged it in our Issue Tracking System (with ID: WATERMARKNET-893) and we’ll keep you updated in case of any useful information.

Thanks for the reply. Great to know this option.
This will help to resume my POC work again with GroupDOCS.

  1. I tried and seems to be editable(removable) still. Is this because of evaluation version restriction ? Please confirm.

  2. Are multiple watermarks are allowed for all document types (PDF, PPTX,XLS,DOCX). I tried it thrown an error saying not possible in evaluation version. Hope it works with License ? Please confirm.

@RR00371658,

Thanks for your response.

We are able to reproduce this issue at our end. It has been logged in our Issue Tracking System (with ID: WATERMARKNET-895) for further investigation. We’ll keep you informed in case of further updates.

Yes, you can not add more than one watermark at a time in evaluation mode.

In case you want to evaluate the product without any restrictions, you can request a temporary license. For more details, please visit here.

@RR00371658,

We have just got an update regarding the locking of the watermark in Word documents.

Unfortunately, doc and docx formats do not provide a reliable way to protect a shape or any other object that can be considered as a watermark. We can try to mimic “protected” watermark using different workarounds but we can’t prevent a user from removing it even when he uses only Word application. Here are some protection techniques that can be implemented in GroupDocs.Watermark:

1) Make a document read-only. In this case, a user will not be able to edit anything inside a protected document. But it’s possible to copy all contents and paste it into a new Word document which will be editable. Except for this obvious drawback, there is another one: modern versions of MS Word display such documents in the reading mode in which all headers and footers are hidden. By default, GroupDocs.Watermark adds watermark to headers, so a user will not see it until try to edit or print the document.

Sample documents:

  • WatermarkInDocumentBody/ReadOnlyDocument.doc
  • WatermarkInDocumentBody/ReadOnlyDocument.docx
  • WatermarkInHeader/ReadOnlyDocument.doc
  • WatermarkInHeader/ReadOnlyDocument.docx

2) Make a document read-only but mark all content except watermark as editable. The document contents still can be copied and pasted into a new unprotected file. Word 2016 opens the document in editing mode but highlights text fragments that can be edited by a user.

Sample documents:

  • WatermarkInDocumentBody/ReadOnlyShape.doc
  • WatermarkInDocumentBody/ReadOnlyShape.docx
  • WatermarkInHeader/ReadOnlyShape.doc
  • WatermarkInHeader/ReadOnlyShape.docx

3) Another way to protect some parts of doc/docx file is to protect some specific sections of a document. The full recipe is described here: How to lock parts of document in Word?. In few words, we can add watermark to separate section and protect this section from editing. In this case, a user can’t use the ctrl+a shortcut to select whole document text but still can select document parts separated by inserted section. This approach has the following drawbacks:

  • We can’t use headers for watermarking, therefore a watermark is added to each document page. In case of image watermark, it can significantly increase resultant file size.
  • We are forced to change document structure by adding new sections.
  • MS Word 2016 displays output document in the reading mode by default.

Sample documents:

  • WatermarkInDocumentBody/ProtectedSection.doc
  • WatermarkInDocumentBody/ProtectedSection.docx

(Please download the above mentioned document samples from here.)

Please let us know which technique would be the most suitable for you to be implemented in GroupDocs.Watermark. We shall be looking forward to your response.

@RR00371658,

While the issue is under investigation, we would suggest you to try the following workaround to add watermark to the master slides of the PowerPoint presentation. In this case, the watermark will appear in all regular slides and a user will not be able to edit it directly. Following is the sample code for this:

using (SlidesDocument doc = Document.Load<SlidesDocument>("D:\\storage\\sample.pptx"))
            {
                // Initialize text watermark
                TextWatermark watermark = new TextWatermark("Protected Document", new Font("Arial", 8));
                watermark.HorizontalAlignment = HorizontalAlignment.Center;
                watermark.VerticalAlignment = VerticalAlignment.Center;
                watermark.RotateAngle = 45;
                watermark.SizingType = SizingType.ScaleToParentDimensions;
                watermark.ScaleFactor = 1;
 
                foreach (SlidesMasterSlide slide in doc.MasterSlides)
                {
                    slide.AddWatermark(watermark);
                }

                // Save document
                doc.Save("D:\\storage\\output.pptx");
            }

Hope it helps.

Sure. I am trying now. Thanks for suggestion.

Thanks for suggestion. I am yet to discuss internally to take a call here (FOR DOCX). I will let you know once finalized.

Perfect. It works. Thanks.

Hi Again,

Our requirements includes

  1. Watermarking (DOCX,PPTX,PDF,Images).
  2. Reading the applied watermarks to find our document.

Now, during evaluation of Images i noticed the ImageDocument is not able to return the watermarks when we are using FindWatermarks.

Can you please confirm, why so? Are there any limitation in eval mode?

@RR00371658,

Thanks for your response.

I am afraid that searching watermarks in image files is not supported by GroupDocs.Watermark. However, we have logged it in our Issue Tracking System (with ID: WATERMARKNET-896) and will check if we have any plans to provide support of this feature in the upcoming releases. We’ll keep you informed in case of any updates.

Based on discussion for DOCX, option 3 looks fine with us. However just to make sure, you are suggesting to do this directly on word document ? If so it wont work. we are planning to add watermarks to lot of documents dynamically during download by users.

If not, if any of the above suggested options are achievable by GroupDOCS using code it will be helpful. Kindly let us know how to achieve the same?

In either case please confirm asap.
Thanks

@RR00371658,

Thanks for your response.

In fact, those are the possible protection techniques that can be implemented in GroupDocs.Watermark. Hence, you will not have to do that manually once implemented in the API. We will keep you updated in case of further information.

Yes great to know this @usman.aziz.

Now after evaluating GroupDOCS with various use-cases and document types I have narrowed it down that only 2 outstanding issues needs to be addressed.

  1. The above DOCX options that we discussed above. As per your reply GroupDOCS Will provide API for option(3) which is workaround to adding non-removable watermark in docx.
    Additional info: We are expecting Text-based watermarking mainly.

  2. Reading the added watermarks from Images. As per your reply GroupDOCS has no options yet.
    Any chances if this can be implemented too? Or any other work-around available so that we can add a piece of hash-code to images invisibly and read the same? within or outside images (as metadata) also fine.
    but, which should not be removable.
    Additional info: We are expecting Text-based watermarking mainly.

@RR00371658,

Thanks for your response. We are investigating both of your mentioned points. We’ll get back to you as soon as we have any useful information for you. We appreciate your cooperation in this regards.

@RR00371658,

We are currently investigating to check if the support of reading watermarks from images can be provided in the upcoming releases. In case we would have any further information, we’ll share that with you.

@RR00371658,

We have an update regarding the feature of finding/reading watermark in images (logged as WATERMARKNET-896). The requested feature can’t be implemented at this moment. It is a very complex scenario and it may take too much time to implement an acceptable solution because it is related to the computer vision field. Besides, you can use any of the existing APIs provided by Google or Microsoft. The following URL might be helpful for you in this regards. https://www.quora.com/What-are-some-well-known-OCR-APIs-available-as-a-Webservice.

Hi,

Alright. Thanks.

Since the watermarking wont be sufficient 100% because of 2 reasons (It is removable) and not (readable) for images, we are evaluating the Meta-data API too.

I like to know is there any option in your metadata API to do the followings ?

  1. Add a key/value to all document types (doc,docx,ppt,pptx,xls,xlsx,jpeg/gif/png/pdf etc)?
  2. The added metadata should not be editable/removable at any cost by user. (important)
  3. Is there a way it can be hidden completely ? (if not also fine)

When i tried we are unable to save the metadata to evaluate. Please confirm. If possible share some code snippet too.

@RR00371658,

Thanks for coming back.

The locking of watermarks in Word and PowerPoint documents is under investigation and we hope that you will get these features in the upcoming versions. As soon as we have any updates, we’ll inform you here.

We have created a separate topic on your behalf for the questions about GroupDocs.Metadata. Please follow this topic for further updates.

@RR00371658,

The feature you have requested earlier to lock watermark in Word document (logged as WATERMARKNET-893) has been implemented in GroupDocs.Watermark for .NET 18.6. For details about this feature, please visit this documentation article.

@RR00371658,

The issue you have found earlier (logged as WATERMARKNET-895) has been fixed in this release. Furthermore, we have also introduced the feature to strengthen the protection of watermark in PowerPoint documents. For details, please visit this documentation article.