Files
docx-js/demo/48-vertical-align.ts

34 lines
974 B
TypeScript
Raw Normal View History

// Example of making content of section vertically aligned
2023-06-05 00:33:43 +01:00
import * as fs from "fs";
import { Document, Packer, Paragraph, VerticalAlignSection, TextRun, Tab } from "docx";
2021-03-19 20:53:56 +00:00
const doc = new Document({
sections: [
{
properties: {
verticalAlign: VerticalAlignSection.CENTER,
2021-03-19 20:53:56 +00:00
},
children: [
2021-03-19 20:53:56 +00:00
new Paragraph({
children: [
new TextRun("Hello World"),
new TextRun({
text: "Foo Bar",
bold: true,
}),
new TextRun({
2022-10-29 15:10:02 +01:00
children: [new Tab(), "Github is the best"],
2021-03-19 20:53:56 +00:00
bold: true,
}),
],
2019-11-21 01:02:46 +00:00
}),
],
2021-03-19 20:53:56 +00:00
},
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});