Skip to content

Examples

Dolan edited this page Mar 10, 2017 · 6 revisions

In practice

I used this library in my personal portfolio/CV website. Click generate CV for a demonstration. http://www.dolan.bio

General

Simple paragraph

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();
paragraph.addText(institutionText);
paragraph.addText(dateText);

doc.addParagraph(paragraph);
var exporter = new docx.LocalPacker(doc);
exporter.pack('My Document');

Using Express Packer

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();
paragraph.addText(institutionText);
paragraph.addText(dateText);

var exporter = new docx.ExpressPacker(doc, res);
exporter.pack('My Document');

Would produce:

University College London

5th Dec 2015

Clone this wiki locally