diff --git a/demo/demo26.js b/demo/demo26.js deleted file mode 100644 index e88469c48b..0000000000 --- a/demo/demo26.js +++ /dev/null @@ -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'); \ No newline at end of file diff --git a/demo/demo26.ts b/demo/demo26.ts new file mode 100644 index 0000000000..9fa560d260 --- /dev/null +++ b/demo/demo26.ts @@ -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); +});