Files
docx-js/demo/demo15.ts

22 lines
532 B
TypeScript
Raw Normal View History

2018-08-21 02:46:21 +01:00
// Page break before example
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, Paragraph } from "../build";
const doc = new Document();
const paragraph = new Paragraph("Hello World");
2019-06-13 01:07:00 +01:00
const paragraph2 = new Paragraph({
text: "Hello World on another page",
pageBreakBefore: true,
});
2018-08-21 02:46:21 +01:00
2019-06-25 23:17:56 +01:00
doc.add(paragraph);
doc.add(paragraph2);
2018-08-21 02:46:21 +01:00
const packer = new Packer();
packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});