Deprecate createParagraph in all demos
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
// Example how to display page numbers
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import { Document, Packer, PageNumberFormat, TextRun } from "../build";
|
||||
import { AlignmentType, Document, Packer, PageNumberFormat, Paragraph, TextRun } from "../build";
|
||||
|
||||
const doc = new Document(
|
||||
{},
|
||||
@ -11,20 +11,24 @@ const doc = new Document(
|
||||
},
|
||||
);
|
||||
|
||||
doc.Header.createParagraph("Foo Bar corp. ")
|
||||
.addRun(new TextRun("Page Number ").pageNumber())
|
||||
.addRun(new TextRun(" to ").numberOfTotalPages());
|
||||
doc.Header.addParagraph(
|
||||
new Paragraph("Foo Bar corp. ").addRun(new TextRun("Page Number ").pageNumber()).addRun(new TextRun(" to ").numberOfTotalPages()),
|
||||
);
|
||||
|
||||
doc.Footer.createParagraph("Foo Bar corp. ")
|
||||
.center()
|
||||
.addRun(new TextRun("Page Number: ").pageNumber())
|
||||
.addRun(new TextRun(" to ").numberOfTotalPages());
|
||||
doc.Footer.addParagraph(
|
||||
new Paragraph({
|
||||
text: "Foo Bar corp. ",
|
||||
alignment: AlignmentType.CENTER,
|
||||
})
|
||||
.addRun(new TextRun("Page Number: ").pageNumber())
|
||||
.addRun(new TextRun(" to ").numberOfTotalPages()),
|
||||
);
|
||||
|
||||
doc.createParagraph("Hello World 1").pageBreak();
|
||||
doc.createParagraph("Hello World 2").pageBreak();
|
||||
doc.createParagraph("Hello World 3").pageBreak();
|
||||
doc.createParagraph("Hello World 4").pageBreak();
|
||||
doc.createParagraph("Hello World 5").pageBreak();
|
||||
doc.addParagraph(new Paragraph("Hello World 1").pageBreak());
|
||||
doc.addParagraph(new Paragraph("Hello World 2").pageBreak());
|
||||
doc.addParagraph(new Paragraph("Hello World 3").pageBreak());
|
||||
doc.addParagraph(new Paragraph("Hello World 4").pageBreak());
|
||||
doc.addParagraph(new Paragraph("Hello World 5").pageBreak());
|
||||
|
||||
const packer = new Packer();
|
||||
|
||||
|
Reference in New Issue
Block a user