2017-03-12 21:34:49 +00:00
|
|
|
const docx = require('../build');
|
2018-08-14 01:46:48 +01:00
|
|
|
const fs = require('fs');
|
2017-03-12 21:34:49 +00:00
|
|
|
|
2018-01-31 00:32:13 +00:00
|
|
|
var doc = new docx.Document();
|
2017-03-12 21:34:49 +00:00
|
|
|
|
|
|
|
var paragraph = new docx.Paragraph("Hello World");
|
|
|
|
var institutionText = new docx.TextRun("University College London").bold();
|
|
|
|
var dateText = new docx.TextRun("5th Dec 2015").tab().bold();
|
2017-03-26 20:57:43 +01:00
|
|
|
paragraph.addRun(institutionText);
|
|
|
|
paragraph.addRun(dateText);
|
2017-03-12 21:34:49 +00:00
|
|
|
|
|
|
|
doc.addParagraph(paragraph);
|
2017-03-26 20:57:43 +01:00
|
|
|
|
2018-08-14 01:46:48 +01:00
|
|
|
var packer = new docx.Packer();
|
|
|
|
|
|
|
|
packer.toBuffer(doc).then((buffer) => {
|
|
|
|
fs.writeFileSync('My Document.docx', buffer);
|
|
|
|
});
|
2017-03-12 21:34:49 +00:00
|
|
|
|
2018-01-30 01:16:48 +00:00
|
|
|
console.log('Document created successfully at project root!');
|