deno.land / x / docx@8.5.0 / demo / 22-right-to-left-text.ts
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172// This demo shows right to left for special languages
import * as fs from "fs";import { Document, Packer, Paragraph, Table, TableCell, TableRow, TextRun } from "docx";
const doc = new Document({ sections: [ { children: [ new Paragraph({ bidirectional: true, children: [ new TextRun({ text: "שלום עולם", rightToLeft: true, }), ], }), new Paragraph({ bidirectional: true, children: [ new TextRun({ text: "שלום עולם", bold: true, rightToLeft: true, }), ], }), new Paragraph({ bidirectional: true, children: [ new TextRun({ text: "שלום עולם", italics: true, rightToLeft: true, }), ], }), new Table({ visuallyRightToLeft: true, rows: [ new TableRow({ children: [ new TableCell({ children: [new Paragraph("שלום עולם")], }), new TableCell({ children: [], }), ], }), new TableRow({ children: [ new TableCell({ children: [], }), new TableCell({ children: [new Paragraph("שלום עולם")], }), ], }), ], }), ], }, ],});
Packer.toBuffer(doc).then((buffer) => { fs.writeFileSync("My Document.docx", buffer);});
Version Info