Files
docx-js/demo/demo26.ts

37 lines
837 B
TypeScript
Raw Normal View History

2018-08-22 00:51:18 +01:00
// 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!");
2019-06-25 23:17:56 +01:00
doc.add(paragraph);
2018-08-22 00:51:18 +01:00
2019-06-17 01:51:57 +01:00
const borderParagraph = new Paragraph({
text: "I have borders on my top and bottom sides!",
border: {
top: {
color: "auto",
space: 1,
value: "single",
size: 6,
},
bottom: {
color: "auto",
space: 1,
value: "single",
size: 6,
},
},
});
2018-08-22 00:51:18 +01:00
2019-06-25 23:17:56 +01:00
doc.add(borderParagraph);
2018-08-22 00:51:18 +01:00
const packer = new Packer();
packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});