Tile / Usual Watermark does not work in Python GroupDocs.Watermark for docx files

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.

That’s how watermark in pdf looks like.
Screenshot 2024-11-18 at 17.38.57.jpg (94.8 KB)

The code for it was taken from your github repo with only just few adjustments. We’re testing latest python build (24.9.1) on macos / windows

import groupdocs.watermark as gw
import groupdocs.watermark.watermarks as gww

USER_EMAIL = 'useremail@mail.com'
FILE_ID = '86f71790-2573-4a04-935f-3c83c3079a47'
DISCLAIMER = 'Confidential - Do not distribute - Subject to NDA'

def main():
    document_path = 'input.pdf'
    output_document_path = 'output.pdf'

    with gw.Watermarker(document_path) as watermarker:
        font = gww.Font('Helvetica', 10.0)
        watermark = gww.TextWatermark(f'{USER_EMAIL}\n{FILE_ID}\n{DISCLAIMER}', font)
        watermark.foreground_color = gww.Color.gray
        watermark.opacity = 0.4
        watermark.rotate_angle = -45.0
        watermark.text_alignment = gww.TextAlignment.CENTER

        line_spacing = gww.MeasureValue()
        line_spacing.measure_type = gww.TileMeasureType.POINTS
        line_spacing.value = 100.0

        watermark_spacing = gww.MeasureValue()
        watermark_spacing.measure_type = gww.TileMeasureType.POINTS
        watermark_spacing.value = 30.0

        watermark.tile_options = gww.TileOptions()
        watermark.tile_options.line_spacing = line_spacing
        watermark.tile_options.watermark_spacing = watermark_spacing

        watermarker.add(watermark)
        watermarker.save(output_document_path)


if __name__ == '__main__':
    aspose_license = gw.License()
    aspose_license.set_license('GroupDocs.WatermarkforPythonvia.NET.lic')

    main()

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:

  1. 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?
  2. 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?

Thanks for your response in advance!

@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.

hi @artempenteskul

  1. 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.

  1. 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.

Looking forward to your response.

hey @alexndr

Thanks for your quick research and reply.

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.