2019-08-05 13:42:45 +03:00
|
|
|
import * as fs from "fs";
|
2019-08-06 21:37:33 +01:00
|
|
|
import { AlignmentType, Document, Header, Packer, Paragraph, ShadingType, TextRun } from "../build";
|
2019-08-05 13:42:45 +03:00
|
|
|
|
|
|
|
const doc = new Document();
|
|
|
|
|
2019-08-06 21:37:33 +01:00
|
|
|
doc.addSection({
|
|
|
|
headers: {
|
|
|
|
default: new Header({
|
|
|
|
children: [
|
|
|
|
new Paragraph({
|
|
|
|
alignment: AlignmentType.RIGHT,
|
|
|
|
children: [
|
|
|
|
new TextRun({
|
|
|
|
text: "Hello World",
|
|
|
|
color: "red",
|
|
|
|
bold: true,
|
|
|
|
size: 24,
|
|
|
|
font: {
|
|
|
|
name: "Garamond",
|
|
|
|
},
|
|
|
|
shadow: {
|
|
|
|
type: ShadingType.REVERSE_DIAGONAL_STRIPE,
|
|
|
|
color: "00FFFF",
|
|
|
|
fill: "FF0000",
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
children: [],
|
|
|
|
});
|
2019-08-05 13:42:45 +03:00
|
|
|
|
|
|
|
const packer = new Packer();
|
|
|
|
|
|
|
|
packer.toBuffer(doc).then((buffer) => {
|
|
|
|
fs.writeFileSync("My Document.docx", buffer);
|
|
|
|
});
|