Change demo26 to typescript

This commit is contained in:
Dolan
2018-08-22 00:51:18 +01:00
parent 33f87523e0
commit 9a6c92222c
2 changed files with 22 additions and 20 deletions

View File

@ -1,20 +0,0 @@
/*
* Creates two paragraphs, one with a border and one without
*/
const docx = require("../build");
let doc = new docx.Document();
let paragraph = new docx.Paragraph("No border!");
doc.addParagraph(paragraph);
let borderParagraph = new docx.Paragraph("I have borders on my top and bottom sides!").createBorder();
borderParagraph.Borders.addTopBorder();
borderParagraph.Borders.addBottomBorder();
doc.addParagraph(borderParagraph);
let exporter = new docx.LocalPacker(doc);
exporter.pack('My Document');

22
demo/demo26.ts Normal file
View File

@ -0,0 +1,22 @@
// Creates two paragraphs, one with a border and one without
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, Paragraph } from "../build";
const doc = new Document();
const paragraph = new Paragraph("No border!");
doc.addParagraph(paragraph);
const borderParagraph = new Paragraph("I have borders on my top and bottom sides!").createBorder();
borderParagraph.Borders.addTopBorder();
borderParagraph.Borders.addBottomBorder();
doc.addParagraph(borderParagraph);
const packer = new Packer();
packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});