From 9a6885f124a3452ac088d8f2cdf97af9b8682b74 Mon Sep 17 00:00:00 2001 From: Dolan Date: Wed, 23 Nov 2022 00:36:54 +0000 Subject: [PATCH] Add Thai Distributed demo --- demo/1-basic.ts | 1 + demo/78-thai-distributed.ts | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 demo/78-thai-distributed.ts diff --git a/demo/1-basic.ts b/demo/1-basic.ts index 925883dd6f..6e937dbeae 100644 --- a/demo/1-basic.ts +++ b/demo/1-basic.ts @@ -14,6 +14,7 @@ const doc = new Document({ new TextRun({ text: "Foo Bar", bold: true, + size: 40, }), new TextRun({ children: [new Tab(), "Github is the best"], diff --git a/demo/78-thai-distributed.ts b/demo/78-thai-distributed.ts new file mode 100644 index 0000000000..d5ffc13935 --- /dev/null +++ b/demo/78-thai-distributed.ts @@ -0,0 +1,27 @@ +// Simple example to add text to a document +// Import from 'docx' rather than '../build' if you install from npm +import * as fs from "fs"; +import { AlignmentType, Document, Packer, Paragraph, TextRun } from "../build"; + +const doc = new Document({ + sections: [ + { + properties: {}, + children: [ + new Paragraph({ + alignment: AlignmentType.THAI_DISTRIBUTE, + children: [ + new TextRun({ + text: "บริษัท บิสกิด จำกัด (บริษัทฯ) ได้จดทะเบียนจัดตั้งขึ้นเป็นบริษัทจำกัดตามประมวลกฎหมายแพ่งและพาณิชย์ของประเทศไทย เมื่อวันที่ 30 พฤษภาคม 2561 ทะเบียนนิติบุคคลเลขที่ 0845561005665", + size: 36, + }), + ], + }), + ], + }, + ], +}); + +Packer.toBuffer(doc).then((buffer) => { + fs.writeFileSync("My Document.docx", buffer); +});