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.
@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.
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.
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.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.