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

50 lines
1.7 KiB
TypeScript
Raw Permalink Normal View History

// Sequential Captions
2023-06-05 00:33:43 +01:00
import * as fs from "fs";
2023-06-05 00:33:43 +01:00
import { Document, Packer, Paragraph, SequentialIdentifier, TextRun } from "docx";
2021-03-19 20:53:56 +00:00
const doc = new Document({
sections: [
{
2019-10-10 01:18:20 +01:00
children: [
2021-03-19 20:53:56 +00:00
new Paragraph({
children: [
new TextRun("Hello World 1->"),
new SequentialIdentifier("Caption"),
new TextRun(" text after sequencial caption 2->"),
new SequentialIdentifier("Caption"),
],
}),
new Paragraph({
children: [
new TextRun("Hello World 1->"),
new SequentialIdentifier("Label"),
new TextRun(" text after sequencial caption 2->"),
new SequentialIdentifier("Label"),
],
}),
new Paragraph({
children: [
new TextRun("Hello World 1->"),
new SequentialIdentifier("Another"),
new TextRun(" text after sequencial caption 3->"),
new SequentialIdentifier("Label"),
],
}),
new Paragraph({
children: [
new TextRun("Hello World 2->"),
new SequentialIdentifier("Another"),
new TextRun(" text after sequencial caption 4->"),
new SequentialIdentifier("Label"),
],
}),
2019-10-10 01:18:20 +01:00
],
2021-03-19 20:53:56 +00:00
},
2019-07-31 08:48:02 +01:00
],
});
2019-08-07 22:12:14 +01:00
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});