2018-06-26 23:34:39 +01:00
|
|
|
const docx = require("../build");
|
2018-06-26 00:03:37 +01:00
|
|
|
|
|
|
|
var doc = new docx.Document();
|
|
|
|
|
2018-06-26 23:34:39 +01:00
|
|
|
var paragraph = new docx.Paragraph("Hello World").pageBreak();
|
2018-06-26 00:03:37 +01:00
|
|
|
|
|
|
|
doc.addParagraph(paragraph);
|
|
|
|
|
|
|
|
var header = doc.createHeader();
|
|
|
|
header.createParagraph("Header on another page");
|
|
|
|
var footer = doc.createFooter();
|
|
|
|
footer.createParagraph("Footer on another page");
|
|
|
|
|
|
|
|
doc.addSection({
|
2018-08-07 01:25:28 +01:00
|
|
|
headerId: header.Header.ReferenceId,
|
|
|
|
footerId: footer.Footer.ReferenceId,
|
2018-06-26 23:34:39 +01:00
|
|
|
pageNumberStart: 1,
|
|
|
|
pageNumberFormatType: docx.PageNumberFormat.DECIMAL,
|
|
|
|
});
|
|
|
|
|
|
|
|
doc.createParagraph("hello");
|
|
|
|
|
|
|
|
doc.addSection({
|
2018-08-07 01:25:28 +01:00
|
|
|
headerId: header.Header.ReferenceId,
|
|
|
|
footerId: footer.Footer.ReferenceId,
|
2018-06-26 23:34:39 +01:00
|
|
|
pageNumberStart: 1,
|
|
|
|
pageNumberFormatType: docx.PageNumberFormat.DECIMAL,
|
|
|
|
orientation: docx.PageOrientation.LANDSCAPE,
|
2018-06-26 00:03:37 +01:00
|
|
|
});
|
|
|
|
|
2018-06-26 23:34:39 +01:00
|
|
|
doc.createParagraph("hello in landscape");
|
|
|
|
|
2018-06-26 00:03:37 +01:00
|
|
|
var exporter = new docx.LocalPacker(doc);
|
2018-06-26 23:34:39 +01:00
|
|
|
exporter.pack("My Document");
|
2018-06-26 00:03:37 +01:00
|
|
|
|
2018-06-26 23:34:39 +01:00
|
|
|
console.log("Document created successfully at project root!");
|