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.

Hello,

Apologies for the long silence on this one. We have re-tested the issue on the current release and would like to close it with a summary of where things stand.

Fixed in 26.9. The UnsatisfiedLinkError you reported in your first message has been fixed and is available in GroupDocs.Watermark for Java 26.9. It was caused by an internal packaging problem in the released jar that prevented native font-metrics calls from being resolved; it was unrelated to the layout changes, it just happened to appear in the same log.

The layout changes: confirmed, and a format limitation. We re-verified the behaviour on your TestWatermark.docx with 26.9. A locked watermark with AllowOnlyFormFields still restructures the document:

Before:  1 section,  45 paragraphs
After:   3 sections, 23 paragraphs / watermark section / 22 paragraphs

As Alexander explained earlier in this thread, Word applies “allow only form fields” protection per section, so the only way to protect the watermark while leaving the rest of the document editable is to move it into its own section — which means splitting the surrounding content. This is inherent to the Word format rather than something we can correct in the library, so we are closing WATERMARKJAVA-147 as a format limitation.

Put plainly: the three requirements — the watermark cannot be removed, the document stays freely editable, and the layout is untouched — cannot all hold at once in a .docx file. Any protection strong enough to prevent removal of the watermark is applied at section level and therefore changes the document structure.

One option that was not discussed in this thread. If the goal of locking is identification rather than strict prevention, WordProcessingLockType.AllowOnlyRevisions may suit you better than what you have now:

WordProcessingWatermarkPagesOptions options = new WordProcessingWatermarkPagesOptions();
options.setLocked(true);
options.setLockType(WordProcessingLockType.AllowOnlyRevisions);

We verified on your file that it leaves the document structure unchanged — still 1 section and 45 paragraphs, no alignment or pagination changes, and no highlighting of editable regions. The document remains editable, and if someone deletes the watermark that deletion is recorded as a tracked revision, so it is visible in the document. It does not make removal impossible, but it does make it traceable, which may be a better trade-off than the unlocked watermarks you are currently using.

If that turns out not to fit your workflow either, or if you would like us to look at the problem from a different angle, please let us know and we will be glad to continue.

Best regards