Change demo26 to typescript
This commit is contained in:
@ -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
22
demo/demo26.ts
Normal 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);
|
||||||
|
});
|
Reference in New Issue
Block a user