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

HTML causing unreadable content error message #222

Closed
JoshuaTruscott opened this issue Jul 10, 2021 · 8 comments
Closed

HTML causing unreadable content error message #222

JoshuaTruscott opened this issue Jul 10, 2021 · 8 comments
Labels

Comments

@JoshuaTruscott
Copy link

JoshuaTruscott commented Jul 10, 2021

When a HTML command is present in a template, opening the output document results in message:
"Word found unreadable content in "template.docx". Do you want to recover the contents of this document? If you trust the source of this document, click Yes."

Tested using the HTML example from the README

Example:

const buffer = await createReport({
  template: fs.readFileSync("template.docx")
});
fs.writeFileSync("output.docx", buffer);

Template used

Environment:
docx-templates v4.6.4
Node v14.2.0
Mac OS X v11.4

Thank you

@jjhbw
Copy link
Collaborator

jjhbw commented Jul 10, 2021

This probably means your specific HTML is malformed. Please provide a reproducible example, ideally limited to the HTML command in question.

@jjhbw jjhbw added the triage label Jul 10, 2021
@JoshuaTruscott
Copy link
Author

No problem, I've added the snippet and template used

@jjhbw jjhbw added bug and removed triage labels Jul 11, 2021
@jjhbw
Copy link
Collaborator

jjhbw commented Jul 11, 2021

Got it. Thanks for reporting. Looks like I messed something up when fixing #217 . This should be working as intended again after 636db40, which is currently on master and will be in the next release.

@jjhbw jjhbw closed this as completed Jul 11, 2021
@JoshuaTruscott
Copy link
Author

Amazing, thanks for all your help!

@jjhbw
Copy link
Collaborator

jjhbw commented Jul 12, 2021

Fix released in v4.7.0. Should be on NPM shortly.

@gognjanovski
Copy link

gognjanovski commented Mar 5, 2023

I get the same error when I try to inject more then 2 images with html. (even if I use base64 instead of url)

<meta charset="UTF-8">
<body>
    <div style="margin-top: 20px;">
        <img width="30" height="30"
            src="https://upload.wikimedia.org/wikipedia/commons/thumb/0/03/Circle-withsegments.svg/1200px-Circle-withsegments.svg.png" />
        <img width="30" height="30"
            src="https://upload.wikimedia.org/wikipedia/commons/thumb/0/03/Circle-withsegments.svg/1200px-Circle-withsegments.svg.png" />
        <img width="30" height="30"
            src="https://upload.wikimedia.org/wikipedia/commons/thumb/0/03/Circle-withsegments.svg/1200px-Circle-withsegments.svg.png" />
    </div>
</body>

Environment:
docx-templates v4.11.0
Node v14.17.3
Mac OS X v13.1

@jjhbw
Copy link
Collaborator

jjhbw commented Mar 6, 2023

@gognjanovski I don't think that's related to this issue, because HTML images are treated very differently from image commands using IMAGE commands. The HTML is inserted as-is using the altChunk spec, which AFAIK only works in MS Word.

If inserting 2 images works, but more than that gives you an error than this may be a limitation of MS Word instead.

@abhinovpankaj
Copy link

I have a very simple HTML tag inside a tble in the docx template, however once processed on opening the doc I am getting error while opening the file. And the field in the table comes as empty.

image image

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

4 participants