DOCX Demo 1

node v10.12.0
version: 3.0.0
endpointsharetweet
const docx = require("docx@4.0.0") const express = require("@runkit/runkit/express-endpoint/1.0.0"); const app = express(exports); const { Document, Paragraph, Packer } = docx; app.get("/", async (req, res) => { const doc = new Document(); const paragraph = new Paragraph("Hello World"); doc.addParagraph(paragraph); 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')); })
Created from: https://runkit.com/docs/endpoint
Loading…

no comments

    sign in to comment