This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const docx = require("@nativedocuments/docx-wasm"); | |
// init docx engine | |
docx.init({ | |
ND_DEV_ID: "4H2I80DDEVNAJQSGGIC3K98N8S", | |
ND_DEV_SECRET: "3CTNJA7DBQFA8UDV2GM8I60N38", | |
// ND_DEV_ID: "XXXXXXXXXXXXXXXXXXXXXXXXXX", // goto https://developers.nativedocuments.com/ to get a dev-id/dev-secret | |
// ND_DEV_SECRET: "YYYYYYYYYYYYYYYYYYYYYYYYYY", // you can also set the credentials in the enviroment variables | |
ENVIRONMENT: "NODE", // required | |
LAZY_INIT: true // if set to false the WASM engine will be initialized right now, usefull pre-caching (like e.g. for AWS lambda) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var JSZip = require('jszip'); | |
var Docxtemplater = require('docxtemplater'); | |
var fs = require('fs'); | |
var path = require('path'); | |
//Load the docx file as a binary | |
var content = fs | |
.readFileSync(path.resolve(__dirname, 'invoice-template.docx'), 'binary'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{CustomerName : "Microsoft Corp", | |
AddressLine1: "One Microsoft Way", | |
City: "Redmond", State: "WA", Zip: "98052", | |
Country: "USA", | |
InvoiceDate : "14 March 2019", | |
InvoiceNumber: "INV123", | |
Items: [ | |
{ | |
Item_Description: "Bananas", | |
Item_Price: "5", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Step 1: generate docx | |
var JSZip = require('jszip'); | |
var Docxtemplater = require('docxtemplater'); | |
var fs = require('fs'); | |
var path = require('path'); | |
//Load the docx file as a binary | |
var content = fs |