You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @dolanmiu, I'm trying to fill a word template with data from JSON, and found this amazing library, it's documentation says that works on server side and client side, until the most examples shows implementations in sever side... the function i'm trying to implement is "patchDocument", what takes an template file and fills it with some data but I'm getting the following message "Uncaught ReferenceError: patchDocument is not defined" like the library isn't included until is included... but when I try to generate a word document works fine.
It seems like the library wasn't included correctly
I've tried to include the library in the following ways:
2.-Installing it via npm and importing it via web-pack
require('./bootstrap');
import * as docx from "docx";
window.docx = docx;
With this two ways i tried to generate a word document and it works!!
But when tried to call the patchDocument (https://docx.js.org/#/usage/patcher?id=usage) method shows that is undefined...
Where response.download is the base64 string of the document, and my question is How is the correct way to include this library in a project to work on client side?
I understood that my question could be so basic, but I'm a little confused
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi @dolanmiu, I'm trying to fill a word template with data from JSON, and found this amazing library, it's documentation says that works on server side and client side, until the most examples shows implementations in sever side... the function i'm trying to implement is "patchDocument", what takes an template file and fills it with some data but I'm getting the following message "Uncaught ReferenceError: patchDocument is not defined" like the library isn't included until is included... but when I try to generate a word document works fine.
It seems like the library wasn't included correctly
I've tried to include the library in the following ways:
1.- From CDN:
<script src="https://cdn.jsdelivr.net/npm/docx@8.5/build/index.umd.min.js"></script>2.-Installing it via npm and importing it via web-pack
require('./bootstrap');
import * as docx from "docx";
window.docx = docx;
With this two ways i tried to generate a word document and it works!!
But when tried to call the patchDocument (https://docx.js.org/#/usage/patcher?id=usage) method shows that is undefined...
This is the code I'm trying to run:
Where response.download is the base64 string of the document, and my question is How is the correct way to include this library in a project to work on client side?
I understood that my question could be so basic, but I'm a little confused
Beta Was this translation helpful? Give feedback.
All reactions