Hey, my organization is really interested in GroupsDocs.Watermark package (primarily in Python language), so we’re testing it right now to see whether it’s suitable for our needs.
Current issue which we’re trying to solve is connected to adding watermark to docx files. Our expected result is to have same multiline tile watermark as we’ve made in pdf and few other file extensions using GroupsDocs.Watermark library.
In case I’m trying to use this code for the .docx files, the result is unacceptable and usually looks like this. As you can see on the screenshot, multiline watermark is not displayed properly and even first row (user_email parameter) is not displayed fully. Font size could not be set to less that 24. That’s reproducible not only for multiline tile watermarks, for usual one watermark per file this result is kinda same. Screenshot 2024-11-18 at 17.47.21.png (381.1 KB)
So, questions are next:
Is it possible to implement multiline tile watermark pattern in .docx files using python library or any other language? If yes, can you share some ideas of implementation / fixes for this?
How stable and long-term supported is python version of the library? Should we consider moving to C# one or python version also will have periodical updates?
@artempenteskul
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): 363327
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.
We have attempted to reproduce the described issue with the DOCX file using your provided code but have not been able to replicate the problem on our side. I tested both the .NET package and the Python package in a Windows environment, and both produced identical results. Since Helvetica is not a default Windows font, I used Arial as a substitute.
For your reference, I have attached the initial file (sample.docx) and the resulting file (result.docx):
For the Python tests, I used Python version 3.8.0.
This might be an issue specific to your DOCX file. Could you please try reproducing the issue with the attached sample.docx? If the issue gone, we would appreciate it if you could share your DOCX file for further investigation.
Additionally, have you tested the issue in a Windows environment using the .NET package? This information would help us narrow down the root cause.
Regarding your question about Python long-term support:
Currently, we aim to release a new Python version approximately every three months. Additionally, we may release updates on demand to address critical issues or implement necessary error corrections.
In comparison to the .NET package, the Python package includes most of the core functionalities, such as adding and removing watermarks. However, there are some limitations in modification capabilities—for example, adding a watermark to a specific existing image within a PDF document is not yet supported.
I’ve tested more cases today (both with C# and Python library and on different operating systems: MacOS & Windows). Issue which is described above replicates only in Word on MacOS (it does not matter whether file was created with C# or Python library, it reproduces always).
I think that it’s either related to the settings in the Word or maybe it’s native Word bug. It looks like whole text is present in the watermark, but font size and the width & height of the watermark shape are wrong and that’s why it’s not displayed properly.
I’m attaching screenshots how your result.docx file looks in Word on MacOS just after I’ve opened it. Screenshot 2024-11-19 at 21.11.38.jpg (193.4 KB)
Screenshot 2024-11-19 at 21.31.54.png (397.3 KB) (on this screenshot I’m trying to show that text is present, just font size and watermark shape size is wrong)
I would be grateful if you could provide any information regarding this. Anyway, thanks for you input.
hi @artempenteskul ,
Thank you for your response. We will investigate the mentioned behavior on macOS. Based on some discussions and observations found on the internet, it seems there could be differences in how DOCX documents are rendered across different operating systems.
On Windows, Microsoft Word displays result.docx as expected. However, when I opened it using Office Online (Microsoft365), it didn’t render properly, same moment it displayed correctly in Google Docs. Please see samples: Win Microsoft Word.png (80.5 KB) Office online.png (9.7 KB)
We also checked result.docx view in the Mac and it looks good, here is a screenshot media_20241120_213212.jpg (77.3 KB)
So I think it might depend on the Mac OS version and the specific document viewer. Can you please provide us details about your version of the Mac OS and which document viewer do you use.
@artempenteskul Also as a test I suggest to try an alternative approach for generating DOCX watermarks. This method places watermarks in the document body instead of the document header section. Docx file generated with such approach will be presented properly on your side. To implement this, you can use the following settings in your code:
pages_setup = gww.PagesSetup()
pages_setup.first_page = True # This is one of the ways to force creating watermarks in the docx body section
watermark.pages_setup = pages_setup
Additionally, you can add the following setting to make the document partially read-only:
import groupdocs.watermark.options.wordprocessing as gwow
options = gwow.WordProcessingWatermarkPagesOptions()
options.is_locked = True
options.lock_type = gwow.WordProcessingLockType.ALLOW_ONLY_FORM_FIELDS
watermarker.add(watermark, options) # Use this instead of watermarker.add(watermark)
This is the output file. Office Online displays it properly. in body lock.docx (12.9 KB)
Let us know if this approach helps or if you encounter any further issues.
@artempenteskul hi,
I just wanted to check in and see if you were able to resolve the issue. Do you still need any assistance or have any additional questions? I’d be happy to help further if needed.
I’m still facing this issue on MacOS, making file readonly helps in office-365-online, but not on MacOS.
I’ve tried your proposal above about gww.PagesSetup(). I think you were mistaken with it as from your documentation gww.PagesSetup is responsible for other functionality and not for creating watermarks in body section as I understand.
The only workaround for MacOS that I’m working on is to set hardcoded watermark.height and watermark.width (need to set values for width & height that are big enough to show text with 24 font_size). As I mentioned above, on MacOS it’s not possible to set font_size less than 24 (which probably the root of the problem).
The described solution with setting watermark.width and watermark.height is not the most stable and reliable one, and also it changes basically whole implementation.
I would be grateful if you have any updates / plans on situation with MacOS bug or any code snippets to implement tile pattern with explicitly setting watermark.height & watermark.width.
@artempenteskul hi,
Can you please provide us details about your version of the Mac OS and which document viewer do you use. As mentioned earlier, we are unable to reproduce the issue on our macOS machine. For reference, here is a screenshot of how the DOCX file appears on our system: media_20241120_213212.jpg (77.3 KB)
Regarding PagesSetup:
By default, we create the watermarks in the header section of the Word document. However, when any option in PagesSetup is enabled, the watermark is applied in the content section instead. So visually, it will look the same, but different document viewers may render it differently.
hi @artempenteskul
Thank you for your patience. We are still investigating that behavior and need more time for our analysis. We’ll get back to you as soon as we have more information or updates to share.