Clone and edit this document
Runkit
Runkit
home page
user forum
new notebook
clone notebook
download notebook
support & documentation
log in
sign up
new notebook
help & feedback
clone this notebook
download this notebook
Sign In
Sign Up
DOCX Demo 1
node v10.24.1
version:
3.0.0
endpoint
share
tweet
const docx = require("
[email protected]
") 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…
2 comments
posted
4 years ago
by
timgarciaa
How to convert base64 string back on frontend to download?
posted
a year ago
by
6486b9777002de0012a1c057
Anonmous
sign in
to comment