b1c8b2beb83a7f1cc333c194c587edb2cf8faa79
In MS Word 2015 (and possibly others), leading and trailing spaces are ignored in text runs. This means that calling TextRun with leading/trailing space would result in a document that didn't include those spaces. The fix here (per http://officeopenxml.com/WPtext.php) is to include an extra attribute on the "w:t" element that forces word to recognize those spaces.
Generate .docx files with JS/TS very easily, written in TS.
docx
Install
$ npm install --save docx
Demo
$ npm run demo
will run the demo app in the demo
folder, which creates a file called "My Document.docx" in the root of the project
Guide
Please refer to the Wiki for details on how to use this library, examples and much more!
Simple Usage
// Used to create docx files
var docx = require('docx');
// Create document
var doc = new docx.Document();
// Add some content in the document
var paragraph = new docx.Paragraph("Some cool text here.");
// Add more text into the paragraph if you wish
paragraph.addRun(new docx.TextRun('Lorem Ipsum Foo Bar'));
doc.addParagraph(paragraph);
// Used to export the file into a .docx file
var exporter = new docx.LocalPacker(doc);
// Or use the express packer to make the file downloadable.
// res is express' Response object
var exporter = new docx.ExpressPacker(doc, res);
exporter.pack('My First Document');
// done! A file called 'My First Document.docx'
// will be in your file system if you used LocalPacker
// Or it will start downloading if you are using Express
Examples
Check the Wiki for examples.
Made with 💖
Huge thanks to @felipeochoa for awesome contributions to this project
Description
Languages
TypeScript
100%