Files
docx-js/demo/26-paragraph-borders.ts

36 lines
1.1 KiB
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 { BorderStyle, Document, Packer, Paragraph } from "../build";
2018-08-22 00:51:18 +01:00
2021-03-19 20:53:56 +00:00
const doc = new Document({
sections: [
{
children: [
new Paragraph("No border!"),
new Paragraph({
text: "I have borders on my top and bottom sides!",
border: {
top: {
color: "auto",
space: 1,
2021-06-18 23:56:41 +01:00
style: BorderStyle.SINGLE,
2021-03-19 20:53:56 +00:00
size: 6,
},
bottom: {
color: "auto",
space: 1,
2021-06-18 23:56:41 +01:00
style: BorderStyle.SINGLE,
2021-03-19 20:53:56 +00:00
size: 6,
},
},
}),
],
},
2019-07-31 08:48:02 +01:00
],
2019-06-17 01:51:57 +01:00
});
2018-08-22 00:51:18 +01:00
2019-08-07 22:12:14 +01:00
Packer.toBuffer(doc).then((buffer) => {
2018-08-22 00:51:18 +01:00
fs.writeFileSync("My Document.docx", buffer);
});