Jan-19-2025, 09:02 AM
(This post was last modified: Jan-19-2025, 09:30 AM by Gribouillis.)
This script creates a simple .docx file with some bold and italic text:
import { Document, Paragraph, TextRun } from "docx"; import { writeFileSync } from "fs"; // Create document const doc = new Document({ sections: [{ properties: {}, children: [ new Paragraph({ children: [ new TextRun({ text: "Hello World", bold: true, }), new TextRun({ text: " This is a new paragraph.", italics: true, }), ], }), ], }], }); // Used to export the file into a .docx file const buffer = await Packer.toBuffer(doc); // Write the file writeFileSync("My Document.docx", buffer); console.log("Document created successfully");
Gribouillis write Jan-19-2025, 09:30 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
our gd project- geometry dash