Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Watermark image support #297

Open
victormartinezj opened this issue Feb 20, 2023 · 1 comment
Open

Watermark image support #297

victormartinezj opened this issue Feb 20, 2023 · 1 comment

Comments

@victormartinezj
Copy link

I tried to add an image for watermark, in the template I added with text watermark the next snipped:

{{ IMAGE watermarkImage() }}

When using the library I used the next code:


  const buffer = await createReport({
    template,
    additionalJsContext: {
      watermarkImage: async () => {
          const url = "someUrl";
          const response = await axios(url, { responseType: "arraybuffer" });
          const imageBuffer = Buffer.from(response.data, "binary").toString("base64");
          return { width: 13, height: 7, data: imageBuffer, extension: ".jpg" };
          },
    },
    cmdDelimiter: ["{{", "}}"],
 });

The same function works great when the image is not watermark, but when I used it in watermark
it's not working and the result is the same text in the template:

{{ IMAGE watermarkImage() }}
water

I suppose that the problem reside in the configuration of watermarks not in the library itself,
I think that the configuration of 'text watermark' and 'image watermark' in word it's different
and the library can't convert the text watermark I added:

{{ IMAGE watermarkImage() }}

In an image watermark.

Would it be possible to add that functionality?
Is there an actual functionality and I did something wrong?

Thanks.

@jjhbw
Copy link
Collaborator

jjhbw commented Apr 14, 2023

Sorry for the late reply, but the answer only just occurred to me. I don't think page watermarks can be injected in the same way that regular images are injected. This would require custom manipulation of the docx XML tree, so I've marked this issue as a feature request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants