2017-03-12 21:34:49 +00:00
|
|
|
const docx = require('../build');
|
|
|
|
|
|
|
|
var doc = new docx.Document();
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
var media = new docx.Media();
|
|
|
|
media.addMedia("happy-penguins", "./demo/penguins.jpg");
|
2017-03-29 22:57:52 +01:00
|
|
|
var pictureRun = new docx.PictureRun(media.getMedia("happy-penguins"));
|
2017-03-26 20:57:43 +01:00
|
|
|
|
|
|
|
var exporter = new docx.LocalPacker(doc, undefined, undefined, undefined, media);
|
2017-03-12 21:34:49 +00:00
|
|
|
exporter.pack('My Document');
|
|
|
|
|
|
|
|
console.log('Document created succesfully at project root!');
|