2018-08-21 02:46:21 +01:00
|
|
|
// This demo shows right to left for special languages
|
2023-06-05 00:33:43 +01:00
|
|
|
|
2018-08-21 02:46:21 +01:00
|
|
|
import * as fs from "fs";
|
2023-06-05 00:33:43 +01:00
|
|
|
import { Document, Packer, Paragraph, Table, TableCell, TableRow, TextRun } from "docx";
|
2018-08-21 02:46:21 +01:00
|
|
|
|
2021-03-19 20:53:56 +00:00
|
|
|
const doc = new Document({
|
|
|
|
sections: [
|
|
|
|
{
|
2019-07-31 08:48:02 +01:00
|
|
|
children: [
|
2021-03-19 20:53:56 +00:00
|
|
|
new Paragraph({
|
|
|
|
bidirectional: true,
|
2021-03-04 02:02:28 +00:00
|
|
|
children: [
|
2021-03-19 20:53:56 +00:00
|
|
|
new TextRun({
|
|
|
|
text: "שלום עולם",
|
|
|
|
rightToLeft: true,
|
2021-03-04 02:02:28 +00:00
|
|
|
}),
|
2021-03-19 20:53:56 +00:00
|
|
|
],
|
|
|
|
}),
|
|
|
|
new Paragraph({
|
|
|
|
bidirectional: true,
|
|
|
|
children: [
|
|
|
|
new TextRun({
|
|
|
|
text: "שלום עולם",
|
|
|
|
bold: true,
|
|
|
|
rightToLeft: true,
|
2021-03-04 02:02:28 +00:00
|
|
|
}),
|
|
|
|
],
|
|
|
|
}),
|
2021-03-19 20:53:56 +00:00
|
|
|
new Paragraph({
|
|
|
|
bidirectional: true,
|
2021-03-04 02:02:28 +00:00
|
|
|
children: [
|
2021-03-19 20:53:56 +00:00
|
|
|
new TextRun({
|
|
|
|
text: "שלום עולם",
|
|
|
|
italics: true,
|
|
|
|
rightToLeft: true,
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
new Table({
|
|
|
|
visuallyRightToLeft: true,
|
|
|
|
rows: [
|
|
|
|
new TableRow({
|
|
|
|
children: [
|
|
|
|
new TableCell({
|
|
|
|
children: [new Paragraph("שלום עולם")],
|
|
|
|
}),
|
|
|
|
new TableCell({
|
|
|
|
children: [],
|
|
|
|
}),
|
|
|
|
],
|
2021-03-04 02:02:28 +00:00
|
|
|
}),
|
2021-03-19 20:53:56 +00:00
|
|
|
new TableRow({
|
|
|
|
children: [
|
|
|
|
new TableCell({
|
|
|
|
children: [],
|
|
|
|
}),
|
|
|
|
new TableCell({
|
|
|
|
children: [new Paragraph("שלום עולם")],
|
|
|
|
}),
|
|
|
|
],
|
2021-03-04 02:02:28 +00:00
|
|
|
}),
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
],
|
2021-03-19 20:53:56 +00:00
|
|
|
},
|
2019-07-31 08:48:02 +01:00
|
|
|
],
|
2019-06-17 01:51:57 +01:00
|
|
|
});
|
2018-08-21 02:46:21 +01:00
|
|
|
|
2019-08-07 22:12:14 +01:00
|
|
|
Packer.toBuffer(doc).then((buffer) => {
|
2018-08-21 02:46:21 +01:00
|
|
|
fs.writeFileSync("My Document.docx", buffer);
|
|
|
|
});
|