DOCX Demo 4

node v10.14.1
version: 4.0.1
endpointsharetweet
const docx = require('docx@4.0.0'); const express = require("@runkit/runkit/express-endpoint/1.0.0"); const app = express(exports); const { Document, Packer } = docx; app.get("/", async (req, res) => { const doc = new docx.Document(); const table = doc.createTable(4, 4); table.getCell(2, 2).addContent(new Paragraph('Hello')); const packer = new Packer(); const b64string = await packer.toBase64String(doc); res.setHeader('Content-Disposition', 'attachment; filename=My Document.docx'); res.send(Buffer.from(b64string, 'base64')); });
Loading…

no comments

    sign in to comment