Using a better demo naming system

This commit is contained in:
Dolan
2019-08-06 23:08:21 +01:00
parent 82fef4c2b1
commit b741db3050
51 changed files with 22 additions and 15 deletions

31
demo/1-basic.ts Normal file
View File

@ -0,0 +1,31 @@
// Simple example to add text to a document
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, Paragraph, TextRun } from "../build";
const doc = new Document();
doc.addSection({
properties: {},
children: [
new Paragraph({
children: [
new TextRun("Hello World"),
new TextRun({
text: "Foo Bar",
bold: true,
}),
new TextRun({
text: "Github is the best",
bold: true,
}).tab(),
],
}),
],
});
const packer = new Packer();
packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});