DOCX Demo 7

node v10.24.1
version: 6.0.0
endpointsharetweet
// docx landscape demo const docx = require('docx@6.0.1'); const express = require("@runkit/runkit/express-endpoint/1.0.0"); const app = express(exports); const { Document, Packer, PageOrientation, Paragraph } = docx; app.get("/", async (req, res) => { const doc = new Document({ sections: [{ size: { orientation: PageOrientation.LANDSCAPE, }, children: [new Paragraph("Hello World")], }], }); 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