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

IMAGE commands in the document body are ignored when a Shape/image is already present in header or footer #217

Closed
jjhbw opened this issue Jul 1, 2021 · 5 comments
Assignees
Labels

Comments

@jjhbw
Copy link
Collaborator

jjhbw commented Jul 1, 2021

Sure ! Here is a very simple template that is failing. I'm using the method injectSvg() that is in the documentation :
7078ebf0-16fe-68d6-0e45-e78a25feb224.docx

createReport({
    template: templateFile,
    data: {
    },
    noSandbox: true,
    cmdDelimiter: ['{{', '}}'],
    additionalJsContext: {
        injectSvg: () => {
            const svg_data = Buffer.from(...., 'utf-8');
            return { width: 6, height: 6, data: svg_data, extension: '.svg' };
        }
    }
})

(Just replace the Buffer.from(...) by the one that is in the documentation)

And the generated document :
fail.docx

Originally posted by @matcobat in #144 (comment)

@jjhbw jjhbw self-assigned this Jul 1, 2021
@jjhbw jjhbw added the bug label Jul 1, 2021
@JoshuaTruscott
Copy link

I'm having the same issue

@JoshuaTruscott
Copy link

Just to clarify, in my case I'm adding 2 images, a png in the header and a jpg in the body using IMAGE in the same manner as above. The png in the header renders but the jpg in the body doesn't.

@jjhbw
Copy link
Collaborator Author

jjhbw commented Jul 2, 2021

Thanks for clarifying. I've reproduced it. I also noticed that if you put 4 <> commands in your repro template, only 3 images get rendered.

Experimenting with candidate fixes now.

@jjhbw jjhbw changed the title Corrupt report when adding image in a shape in header/footer IMAGE commands in the document body are ignored when a Shape/image is already present in header or footer Jul 2, 2021
jjhbw added a commit that referenced this issue Jul 2, 2021
… to skip the first IMAGE command in the template.
jjhbw added a commit that referenced this issue Jul 2, 2021
… ensure images/shapes in headers and footers are also taken into account.
@jjhbw
Copy link
Collaborator Author

jjhbw commented Jul 2, 2021

Should be fixed in https://github.com/guigrpa/docx-templates/releases/tag/v4.6.4.

GH Actions should be publishing it to NPM right now. Let me know if you encounter anything weird. Thanks for reporting!

@jjhbw jjhbw closed this as completed Jul 2, 2021
@matcobat
Copy link

matcobat commented Jul 5, 2021

Many thanks ! It's working like a charm now !

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

No branches or pull requests

3 participants