Adding a watermark alters the original word document

Hello,

We’re trying to add watermark in Word documents using the Java module groupdocs-watermark.

Watermarks are being added succesfully, but they alter the original document (blank spaces/lines or modifying text alignment).

This is blocking because the final document (without any watermark) would be different than the watermarked one.

I’ve set up a full reproduction example and added it in this thread (the only missing part is our licence file set in Constants.LicenseFilePath :slight_smile:).

Examples.zip (45,2 Ko)

Here are the issues with the watermarked files :

  • document.docx and document3.docx : one line of “RANDOM TEXT RANDOM TEXT” is left-aligned instead of right-aligned.
  • document2.docx : blank spaces are added in the document, making it takes 2 pages instead of 1.

In addition, there is a GRAVE log during the processing :

GRAVE:
java.lang.UnsatisfiedLinkError: ‘java.util.Map com.groupdocs.watermark.internal.c.a.w.internal.a1.a.bv(int, java.lang.String)’

Any help would be really appreciated.

Thanks,
Regards.

Hi again,

I’ve found that the AllowOnlyFormFields mode addd locked section, which seems to be the origin of the issue :

image.png (3,8 Ko)

I’ve tried the ReadOnlyWithEditableContent mode which seems to work fine (my users should have the possibility to edit the document), but all the content is highlighted when document is opened (because Word displays editable areas with highlight) which is annoying.

Regards.

@Samoth
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WATERMARKJAVA-147

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Hi @Samoth ,
We are still investigating the described behavior. In the meantime, I’d like to ask if you truly need to use the locking mechanism for the applied watermark. If not, you could try removing the use of WordProcessingWatermarkPagesOptions and updating your code as follows:
Instead of:
watermarker.add(watermark, options);
Try:
watermarker.add(watermarks);

This approach will insert the watermark into the document’s header section. But user can still edit or select the watermark by switching to the header/footer editing mode in Word. This should help avoid the changes in spacing, alignment, or highlighting caused by the locking mechanism.
Let us please know if this improves the situation.

Hi @alexndr,

Thanks for your feedback.

I’m afraid that we really need to use the locking mechanism, because we have the requirement to identify document coming from production, and others.

Thus, a locked watermark is the most suitable solution for our need (because documents can also be printed).

Regards.

@Samoth

This scenario is still under investigation. We’ll notify you in case of any update.

hi @Samoth ,
Thank you for your patience

You are right that when using the AllowOnlyFormFields locking option, the library relies on Word’s sectioning mechanism. In this case, a new continuous section is created, the watermark is placed inside that section, and Word’s protection features are applied to lock it. This ensures the watermark cannot be modified unless the document protection is explicitly removed (which would require a password, if one was set in the watermark options).

However, inserting a new section—although visually invisible—does introduce special characters (like section breaks or newline characters), which can affect document layout and formatting. This is likely the cause of the visual artifacts you’re seeing, such as unexpected blank pages or text alignment issues.

When using the WordProcessingLockType.ReadOnlyWithEditableContent option, the library instead uses editable ranges in Word. It inserts the watermark into the header, applies protection, and then marks the rest of the document content as editable. Microsoft Word highlights these editable regions by default when opening the document. Although you can manually disable this highlight via Review → Restrict Editing → uncheck “Highlight the regions I can edit”, Word unfortunately does not persist this setting. This limitation is well known and discussed in communities like this thread, but Microsoft doesn’t currently offer a permanent solution.

You mentioned the need to “identify documents coming from production.” Could you clarify whether this identification needs to be visual (e.g., users seeing a watermark) or automated (e.g., detected by code)? This will help us suggest the most suitable solution for your scenario.
Also, have you considered saving the finalized Word document as a PDF, and then applying the watermark to the PDF instead? PDF watermarking is generally more stable and less prone to formatting issues.

Looking forward to your response.

Hello,
(I’m Samoth, under another account :slight_smile: ).

Considering the details you’ve provided, we will fallback to unlocked watermark for now, because we can’t afford to bother the users with unchecking the flag “Highlight the regions I can edit”.

The identification needs to be visual, because documents can be printed.

Also, we can’t directly generate PDF, because users must be able to modify the DOCX before printing it.

Regards.