(Jan-19-2025, 09:02 AM)Keville_35 Wrote: 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");
Is this the simplest way? Maybe be careful and try step by step
Larz60+ write Feb-13-2025, 06:27 AM:
link removed
link removed