Files
docx-js/demo/33-sequential-captions.ts

32 lines
1.2 KiB
TypeScript
Raw Normal View History

// Sequential Captions
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, Paragraph, TextRun } from "../build";
const doc = new Document();
2019-07-31 08:48:02 +01:00
doc.addSection({
children: [
new Paragraph("Hello World 1->")
.addSequentialIdentifier("Caption")
.addRun(new TextRun(" text after sequencial caption 2->"))
.addSequentialIdentifier("Caption"),
new Paragraph("Hello World 1->")
.addSequentialIdentifier("Label")
.addRun(new TextRun(" text after sequencial caption 2->"))
.addSequentialIdentifier("Label"),
new Paragraph("Hello World 1->")
.addSequentialIdentifier("Another")
.addRun(new TextRun(" text after sequencial caption 3->"))
.addSequentialIdentifier("Label"),
new Paragraph("Hello World 2->")
.addSequentialIdentifier("Another")
.addRun(new TextRun(" text after sequencial caption 4->"))
.addSequentialIdentifier("Label"),
],
});
2019-08-07 22:12:14 +01:00
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});