Deprecate createParagraph in all demos
This commit is contained in:
@ -1,22 +1,32 @@
|
||||
// Page numbers
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import { Document, Packer, Paragraph, TextRun } from "../build";
|
||||
import { AlignmentType, Document, Packer, Paragraph, TextRun } from "../build";
|
||||
|
||||
const doc = new Document();
|
||||
|
||||
doc.createParagraph("First Page").pageBreak();
|
||||
doc.createParagraph("Second Page");
|
||||
doc.addParagraph(
|
||||
new Paragraph({
|
||||
text: "First Page",
|
||||
}).pageBreak(),
|
||||
);
|
||||
doc.addParagraph(new Paragraph("Second Page"));
|
||||
|
||||
const pageNumber = new TextRun("Page ").pageNumber();
|
||||
|
||||
const pageoneheader = new Paragraph("First Page Header ").right();
|
||||
const pageoneheader = new Paragraph({
|
||||
text: "First Page Header ",
|
||||
alignment: AlignmentType.RIGHT,
|
||||
});
|
||||
|
||||
pageoneheader.addRun(pageNumber);
|
||||
const firstPageHeader = doc.createFirstPageHeader();
|
||||
firstPageHeader.addParagraph(pageoneheader);
|
||||
|
||||
const pagetwoheader = new Paragraph("My Title ").right();
|
||||
const pagetwoheader = new Paragraph({
|
||||
text: "My Title ",
|
||||
alignment: AlignmentType.RIGHT,
|
||||
});
|
||||
|
||||
pagetwoheader.addRun(pageNumber);
|
||||
doc.Header.addParagraph(pagetwoheader);
|
||||
|
Reference in New Issue
Block a user