deno.land / x / docx@8.5.0 / demo / 58-section-types.ts
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192// Usage of different Section Types
import * as fs from "fs";import { Document, Packer, Paragraph, TextRun, SectionType } from "docx";
const doc = new Document({ sections: [ { properties: {}, children: [ new Paragraph({ children: [ new TextRun("Hello World"), new TextRun({ text: "Foo Bar", bold: true, }), ], }), ], }, { properties: { type: SectionType.CONTINUOUS, }, children: [ new Paragraph({ children: [ new TextRun("Hello World"), new TextRun({ text: "Foo Bar", bold: true, }), ], }), ], }, { properties: { type: SectionType.ODD_PAGE, }, children: [ new Paragraph({ children: [ new TextRun("Hello World"), new TextRun({ text: "Foo Bar", bold: true, }), ], }), ], }, { properties: { type: SectionType.EVEN_PAGE, }, children: [ new Paragraph({ children: [ new TextRun("Hello World"), new TextRun({ text: "Foo Bar", bold: true, }), ], }), ], }, { properties: { type: SectionType.NEXT_PAGE, }, children: [ new Paragraph({ children: [ new TextRun("Hello World"), new TextRun({ text: "Foo Bar", bold: true, }), ], }), ], }, ],});
Packer.toBuffer(doc).then((buffer) => { fs.writeFileSync("My Document.docx", buffer);});
Version Info