diff --git a/demo/browser-demo.html b/demo/browser-demo.html
index fff5dc7989..535b55beea 100644
--- a/demo/browser-demo.html
+++ b/demo/browser-demo.html
@@ -22,7 +22,7 @@
paragraph.addRun(institutionText);
paragraph.addRun(dateText);
- doc.addParagraph(paragraph);
+ doc.add(paragraph);
const packer = new Packer();
diff --git a/demo/demo1.ts b/demo/demo1.ts
index 83a9a3abd8..c8ed2e4781 100644
--- a/demo/demo1.ts
+++ b/demo/demo1.ts
@@ -17,7 +17,7 @@ const dateText = new TextRun({
paragraph.addRun(institutionText);
paragraph.addRun(dateText);
-doc.addParagraph(paragraph);
+doc.add(paragraph);
const packer = new Packer();
diff --git a/demo/demo10.ts b/demo/demo10.ts
index 8f312af128..62077cf4c4 100644
--- a/demo/demo10.ts
+++ b/demo/demo10.ts
@@ -135,70 +135,70 @@ class DocumentCreator {
const skills = data[2] as object[];
const achivements = data[3] as object[];
const document = new Document();
- document.addParagraph(
+ document.add(
new Paragraph({
text: "Dolan Miu",
heading: HeadingLevel.TITLE,
}),
);
- document.addParagraph(this.createContactInfo(PHONE_NUMBER, PROFILE_URL, EMAIL));
- document.addParagraph(this.createHeading("Education"));
+ document.add(this.createContactInfo(PHONE_NUMBER, PROFILE_URL, EMAIL));
+ document.add(this.createHeading("Education"));
for (const education of educations) {
- document.addParagraph(
+ document.add(
this.createInstitutionHeader(education.schoolName, `${education.startDate.year} - ${education.endDate.year}`),
);
- document.addParagraph(this.createRoleText(`${education.fieldOfStudy} - ${education.degree}`));
+ document.add(this.createRoleText(`${education.fieldOfStudy} - ${education.degree}`));
const bulletPoints = this.splitParagraphIntoBullets(education.notes);
bulletPoints.forEach((bulletPoint) => {
- document.addParagraph(this.createBullet(bulletPoint));
+ document.add(this.createBullet(bulletPoint));
});
}
- document.addParagraph(this.createHeading("Experience"));
+ document.add(this.createHeading("Experience"));
for (const position of experiences) {
- document.addParagraph(
+ document.add(
this.createInstitutionHeader(
position.company.name,
this.createPositionDateText(position.startDate, position.endDate, position.isCurrent),
),
);
- document.addParagraph(this.createRoleText(position.title));
+ document.add(this.createRoleText(position.title));
const bulletPoints = this.splitParagraphIntoBullets(position.summary);
bulletPoints.forEach((bulletPoint) => {
- document.addParagraph(this.createBullet(bulletPoint));
+ document.add(this.createBullet(bulletPoint));
});
}
- document.addParagraph(this.createHeading("Skills, Achievements and Interests"));
+ document.add(this.createHeading("Skills, Achievements and Interests"));
- document.addParagraph(this.createSubHeading("Skills"));
- document.addParagraph(this.createSkillList(skills));
+ document.add(this.createSubHeading("Skills"));
+ document.add(this.createSkillList(skills));
- document.addParagraph(this.createSubHeading("Achievements"));
+ document.add(this.createSubHeading("Achievements"));
for (const achievementParagraph of this.createAchivementsList(achivements)) {
- document.addParagraph(achievementParagraph);
+ document.add(achievementParagraph);
}
- document.addParagraph(this.createSubHeading("Interests"));
+ document.add(this.createSubHeading("Interests"));
- document.addParagraph(this.createInterests("Programming, Technology, Music Production, Web Design, 3D Modelling, Dancing."));
+ document.add(this.createInterests("Programming, Technology, Music Production, Web Design, 3D Modelling, Dancing."));
- document.addParagraph(this.createHeading("References"));
+ document.add(this.createHeading("References"));
- document.addParagraph(
+ document.add(
new Paragraph(
"Dr. Dean Mohamedally Director of Postgraduate Studies Department of Computer Science, University College London Malet Place, Bloomsbury, London WC1E d.mohamedally@ucl.ac.uk",
),
);
- document.addParagraph(new Paragraph("More references upon request"));
- document.addParagraph(
+ document.add(new Paragraph("More references upon request"));
+ document.add(
new Paragraph({
text: "This CV was generated in real-time based on my Linked-In profile from my personal website www.dolan.bio.",
alignment: AlignmentType.CENTER,
diff --git a/demo/demo11.ts b/demo/demo11.ts
index 40c7fe5380..3861447df9 100644
--- a/demo/demo11.ts
+++ b/demo/demo11.ts
@@ -84,7 +84,7 @@ doc.Styles.createParagraphStyle("ListParagraph", "List Paragraph")
.basedOn("Normal");
doc.createImage(fs.readFileSync("./demo/images/pizza.gif"));
-doc.addParagraph(
+doc.add(
new Paragraph({
text: "HEADING",
heading: HeadingLevel.HEADING_1,
@@ -92,7 +92,7 @@ doc.addParagraph(
}),
);
-doc.Footer.addParagraph(
+doc.Footer.add(
new Paragraph({
text: "1",
style: "normalPara",
@@ -100,54 +100,54 @@ doc.Footer.addParagraph(
}),
);
-doc.addParagraph(
+doc.add(
new Paragraph({
text: "Ref. :",
style: "normalPara",
}),
);
-doc.addParagraph(
+doc.add(
new Paragraph({
text: "Date :",
style: "normalPara",
}),
);
-doc.addParagraph(
+doc.add(
new Paragraph({
text: "To,",
style: "normalPara",
}),
);
-doc.addParagraph(
+doc.add(
new Paragraph({
text: "The Superindenting Engineer,(O &M)",
style: "normalPara",
}),
);
-doc.addParagraph(
+doc.add(
new Paragraph({
text: "Sub : ",
style: "normalPara",
}),
);
-doc.addParagraph(
+doc.add(
new Paragraph({
text: "Ref. : ",
style: "normalPara",
}),
);
-doc.addParagraph(
+doc.add(
new Paragraph({
text: "Sir,",
style: "normalPara",
}),
);
-doc.addParagraph(
+doc.add(
new Paragraph({
text: "BRIEF DESCRIPTION",
style: "normalPara",
@@ -161,9 +161,9 @@ const table = new Table({
table
.getRow(0)
.getCell(0)
- .addParagraph(new Paragraph("Pole No."));
+ .add(new Paragraph("Pole No."));
-doc.addTable(table);
+doc.add(table);
const arrboth = [
{
@@ -178,7 +178,7 @@ const arrboth = [
arrboth.forEach((item) => {
doc.createImage(fs.readFileSync(item.image));
- doc.addParagraph(
+ doc.add(
new Paragraph({
text: item.comment,
style: "normalPara2",
diff --git a/demo/demo12.ts b/demo/demo12.ts
index a3479c3cbf..f27aee4968 100644
--- a/demo/demo12.ts
+++ b/demo/demo12.ts
@@ -6,7 +6,7 @@ import { Document, Packer, Paragraph } from "../build";
const doc = new Document();
const paragraph = new Paragraph("Hello World");
-doc.addParagraph(paragraph);
+doc.add(paragraph);
const image = doc.createImage(fs.readFileSync("./demo/images/pizza.gif"));
const image2 = doc.createImage(fs.readFileSync("./demo/images/pizza.gif"));
diff --git a/demo/demo13.ts b/demo/demo13.ts
index cd0111deb4..53287c2e1a 100644
--- a/demo/demo13.ts
+++ b/demo/demo13.ts
@@ -9,7 +9,7 @@ const doc = new Document({
externalStyles: styles,
});
-doc.addParagraph(new Paragraph({
+doc.add(new Paragraph({
text: "Cool Heading Text",
heading: HeadingLevel.HEADING_1,
}));
@@ -18,16 +18,16 @@ const paragraph = new Paragraph({
text: 'This is a custom named style from the template "MyFancyStyle"',
style: "MyFancyStyle",
});
-doc.addParagraph(paragraph);
+doc.add(paragraph);
-doc.addParagraph(new Paragraph("Some normal text"));
+doc.add(new Paragraph("Some normal text"));
-doc.addParagraph(new Paragraph({
+doc.add(new Paragraph({
text: "MyFancyStyle again",
style: "MyFancyStyle",
}));
-doc.addParagraph(paragraph);
+doc.add(paragraph);
const packer = new Packer();
diff --git a/demo/demo14.ts b/demo/demo14.ts
index ca3e56ac78..310f854301 100644
--- a/demo/demo14.ts
+++ b/demo/demo14.ts
@@ -5,12 +5,12 @@ import { AlignmentType, Document, Packer, Paragraph, TextRun } from "../build";
const doc = new Document();
-doc.addParagraph(
+doc.add(
new Paragraph({
text: "First Page",
}).pageBreak(),
);
-doc.addParagraph(new Paragraph("Second Page"));
+doc.add(new Paragraph("Second Page"));
const pageNumber = new TextRun("Page ").pageNumber();
@@ -21,7 +21,7 @@ const pageoneheader = new Paragraph({
pageoneheader.addRun(pageNumber);
const firstPageHeader = doc.createFirstPageHeader();
-firstPageHeader.addParagraph(pageoneheader);
+firstPageHeader.add(pageoneheader);
const pagetwoheader = new Paragraph({
text: "My Title ",
@@ -29,7 +29,7 @@ const pagetwoheader = new Paragraph({
});
pagetwoheader.addRun(pageNumber);
-doc.Header.addParagraph(pagetwoheader);
+doc.Header.add(pagetwoheader);
const packer = new Packer();
diff --git a/demo/demo15.ts b/demo/demo15.ts
index 966d2b9e19..f25639bf2f 100644
--- a/demo/demo15.ts
+++ b/demo/demo15.ts
@@ -11,8 +11,8 @@ const paragraph2 = new Paragraph({
pageBreakBefore: true,
});
-doc.addParagraph(paragraph);
-doc.addParagraph(paragraph2);
+doc.add(paragraph);
+doc.add(paragraph2);
const packer = new Packer();
diff --git a/demo/demo16.ts b/demo/demo16.ts
index 161334c626..cd1507d747 100644
--- a/demo/demo16.ts
+++ b/demo/demo16.ts
@@ -7,12 +7,12 @@ const doc = new Document();
const paragraph = new Paragraph("Hello World").pageBreak();
-doc.addParagraph(paragraph);
+doc.add(paragraph);
const header = doc.createHeader();
-header.addParagraph(new Paragraph("Header on another page"));
+header.add(new Paragraph("Header on another page"));
const footer = doc.createFooter();
-footer.addParagraph(new Paragraph("Footer on another page"));
+footer.add(new Paragraph("Footer on another page"));
doc.addSection({
headers: {
@@ -25,7 +25,7 @@ doc.addSection({
pageNumberFormatType: PageNumberFormat.DECIMAL,
});
-doc.addParagraph(new Paragraph("hello"));
+doc.add(new Paragraph("hello"));
doc.addSection({
headers: {
@@ -39,11 +39,11 @@ doc.addSection({
orientation: PageOrientation.LANDSCAPE,
});
-doc.addParagraph(new Paragraph("hello in landscape"));
+doc.add(new Paragraph("hello in landscape"));
const header2 = doc.createHeader();
const pageNumber = new TextRun("Page number: ").pageNumber();
-header2.addParagraph(new Paragraph({}).addRun(pageNumber));
+header2.add(new Paragraph({}).addRun(pageNumber));
doc.addSection({
headers: {
@@ -52,7 +52,7 @@ doc.addSection({
orientation: PageOrientation.PORTRAIT,
});
-doc.addParagraph(new Paragraph("Page number in the header must be 2, because it continues from the previous section."));
+doc.add(new Paragraph("Page number in the header must be 2, because it continues from the previous section."));
doc.addSection({
headers: {
@@ -62,7 +62,7 @@ doc.addSection({
orientation: PageOrientation.PORTRAIT,
});
-doc.addParagraph(new Paragraph(
+doc.add(new Paragraph(
"Page number in the header must be III, because it continues from the previous section, but is defined as upper roman.",
));
@@ -75,7 +75,7 @@ doc.addSection({
orientation: PageOrientation.PORTRAIT,
});
-doc.addParagraph(new Paragraph("Page number in the header must be 25, because it is defined to start at 25 and to be decimal in this section."));
+doc.add(new Paragraph("Page number in the header must be 25, because it is defined to start at 25 and to be decimal in this section."));
const packer = new Packer();
diff --git a/demo/demo17.ts b/demo/demo17.ts
index c48a2e67e8..1d928b60b5 100644
--- a/demo/demo17.ts
+++ b/demo/demo17.ts
@@ -8,8 +8,8 @@ const doc = new Document();
const paragraph = new Paragraph("Hello World").referenceFootnote(1);
const paragraph2 = new Paragraph("Hello World").referenceFootnote(2);
-doc.addParagraph(paragraph);
-doc.addParagraph(paragraph2);
+doc.add(paragraph);
+doc.add(paragraph2);
doc.createFootnote(new Paragraph("Test"));
doc.createFootnote(new Paragraph("My amazing reference"));
diff --git a/demo/demo19.ts b/demo/demo19.ts
index 819de0bd74..f8930db836 100644
--- a/demo/demo19.ts
+++ b/demo/demo19.ts
@@ -17,7 +17,7 @@ const dateText = new TextRun({
paragraph.addRun(institutionText);
paragraph.addRun(dateText);
-doc.addParagraph(paragraph);
+doc.add(paragraph);
const packer = new Packer();
diff --git a/demo/demo2.ts b/demo/demo2.ts
index c15942db5b..5764f40f91 100644
--- a/demo/demo2.ts
+++ b/demo/demo2.ts
@@ -46,14 +46,14 @@ doc.Styles.createParagraphStyle("ListParagraph", "List Paragraph")
const numberedAbstract = doc.Numbering.createAbstractNumbering();
numberedAbstract.createLevel(0, "lowerLetter", "%1)", "left");
-doc.addParagraph(
+doc.add(
new Paragraph({
text: "Test heading1, bold and italicized",
heading: HeadingLevel.HEADING_1,
}),
);
-doc.addParagraph(new Paragraph("Some simple content"));
-doc.addParagraph(
+doc.add(new Paragraph("Some simple content"));
+doc.add(
new Paragraph({
text: "Test heading2 with double red underline",
heading: HeadingLevel.HEADING_2,
@@ -64,7 +64,7 @@ const letterNumbering = doc.Numbering.createConcreteNumbering(numberedAbstract);
const letterNumbering5 = doc.Numbering.createConcreteNumbering(numberedAbstract);
letterNumbering5.overrideLevel(0, 5);
-doc.addParagraph(
+doc.add(
new Paragraph({
text: "Option1",
numbering: {
@@ -73,7 +73,7 @@ doc.addParagraph(
},
}),
);
-doc.addParagraph(
+doc.add(
new Paragraph({
text: "Option5 -- override 2 to 5",
numbering: {
@@ -82,7 +82,7 @@ doc.addParagraph(
},
}),
);
-doc.addParagraph(
+doc.add(
new Paragraph({
text: "Option3",
numbering: {
@@ -92,7 +92,7 @@ doc.addParagraph(
}),
);
-doc.addParagraph(
+doc.add(
new Paragraph({}).addRun(
new TextRun({
text: "Some monospaced content",
@@ -103,20 +103,20 @@ doc.addParagraph(
),
);
-doc.addParagraph(
+doc.add(
new Paragraph({
text: "An aside, in light gray italics and indented",
style: "aside",
}),
);
-doc.addParagraph(
+doc.add(
new Paragraph({
text: "This is normal, but well-spaced text",
style: "wellSpaced",
}),
);
const para = new Paragraph({});
-doc.addParagraph(para);
+doc.add(para);
// Showing the different ways to create a TextRun
para.addRun(
new TextRun({
diff --git a/demo/demo20.ts b/demo/demo20.ts
index 8038944ed0..b861a10cfa 100644
--- a/demo/demo20.ts
+++ b/demo/demo20.ts
@@ -10,10 +10,10 @@ const table = new Table({
columns: 4,
});
-doc.addTable(table);
+doc.add(table);
table
.getCell(2, 2)
- .addParagraph(new Paragraph("Hello"))
+ .add(new Paragraph("Hello"))
.Borders.addTopBorder(BorderStyle.DASH_DOT_STROKED, 3, "red")
.addBottomBorder(BorderStyle.DOUBLE, 3, "blue")
.addStartBorder(BorderStyle.DOT_DOT_DASH, 3, "green")
diff --git a/demo/demo21.ts b/demo/demo21.ts
index 8e2136c813..5ce3bc2930 100644
--- a/demo/demo21.ts
+++ b/demo/demo21.ts
@@ -17,20 +17,20 @@ const anchorId = "anchorID";
// First create the bookmark
const bookmark = doc.createBookmark(anchorId, "Lorem Ipsum");
// That has header styling
-doc.addParagraph(
+doc.add(
new Paragraph({
heading: HeadingLevel.HEADING_1,
}).addBookmark(bookmark),
);
-doc.addParagraph(new Paragraph("\n"));
+doc.add(new Paragraph("\n"));
-doc.addParagraph(new Paragraph(loremIpsum));
-doc.addParagraph(new Paragraph({}).pageBreak());
+doc.add(new Paragraph(loremIpsum));
+doc.add(new Paragraph({}).pageBreak());
// Now the link back up to the bookmark
const hyperlink = doc.createInternalHyperLink(anchorId, `Click me!`);
-doc.addParagraph(new Paragraph({}).addHyperLink(hyperlink));
+doc.add(new Paragraph({}).addHyperLink(hyperlink));
const packer = new Packer();
diff --git a/demo/demo22.ts b/demo/demo22.ts
index c13d867f5d..c92406071e 100644
--- a/demo/demo22.ts
+++ b/demo/demo22.ts
@@ -13,7 +13,7 @@ const textRun1 = new TextRun({
rightToLeft: true,
});
paragraph1.addRun(textRun1);
-doc.addParagraph(paragraph1);
+doc.add(paragraph1);
const paragraph2 = new Paragraph({
bidirectional: true,
@@ -24,7 +24,7 @@ const textRun2 = new TextRun({
rightToLeft: true,
});
paragraph2.addRun(textRun2);
-doc.addParagraph(paragraph2);
+doc.add(paragraph2);
const paragraph3 = new Paragraph({
bidirectional: true,
@@ -35,7 +35,7 @@ const textRun3 = new TextRun({
rightToLeft: true,
});
paragraph3.addRun(textRun3);
-doc.addParagraph(paragraph3);
+doc.add(paragraph3);
const packer = new Packer();
diff --git a/demo/demo23.ts b/demo/demo23.ts
index 2e230e0cb7..8cbdac292c 100644
--- a/demo/demo23.ts
+++ b/demo/demo23.ts
@@ -6,7 +6,7 @@ import { Document, Media, Packer, Paragraph } from "../build";
const doc = new Document();
const paragraph = new Paragraph("Hello World");
-doc.addParagraph(paragraph);
+doc.add(paragraph);
const image = Media.addImage(doc, fs.readFileSync("./demo/images/image1.jpeg"));
const image2 = Media.addImage(doc, fs.readFileSync("./demo/images/dog.png"));
@@ -20,12 +20,12 @@ const image6 = Media.addImage(doc, Buffer.from(imageBase64Data, "base64"), 100,
// I am adding an image to the paragraph rather than the document to make the image inline
paragraph.addImage(image5);
-doc.addImage(image);
-doc.addImage(image2);
-doc.addImage(image3);
-doc.addImage(image4);
-doc.addImage(image5);
-doc.addImage(image6);
+doc.add(image);
+doc.add(image2);
+doc.add(image3);
+doc.add(image4);
+doc.add(image5);
+doc.add(image6);
const packer = new Packer();
diff --git a/demo/demo24.ts b/demo/demo24.ts
index 7a50a911b4..fc940eed1d 100644
--- a/demo/demo24.ts
+++ b/demo/demo24.ts
@@ -10,12 +10,12 @@ const table = new Table({
columns: 4,
});
-doc.addTable(table);
+doc.add(table);
-table.getCell(2, 2).addParagraph(new Paragraph("Hello"));
+table.getCell(2, 2).add(new Paragraph("Hello"));
const image = Media.addImage(doc, fs.readFileSync("./demo/images/image1.jpeg"));
-table.getCell(1, 1).addParagraph(new Paragraph(image));
+table.getCell(1, 1).add(new Paragraph(image));
const packer = new Packer();
diff --git a/demo/demo26.ts b/demo/demo26.ts
index 613d624091..ef914e9465 100644
--- a/demo/demo26.ts
+++ b/demo/demo26.ts
@@ -7,7 +7,7 @@ const doc = new Document();
const paragraph = new Paragraph("No border!");
-doc.addParagraph(paragraph);
+doc.add(paragraph);
const borderParagraph = new Paragraph({
text: "I have borders on my top and bottom sides!",
@@ -27,7 +27,7 @@ const borderParagraph = new Paragraph({
},
});
-doc.addParagraph(borderParagraph);
+doc.add(borderParagraph);
const packer = new Packer();
diff --git a/demo/demo27.ts b/demo/demo27.ts
index 09651dee9e..28d2ba5d09 100644
--- a/demo/demo27.ts
+++ b/demo/demo27.ts
@@ -27,13 +27,13 @@ myStyles
.underline("double", "FF0000")
.spacing({ before: 240, after: 120 }); // TWIP for both
-doc.addParagraph(
+doc.add(
new Paragraph({
text: "Hello",
style: "myWonkyStyle",
}),
);
-doc.addParagraph(
+doc.add(
new Paragraph({
text: "World",
heading: HeadingLevel.HEADING_2,
diff --git a/demo/demo28.ts b/demo/demo28.ts
index 20e4a50026..0bef4470bc 100644
--- a/demo/demo28.ts
+++ b/demo/demo28.ts
@@ -26,26 +26,26 @@ const toc = new TableOfContents("Summary", {
doc.addTableOfContents(toc);
-doc.addParagraph(new Paragraph({
+doc.add(new Paragraph({
text: "Header #1",
heading: HeadingLevel.HEADING_1,
pageBreakBefore: true,
}));
-doc.addParagraph(new Paragraph("I'm a little text very nicely written.'"));
+doc.add(new Paragraph("I'm a little text very nicely written.'"));
-doc.addParagraph(new Paragraph({
+doc.add(new Paragraph({
text: "Header #2",
heading: HeadingLevel.HEADING_1,
pageBreakBefore: true,
}));
-doc.addParagraph(new Paragraph("I'm a other text very nicely written.'"));
-doc.addParagraph(new Paragraph({
+doc.add(new Paragraph("I'm a other text very nicely written.'"));
+doc.add(new Paragraph({
text: "Header #2.1",
heading: HeadingLevel.HEADING_2,
}));
-doc.addParagraph(new Paragraph("I'm a another text very nicely written.'"));
+doc.add(new Paragraph("I'm a another text very nicely written.'"));
-doc.addParagraph(new Paragraph({
+doc.add(new Paragraph({
text: "My Spectacular Style #1",
style: "MySpectacularStyle",
pageBreakBefore: true,
diff --git a/demo/demo29.ts b/demo/demo29.ts
index bbf6b8d125..f8982e425d 100644
--- a/demo/demo29.ts
+++ b/demo/demo29.ts
@@ -8,7 +8,7 @@ const doc = new Document();
const numbering = new Numbering();
const abstractNum = numbering.createAbstractNumbering();
-abstractNum.createLevel(0, "upperRoman", "%1", "start").addParagraphProperty(new Indent({ left: 720, hanging: 260 }));
+abstractNum.createLevel(0, "upperRoman", "%1", "start").addProperty(new Indent({ left: 720, hanging: 260 }));
const concrete = numbering.createConcreteNumbering(abstractNum);
@@ -57,10 +57,10 @@ const item4 = new Paragraph({
},
});
-doc.addParagraph(item1);
-doc.addParagraph(item2);
-doc.addParagraph(item3);
-doc.addParagraph(item4);
+doc.add(item1);
+doc.add(item2);
+doc.add(item3);
+doc.add(item4);
const packer = new Packer();
diff --git a/demo/demo3.ts b/demo/demo3.ts
index e526b8e523..e901049ec9 100644
--- a/demo/demo3.ts
+++ b/demo/demo3.ts
@@ -8,9 +8,9 @@ const doc = new Document();
const numbering = new Numbering();
const abstractNum = numbering.createAbstractNumbering();
-abstractNum.createLevel(0, "upperRoman", "%1", "start").addParagraphProperty(new Indent({ left: 720, hanging: 260 }));
-abstractNum.createLevel(1, "decimal", "%2.", "start").addParagraphProperty(new Indent({ left: 1440, hanging: 980 }));
-abstractNum.createLevel(2, "lowerLetter", "%3)", "start").addParagraphProperty(new Indent({ left: 14402160, hanging: 1700 }));
+abstractNum.createLevel(0, "upperRoman", "%1", "start").addProperty(new Indent({ left: 720, hanging: 260 }));
+abstractNum.createLevel(1, "decimal", "%2.", "start").addProperty(new Indent({ left: 1440, hanging: 980 }));
+abstractNum.createLevel(2, "lowerLetter", "%3)", "start").addProperty(new Indent({ left: 14402160, hanging: 1700 }));
const concrete = numbering.createConcreteNumbering(abstractNum);
@@ -43,10 +43,10 @@ const subSubP = new Paragraph({
},
});
-doc.addParagraph(topLevelP);
-doc.addParagraph(subP);
-doc.addParagraph(secondSubP);
-doc.addParagraph(subSubP);
+doc.add(topLevelP);
+doc.add(subP);
+doc.add(secondSubP);
+doc.add(subSubP);
const bullet1 = new Paragraph({
text: "Hey you",
@@ -73,10 +73,10 @@ const bullet4 = new Paragraph({
},
});
-doc.addParagraph(bullet1);
-doc.addParagraph(bullet2);
-doc.addParagraph(bullet3);
-doc.addParagraph(bullet4);
+doc.add(bullet1);
+doc.add(bullet2);
+doc.add(bullet3);
+doc.add(bullet4);
const packer = new Packer();
diff --git a/demo/demo30.ts b/demo/demo30.ts
index ad7867a9c0..92b929bd30 100644
--- a/demo/demo30.ts
+++ b/demo/demo30.ts
@@ -21,7 +21,7 @@ fs.readFile(filePath, (err, data) => {
template: templateDocument,
});
const paragraph = new Paragraph("Hello World");
- doc.addParagraph(paragraph);
+ doc.add(paragraph);
const packer = new Packer();
packer.toBuffer(doc).then((buffer) => {
diff --git a/demo/demo31.ts b/demo/demo31.ts
index 15f6de5a64..32c8cd755a 100644
--- a/demo/demo31.ts
+++ b/demo/demo31.ts
@@ -10,14 +10,14 @@ const table = new Table({
columns: 2,
});
-doc.addTable(table);
+doc.add(table);
table
.getCell(1, 1)
- .addParagraph(new Paragraph("This text should be in the middle of the cell"))
+ .add(new Paragraph("This text should be in the middle of the cell"))
.setVerticalAlign(VerticalAlign.CENTER);
-table.getCell(1, 0).addParagraph(
+table.getCell(1, 0).add(
new Paragraph({
text:
"Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah",
diff --git a/demo/demo32.ts b/demo/demo32.ts
index 2591a72174..c2fd76ebf6 100644
--- a/demo/demo32.ts
+++ b/demo/demo32.ts
@@ -10,12 +10,12 @@ let table = new Table({
columns: 2,
});
-doc.addTable(table);
+doc.add(table);
-table.getCell(0, 0).addParagraph(new Paragraph("Hello"));
+table.getCell(0, 0).add(new Paragraph("Hello"));
table.getRow(0).mergeCells(0, 1);
-doc.addParagraph(
+doc.add(
new Paragraph({
text: "Another table",
heading: HeadingLevel.HEADING_2,
@@ -30,11 +30,11 @@ table = new Table({
columnWidths: [1000, 1000, 1000],
});
-doc.addTable(table);
+doc.add(table);
table
.getCell(0, 0)
- .addParagraph(new Paragraph("World"))
+ .add(new Paragraph("World"))
.setMargins({
top: 1000,
bottom: 1000,
@@ -43,7 +43,7 @@ table
});
table.getRow(0).mergeCells(0, 2);
-doc.addParagraph(
+doc.add(
new Paragraph({
text: "Another table",
heading: HeadingLevel.HEADING_2,
@@ -63,14 +63,14 @@ table = new Table({
},
});
-doc.addTable(table);
+doc.add(table);
-table.getCell(0, 0).addParagraph(new Paragraph("Foo"));
-table.getCell(0, 1).addParagraph(new Paragraph("v"));
+table.getCell(0, 0).add(new Paragraph("Foo"));
+table.getCell(0, 1).add(new Paragraph("v"));
table
.getCell(1, 0)
- .addParagraph(new Paragraph("Bar1"))
+ .add(new Paragraph("Bar1"))
.setShading({
fill: "b79c2f",
val: ShadingType.REVERSE_DIAGONAL_STRIPE,
@@ -78,7 +78,7 @@ table
});
table
.getCell(1, 1)
- .addParagraph(new Paragraph("Bar2"))
+ .add(new Paragraph("Bar2"))
.setShading({
fill: "42c5f4",
val: ShadingType.PERCENT_95,
@@ -86,7 +86,7 @@ table
});
table
.getCell(1, 2)
- .addParagraph(new Paragraph("Bar3"))
+ .add(new Paragraph("Bar3"))
.setShading({
fill: "880aa8",
val: ShadingType.PERCENT_10,
@@ -94,7 +94,7 @@ table
});
table
.getCell(1, 3)
- .addParagraph(new Paragraph("Bar4"))
+ .add(new Paragraph("Bar4"))
.setShading({
fill: "FF0000",
val: ShadingType.CLEAR,
@@ -103,7 +103,7 @@ table
table.getRow(0).mergeCells(0, 3);
-doc.addParagraph(new Paragraph("hi"));
+doc.add(new Paragraph("hi"));
table = new Table({
rows: 2,
@@ -112,7 +112,7 @@ table = new Table({
widthUnitType: WidthType.PERCENTAGE,
});
-doc.addTable(table);
+doc.add(table);
const packer = new Packer();
diff --git a/demo/demo33.ts b/demo/demo33.ts
index c6efe2ed0f..b4831d849b 100644
--- a/demo/demo33.ts
+++ b/demo/demo33.ts
@@ -10,10 +10,10 @@ const paragraph2 = new Paragraph("Hello World 1->").addSequentialIdentifier("Lab
const paragraph3 = new Paragraph("Hello World 1->").addSequentialIdentifier("Another").addRun(new TextRun(" text after sequencial caption 3->")).addSequentialIdentifier("Label");
const paragraph4 = new Paragraph("Hello World 2->").addSequentialIdentifier("Another").addRun(new TextRun(" text after sequencial caption 4->")).addSequentialIdentifier("Label");
-doc.addParagraph(paragraph);
-doc.addParagraph(paragraph2);
-doc.addParagraph(paragraph3);
-doc.addParagraph(paragraph4);
+doc.add(paragraph);
+doc.add(paragraph2);
+doc.add(paragraph3);
+doc.add(paragraph4);
const packer = new Packer();
diff --git a/demo/demo34.ts b/demo/demo34.ts
index 365fc00845..007be8efdb 100644
--- a/demo/demo34.ts
+++ b/demo/demo34.ts
@@ -31,7 +31,7 @@ const table = new Table({
doc.add(table);
-table.getCell(0, 0).addParagraph(new Paragraph("Hello"));
+table.getCell(0, 0).add(new Paragraph("Hello"));
table.getRow(0).mergeCells(0, 1);
const packer = new Packer();
diff --git a/demo/demo35.ts b/demo/demo35.ts
index 04573edc1e..a2927a6957 100644
--- a/demo/demo35.ts
+++ b/demo/demo35.ts
@@ -8,7 +8,7 @@ const paragraph = new Paragraph({});
const link = doc.createHyperlink("http://www.example.com", "Hyperlink");
paragraph.addHyperLink(link);
-doc.addParagraph(paragraph);
+doc.add(paragraph);
const packer = new Packer();
diff --git a/demo/demo36.ts b/demo/demo36.ts
index 655410b56e..1faf0c3e94 100644
--- a/demo/demo36.ts
+++ b/demo/demo36.ts
@@ -10,12 +10,12 @@ const table = new Table({
rows: 2,
columns: 2,
});
-table.getCell(1, 1).addParagraph(new Paragraph(image));
+table.getCell(1, 1).add(new Paragraph(image));
-doc.addTable(table);
+doc.add(table);
// doc.Header.createImage(fs.readFileSync("./demo/images/pizza.gif"));
-doc.Header.addTable(table);
+doc.Header.add(table);
// doc.Footer.createImage(fs.readFileSync("./demo/images/pizza.gif"));
const packer = new Packer();
diff --git a/demo/demo37.ts b/demo/demo37.ts
index 8b9e04a12e..6f599cd15a 100644
--- a/demo/demo37.ts
+++ b/demo/demo37.ts
@@ -5,7 +5,7 @@ import { Document, Media, Packer, Paragraph } from "../build";
const doc = new Document();
const image = Media.addImage(doc, fs.readFileSync("./demo/images/image1.jpeg"));
-doc.addParagraph(new Paragraph("Hello World"));
+doc.add(new Paragraph("Hello World"));
doc.Header.addImage(image);
doc.Header.createImage(fs.readFileSync("./demo/images/pizza.gif"));
diff --git a/demo/demo38.ts b/demo/demo38.ts
index dfc9a50091..eca2c82ef4 100644
--- a/demo/demo38.ts
+++ b/demo/demo38.ts
@@ -6,15 +6,15 @@ import { Document, Packer, Paragraph, TextWrappingSide, TextWrappingType } from
const doc = new Document();
-doc.addParagraph(new Paragraph(
+doc.add(new Paragraph(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque vehicula nec nulla vitae efficitur. Ut interdum mauris eu ipsum rhoncus, nec pharetra velit placerat. Sed vehicula libero ac urna molestie, id pharetra est pellentesque. Praesent iaculis vehicula fringilla. Duis pretium gravida orci eu vestibulum. Mauris tincidunt ipsum dolor, ut ornare dolor pellentesque id. Integer in nulla gravida, lacinia ante non, commodo ex. Vivamus vulputate nisl id lectus finibus vulputate. Ut et nisl mi. Cras fermentum augue arcu, ac accumsan elit euismod id. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed ac posuere nisi. Pellentesque tincidunt vehicula bibendum. Phasellus eleifend viverra nisl.",
));
-doc.addParagraph(new Paragraph(
+doc.add(new Paragraph(
"Proin ac purus faucibus, porttitor magna ut, cursus nisl. Vivamus ante purus, porta accumsan nibh eget, eleifend dignissim odio. Integer sed dictum est, aliquam lacinia justo. Donec ultrices auctor venenatis. Etiam interdum et elit nec elementum. Pellentesque nec viverra mauris. Etiam suscipit leo nec velit fringilla mattis. Pellentesque justo lacus, sodales eu condimentum in, dapibus finibus lacus. Morbi vitae nibh sit amet sem molestie feugiat. In non porttitor enim.",
));
-doc.addParagraph(new Paragraph(
+doc.add(new Paragraph(
"Ut eget diam cursus quam accumsan interdum at id ante. Ut mollis mollis arcu, eu scelerisque dui tempus in. Quisque aliquam, augue quis ornare aliquam, ex purus ultrices mauris, ut porta dolor dolor nec justo. Nunc a tempus odio, eu viverra arcu. Suspendisse vitae nibh nec mi pharetra tempus. Mauris ut ullamcorper sapien, et sagittis sapien. Vestibulum in urna metus. In scelerisque, massa id bibendum tempus, quam orci rutrum turpis, a feugiat nisi ligula id metus. Praesent id dictum purus. Proin interdum ipsum nulla.",
));
diff --git a/demo/demo39.ts b/demo/demo39.ts
index 1768ce3074..0c4cf86ca8 100644
--- a/demo/demo39.ts
+++ b/demo/demo39.ts
@@ -11,11 +11,11 @@ const doc = new Document(
},
);
-doc.Header.addParagraph(
+doc.Header.add(
new Paragraph("Foo Bar corp. ").addRun(new TextRun("Page Number ").pageNumber()).addRun(new TextRun(" to ").numberOfTotalPages()),
);
-doc.Footer.addParagraph(
+doc.Footer.add(
new Paragraph({
text: "Foo Bar corp. ",
alignment: AlignmentType.CENTER,
@@ -24,11 +24,11 @@ doc.Footer.addParagraph(
.addRun(new TextRun(" to ").numberOfTotalPages()),
);
-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());
+doc.add(new Paragraph("Hello World 1").pageBreak());
+doc.add(new Paragraph("Hello World 2").pageBreak());
+doc.add(new Paragraph("Hello World 3").pageBreak());
+doc.add(new Paragraph("Hello World 4").pageBreak());
+doc.add(new Paragraph("Hello World 5").pageBreak());
const packer = new Packer();
diff --git a/demo/demo4.ts b/demo/demo4.ts
index 19242b1a71..5e528ac2db 100644
--- a/demo/demo4.ts
+++ b/demo/demo4.ts
@@ -10,9 +10,9 @@ const table = new Table({
columns: 4,
});
-doc.addTable(table);
+doc.add(table);
-table.getCell(2, 2).addParagraph(new Paragraph("Hello"));
+table.getCell(2, 2).add(new Paragraph("Hello"));
const packer = new Packer();
diff --git a/demo/demo40.ts b/demo/demo40.ts
index ed0e0fe278..6db6e7ba1e 100644
--- a/demo/demo40.ts
+++ b/demo/demo40.ts
@@ -11,18 +11,18 @@ const doc = new Document(
},
);
-doc.addParagraph(
+doc.add(
new Paragraph({
text: "Hello",
heading: HeadingLevel.HEADING_1,
}),
);
-doc.addParagraph(
+doc.add(
new Paragraph(
"Himenaeos duis luctus nullam fermentum lobortis potenti vivamus non dis, sed facilisis ultricies scelerisque aenean risus hac senectus. Adipiscing id venenatis justo ante gravida placerat, ac curabitur dis pellentesque proin bibendum risus, aliquam porta taciti vulputate primis. Tortor ipsum fermentum quam vel convallis primis nisl praesent tincidunt, lobortis quisque felis vitae condimentum class ut sem nam, aenean potenti pretium ac amet lacinia himenaeos mi. Aliquam nisl turpis hendrerit est morbi malesuada, augue interdum mus inceptos curabitur tristique, parturient feugiat sodales nulla facilisi. Aliquam non pulvinar purus nulla ex integer, velit faucibus vitae at bibendum quam, risus elit aenean adipiscing posuere.",
),
);
-doc.addParagraph(
+doc.add(
new Paragraph(
"Sed laoreet id mattis egestas nam mollis elit lacinia convallis dui tincidunt ultricies habitant, pharetra per maximus interdum neque tempor risus efficitur morbi imperdiet senectus. Lectus laoreet senectus finibus inceptos donec potenti fermentum, ultrices eleifend odio suscipit magnis tellus maximus nibh, ac sit nullam eget felis himenaeos. Diam class sem magnis aenean commodo faucibus id proin mi, nullam sodales nec mus parturient ornare ad inceptos velit hendrerit, bibendum placerat eleifend integer facilisis urna dictumst suspendisse.",
),
diff --git a/demo/demo41.ts b/demo/demo41.ts
index 2d3192bdf2..977d99abb5 100644
--- a/demo/demo41.ts
+++ b/demo/demo41.ts
@@ -10,41 +10,41 @@ const table = new Table({
columns: 6,
});
-doc.addTable(table);
+doc.add(table);
let row = 0;
-table.getCell(row, 0).addParagraph(new Paragraph("0,0"));
-table.getCell(row, 1).addParagraph(new Paragraph("0,1"));
-table.getCell(row, 3).addParagraph(new Paragraph("0,3"));
-table.getCell(row, 4).addParagraph(new Paragraph("0,4"));
+table.getCell(row, 0).add(new Paragraph("0,0"));
+table.getCell(row, 1).add(new Paragraph("0,1"));
+table.getCell(row, 3).add(new Paragraph("0,3"));
+table.getCell(row, 4).add(new Paragraph("0,4"));
table.getRow(row).mergeCells(4, 5);
table.getRow(row).mergeCells(1, 2);
row = 1;
-table.getCell(row, 0).addParagraph(new Paragraph("1,0"));
-table.getCell(row, 2).addParagraph(new Paragraph("1,2"));
-table.getCell(row, 4).addParagraph(new Paragraph("1,4"));
+table.getCell(row, 0).add(new Paragraph("1,0"));
+table.getCell(row, 2).add(new Paragraph("1,2"));
+table.getCell(row, 4).add(new Paragraph("1,4"));
table.getRow(row).mergeCells(4, 5);
table.getRow(row).mergeCells(2, 3);
table.getRow(row).mergeCells(0, 1);
row = 2;
-table.getCell(row, 0).addParagraph(new Paragraph("2,0"));
-table.getCell(row, 1).addParagraph(new Paragraph("2,1"));
-table.getCell(row, 2).addParagraph(new Paragraph("2,2"));
-table.getCell(row, 3).addParagraph(new Paragraph("2,3"));
-table.getCell(row, 4).addParagraph(new Paragraph("2,4"));
+table.getCell(row, 0).add(new Paragraph("2,0"));
+table.getCell(row, 1).add(new Paragraph("2,1"));
+table.getCell(row, 2).add(new Paragraph("2,2"));
+table.getCell(row, 3).add(new Paragraph("2,3"));
+table.getCell(row, 4).add(new Paragraph("2,4"));
table.getRow(row).mergeCells(4, 5);
table.getRow(row).mergeCells(1, 2);
row = 3;
-table.getCell(row, 0).addParagraph(new Paragraph("3,0"));
-table.getCell(row, 1).addParagraph(new Paragraph("3,1"));
-table.getCell(row, 2).addParagraph(new Paragraph("3,2"));
-table.getCell(row, 3).addParagraph(new Paragraph("3,3"));
-table.getCell(row, 4).addParagraph(new Paragraph("3,4"));
-table.getCell(row, 5).addParagraph(new Paragraph("3,5"));
+table.getCell(row, 0).add(new Paragraph("3,0"));
+table.getCell(row, 1).add(new Paragraph("3,1"));
+table.getCell(row, 2).add(new Paragraph("3,2"));
+table.getCell(row, 3).add(new Paragraph("3,3"));
+table.getCell(row, 4).add(new Paragraph("3,4"));
+table.getCell(row, 5).add(new Paragraph("3,5"));
row = 4;
-table.getCell(row, 0).addParagraph(new Paragraph("4,0"));
-table.getCell(row, 5).addParagraph(new Paragraph("4,5"));
+table.getCell(row, 0).add(new Paragraph("4,0"));
+table.getCell(row, 5).add(new Paragraph("4,5"));
table.getRow(row).mergeCells(0, 4);
const packer = new Packer();
diff --git a/demo/demo43.ts b/demo/demo43.ts
index 65ce2d443a..451d21a0fd 100644
--- a/demo/demo43.ts
+++ b/demo/demo43.ts
@@ -10,11 +10,11 @@ const table = new Table({
columns: 4,
});
-doc.addTable(table);
+doc.add(table);
-table.getCell(2, 2).addParagraph(new Paragraph("Hello"));
+table.getCell(2, 2).add(new Paragraph("Hello"));
table.getColumn(3).mergeCells(1, 2);
-// table.getCell(3, 2).addParagraph(new Paragraph("Hello"));
+// table.getCell(3, 2).add(new Paragraph("Hello"));
const packer = new Packer();
diff --git a/demo/demo5.ts b/demo/demo5.ts
index 7163a5db60..be340a3530 100644
--- a/demo/demo5.ts
+++ b/demo/demo5.ts
@@ -7,7 +7,7 @@ import { Document, HorizontalPositionAlign, HorizontalPositionRelativeFrom, Pack
const doc = new Document();
const paragraph = new Paragraph("Hello World");
-doc.addParagraph(paragraph);
+doc.add(paragraph);
doc.createImage(fs.readFileSync("./demo/images/image1.jpeg"));
doc.createImage(fs.readFileSync("./demo/images/dog.png").toString("base64"));
diff --git a/demo/demo6.ts b/demo/demo6.ts
index 042f6d7d94..2629c1b96d 100644
--- a/demo/demo6.ts
+++ b/demo/demo6.ts
@@ -22,14 +22,14 @@ const dateText = new TextRun({
paragraph.addRun(institutionText);
paragraph.addRun(dateText);
-doc.addParagraph(paragraph);
+doc.add(paragraph);
-doc.addParagraph(new Paragraph({
+doc.add(new Paragraph({
text: "Hello World",
heading: HeadingLevel.HEADING_1,
}));
-doc.addParagraph(new Paragraph("Foo bar"));
-doc.addParagraph(new Paragraph("Github is the best"));
+doc.add(new Paragraph("Foo bar"));
+doc.add(new Paragraph("Github is the best"));
const packer = new Packer();
diff --git a/demo/demo7.ts b/demo/demo7.ts
index fe9fccf928..db528cb157 100644
--- a/demo/demo7.ts
+++ b/demo/demo7.ts
@@ -9,7 +9,7 @@ const doc = new Document(undefined, {
const paragraph = new Paragraph("Hello World");
-doc.addParagraph(paragraph);
+doc.add(paragraph);
const packer = new Packer();
diff --git a/demo/demo8.ts b/demo/demo8.ts
index 89d474568d..1e3dfbaada 100644
--- a/demo/demo8.ts
+++ b/demo/demo8.ts
@@ -5,10 +5,10 @@ import { Document, Packer, Paragraph } from "../build";
const doc = new Document();
-doc.addParagraph(new Paragraph("Hello World"));
+doc.add(new Paragraph("Hello World"));
-doc.Header.addParagraph(new Paragraph("Header text"));
-doc.Footer.addParagraph(new Paragraph("Footer text"));
+doc.Header.add(new Paragraph("Header text"));
+doc.Footer.add(new Paragraph("Footer text"));
const packer = new Packer();
diff --git a/demo/demo9.ts b/demo/demo9.ts
index 71b8b25a77..8787d43b24 100644
--- a/demo/demo9.ts
+++ b/demo/demo9.ts
@@ -5,7 +5,7 @@ import { Document, Packer, Paragraph } from "../build";
const doc = new Document();
-doc.addParagraph(new Paragraph("Hello World"));
+doc.add(new Paragraph("Hello World"));
doc.Header.createImage(fs.readFileSync("./demo/images/pizza.gif"));
doc.Footer.createImage(fs.readFileSync("./demo/images/pizza.gif"));
diff --git a/docs/README.md b/docs/README.md
index fd5ad9ecd9..caee21e8b8 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -39,7 +39,7 @@ var doc = new docx.Document();
var paragraph = new docx.Paragraph("Some cool text here.");
// Add more text into the paragraph if you wish
paragraph.addRun(new docx.TextRun("Lorem Ipsum Foo Bar"));
-doc.addParagraph(paragraph);
+doc.add(paragraph);
// Used to export the file into a .docx file
var packer = new docx.Packer();
diff --git a/docs/contribution-guidelines.md b/docs/contribution-guidelines.md
index 7f61964032..4092d246a4 100644
--- a/docs/contribution-guidelines.md
+++ b/docs/contribution-guidelines.md
@@ -92,7 +92,7 @@ This is just a guideline, and the rules can sometimes be broken.
*Note:* This may look like its breaking the previous guideline, but it has semantically different meanings. The previous one is using data to construct an object, whereas this one is simply adding elements into the document:
```js
- public addParagraph(paragraph: Paragraph) {
+ public add(paragraph: Paragraph) {
this.root.push(paragraph);
}
```
diff --git a/docs/usage/bullet-points.md b/docs/usage/bullet-points.md
index c2fb2987d0..5926e0eca7 100644
--- a/docs/usage/bullet-points.md
+++ b/docs/usage/bullet-points.md
@@ -11,8 +11,8 @@ var paragraph = new docx.Paragraph(text).bullet();
var text2 = new docx.TextRun("Are awesome");
var paragraph2 = new docx.Paragraph(text2).bullet();
-doc.addParagraph(paragraph);
-doc.addParagraph(paragraph2);
+doc.add(paragraph);
+doc.add(paragraph2);
```
### This will produce:
diff --git a/docs/usage/paragraph.md b/docs/usage/paragraph.md
index 6864bd1e73..28f815e4b2 100644
--- a/docs/usage/paragraph.md
+++ b/docs/usage/paragraph.md
@@ -23,7 +23,7 @@ var paragraph = new docx.Paragraph("Short hand notation for adding text.");
After you create the paragraph, you must add the paragraph into the `document`:
```js
-doc.addParagraph(paragraph);
+doc.add(paragraph);
```
## Styles
diff --git a/docs/usage/styling-with-xml.md b/docs/usage/styling-with-xml.md
index 5f138d31d6..1aad181d2d 100644
--- a/docs/usage/styling-with-xml.md
+++ b/docs/usage/styling-with-xml.md
@@ -39,7 +39,7 @@ doc.createParagraph("Cool Heading Text").heading1();
let paragraph = new docx.Paragraph('This is a custom named style from the template "Cool New Style"');
paragraph.style("Cool New Style");
-doc.addParagraph(paragraph);
+doc.add(paragraph);
doc.createParagraph("Some normal text");
```
diff --git a/docs/usage/table-of-contents.md b/docs/usage/table-of-contents.md
index c1fb439143..02ef2eff14 100644
--- a/docs/usage/table-of-contents.md
+++ b/docs/usage/table-of-contents.md
@@ -58,15 +58,15 @@ const toc = new TableOfContents("Summary", {
doc.addTableOfContents(toc);
-doc.addParagraph(new Paragraph("Header #1").heading1().pageBreakBefore());
-doc.addParagraph(new Paragraph("I'm a little text, very nicely written.'"));
+doc.add(new Paragraph("Header #1").heading1().pageBreakBefore());
+doc.add(new Paragraph("I'm a little text, very nicely written.'"));
-doc.addParagraph(new Paragraph("Header #2").heading1().pageBreakBefore());
-doc.addParagraph(new Paragraph("I'm another text very nicely written.'"));
-doc.addParagraph(new Paragraph("Header #2.1").heading2());
-doc.addParagraph(new Paragraph("I'm another text very nicely written.'"));
+doc.add(new Paragraph("Header #2").heading1().pageBreakBefore());
+doc.add(new Paragraph("I'm another text very nicely written.'"));
+doc.add(new Paragraph("Header #2.1").heading2());
+doc.add(new Paragraph("I'm another text very nicely written.'"));
-doc.addParagraph(new Paragraph("My Spectacular Style #1").style("MySpectacularStyle").pageBreakBefore());
+doc.add(new Paragraph("My Spectacular Style #1").style("MySpectacularStyle").pageBreakBefore());
```
### Complete example
diff --git a/docs/usage/tables.md b/docs/usage/tables.md
index 437d579b8f..70556ae028 100644
--- a/docs/usage/tables.md
+++ b/docs/usage/tables.md
@@ -4,10 +4,10 @@ You can create tables with `docx`. More information can be found [here](http://o
## Create Table
-To create a table, simply create one with `new Table()`, then add it to the document: `doc.addTable()`.
+To create a table, simply create one with `new Table()`, then add it to the document: `doc.add()`.
```ts
-const table = doc.addTable(new Table({
+const table = doc.add(new Table({
rows: [NUMBER OF ROWS],
columns: [NUMBER OF COLUMNS]
});
@@ -17,7 +17,7 @@ Alternatively, you can create a table object directly, and then add it in the `d
```ts
const table = new Table(4, 4);
-doc.addTable(table);
+doc.add(table);
```
The snippet below creates a table of 2 rows and 4 columns.
@@ -27,7 +27,7 @@ const table = new Table({
rows: 2,
columns: 4,
});
-doc.addTable(table);
+doc.add(table);
```
## Rows and Columns
@@ -92,10 +92,10 @@ const cell = column.getCell(2);
### Add paragraph to a cell
-Once you have got the cell, you can add data to it with the `addParagraph()` method.
+Once you have got the cell, you can add data to it with the `add()` method.
```ts
-cell.addParagraph(new Paragraph("Hello"));
+cell.add(new Paragraph("Hello"));
```
### Set width of a cell
@@ -226,7 +226,7 @@ It has not been implemented yet, but it will follow a similar structure as mergi
To have a table within a table
```ts
-cell.addTable(new Table(1, 1));
+cell.add(new Table(1, 1));
```
## Pagination
diff --git a/src/file/document/document.ts b/src/file/document/document.ts
index c517124ef3..b716c1367b 100644
--- a/src/file/document/document.ts
+++ b/src/file/document/document.ts
@@ -37,7 +37,7 @@ export class Document extends XmlComponent {
this.root.push(this.body);
}
- public addParagraph(paragraph: Paragraph): Document {
+ public add(paragraph: Paragraph | Table): Document {
this.body.push(paragraph);
return this;
}
@@ -47,11 +47,6 @@ export class Document extends XmlComponent {
return this;
}
- public addTable(table: Table): Document {
- this.body.push(table);
- return this;
- }
-
public get Body(): Body {
return this.body;
}
diff --git a/src/file/file.spec.ts b/src/file/file.spec.ts
index 6b0b7aa251..b11a5f61ec 100644
--- a/src/file/file.spec.ts
+++ b/src/file/file.spec.ts
@@ -80,20 +80,18 @@ describe("File", () => {
});
});
- describe("#addParagraph", () => {
- it("should call the underlying document's addParagraph", () => {
+ describe("#add", () => {
+ it("should call the underlying document's add a Paragraph", () => {
const file = new File();
- const spy = sinon.spy(file.Document, "addParagraph");
+ const spy = sinon.spy(file.Document, "add");
file.add(new Paragraph({}));
expect(spy.called).to.equal(true);
});
- });
- describe("#add", () => {
- it("should call the underlying document's addTable", () => {
+ it("should call the underlying document's add when adding a Table", () => {
const wrapper = new File();
- const spy = sinon.spy(wrapper.Document, "addTable");
+ const spy = sinon.spy(wrapper.Document, "add");
wrapper.add(
new Table({
rows: 1,
@@ -104,6 +102,17 @@ describe("File", () => {
expect(spy.called).to.equal(true);
});
+ it("should call the underlying document's add when adding an Image (paragraph)", () => {
+ const wrapper = new File();
+ const spy = sinon.spy(wrapper.Document, "add");
+ // tslint:disable-next-line:no-any
+ wrapper.add(new Paragraph(""));
+
+ expect(spy.called).to.equal(true);
+ });
+ });
+
+ describe("#add", () => {
it("should call the underlying document's addTableOfContents", () => {
const wrapper = new File();
const spy = sinon.spy(wrapper.Document, "addTableOfContents");
@@ -111,22 +120,13 @@ describe("File", () => {
expect(spy.called).to.equal(true);
});
-
- it("should call the underlying document's addImage", () => {
- const wrapper = new File();
- const spy = sinon.spy(wrapper.Document, "addParagraph");
- // tslint:disable-next-line:no-any
- wrapper.add(new Paragraph(""));
-
- expect(spy.called).to.equal(true);
- });
});
describe("#createImage", () => {
it("should call the underlying document's createImage", () => {
const wrapper = new File();
const spy = sinon.spy(wrapper.Media, "addMedia");
- const wrapperSpy = sinon.spy(wrapper.Document, "addParagraph");
+ const wrapperSpy = sinon.spy(wrapper.Document, "add");
wrapper.createImage("");
expect(spy.called).to.equal(true);
diff --git a/src/file/file.ts b/src/file/file.ts
index 26848c8e5b..a8fba1d512 100644
--- a/src/file/file.ts
+++ b/src/file/file.ts
@@ -114,11 +114,11 @@ export class File {
public add(item: Paragraph | Table | TableOfContents): File {
if (item instanceof Paragraph) {
- this.document.addParagraph(item);
+ this.document.add(item);
}
if (item instanceof Table) {
- this.document.addTable(item);
+ this.document.add(item);
}
if (item instanceof TableOfContents) {
@@ -136,7 +136,7 @@ export class File {
): Paragraph {
const image = Media.addImage(this, buffer, width, height, drawingOptions);
const paragraph = new Paragraph(image);
- this.document.addParagraph(paragraph);
+ this.document.add(paragraph);
return paragraph;
}
diff --git a/src/file/footnotes/footnote/footnote.ts b/src/file/footnotes/footnote/footnote.ts
index 0567695c40..60e6e533c8 100644
--- a/src/file/footnotes/footnote/footnote.ts
+++ b/src/file/footnotes/footnote/footnote.ts
@@ -20,7 +20,7 @@ export class Footnote extends XmlComponent {
);
}
- public addParagraph(paragraph: Paragraph): void {
+ public add(paragraph: Paragraph): void {
paragraph.addRunToFront(new FootnoteRefRun());
this.root.push(paragraph);
}
diff --git a/src/file/footnotes/footnotes.ts b/src/file/footnotes/footnotes.ts
index 1681928afb..2fea5fe380 100644
--- a/src/file/footnotes/footnotes.ts
+++ b/src/file/footnotes/footnotes.ts
@@ -37,7 +37,7 @@ export class FootNotes extends XmlComponent {
);
const begin = new Footnote(-1, FootnoteType.SEPERATOR);
- begin.addParagraph(
+ begin.add(
new Paragraph({
spacing: {
after: 0,
@@ -49,7 +49,7 @@ export class FootNotes extends XmlComponent {
this.root.push(begin);
const spacing = new Footnote(0, FootnoteType.CONTINUATION_SEPERATOR);
- spacing.addParagraph(
+ spacing.add(
new Paragraph({
spacing: {
after: 0,
@@ -63,7 +63,7 @@ export class FootNotes extends XmlComponent {
public createFootNote(paragraph: Paragraph): void {
const footnote = new Footnote(this.currentId);
- footnote.addParagraph(paragraph);
+ footnote.add(paragraph);
this.root.push(footnote);
this.currentId++;
diff --git a/src/file/table/table-cell/table-cell.ts b/src/file/table/table-cell/table-cell.ts
index 830797dbed..1c546ab934 100644
--- a/src/file/table/table-cell/table-cell.ts
+++ b/src/file/table/table-cell/table-cell.ts
@@ -22,13 +22,9 @@ export class TableCell extends XmlComponent {
this.root.push(this.properties);
}
- public addParagraph(content: Paragraph): TableCell {
- this.root.push(content);
- return this;
- }
+ public add(item: Paragraph | Table): TableCell {
+ this.root.push(item);
- public addTable(content: Table): TableCell {
- this.root.push(content);
return this;
}
@@ -36,7 +32,7 @@ export class TableCell extends XmlComponent {
// Cells must end with a paragraph
if (!(this.root[this.root.length - 1] instanceof Paragraph)) {
const para = new Paragraph({});
- this.addParagraph(para);
+ this.add(para);
}
return super.prepForXml();
}
diff --git a/src/file/table/table.spec.ts b/src/file/table/table.spec.ts
index 70fc2db165..7c93c5fc8e 100644
--- a/src/file/table/table.spec.ts
+++ b/src/file/table/table.spec.ts
@@ -163,19 +163,19 @@ describe("Table", () => {
table
.getRow(0)
.getCell(0)
- .addParagraph(new Paragraph("A1"));
+ .add(new Paragraph("A1"));
table
.getRow(0)
.getCell(1)
- .addParagraph(new Paragraph("B1"));
+ .add(new Paragraph("B1"));
table
.getRow(1)
.getCell(0)
- .addParagraph(new Paragraph("A2"));
+ .add(new Paragraph("A2"));
table
.getRow(1)
.getCell(1)
- .addParagraph(new Paragraph("B2"));
+ .add(new Paragraph("B2"));
const tree = new Formatter().format(table);
const cell = (c) => ({
"w:tc": [
@@ -221,10 +221,10 @@ describe("Table", () => {
rows: 2,
columns: 2,
});
- table.getCell(0, 0).addParagraph(new Paragraph("A1"));
- table.getCell(0, 1).addParagraph(new Paragraph("B1"));
- table.getCell(1, 0).addParagraph(new Paragraph("A2"));
- table.getCell(1, 1).addParagraph(new Paragraph("B2"));
+ table.getCell(0, 0).add(new Paragraph("A1"));
+ table.getCell(0, 1).add(new Paragraph("B1"));
+ table.getCell(1, 0).add(new Paragraph("A2"));
+ table.getCell(1, 1).add(new Paragraph("B2"));
const tree = new Formatter().format(table);
const cell = (c) => ({
"w:tc": [
@@ -295,7 +295,7 @@ describe("Table", () => {
rows: 1,
columns: 1,
});
- parentTable.getCell(0, 0).addTable(
+ parentTable.getCell(0, 0).add(
new Table({
rows: 1,
columns: 1,
@@ -322,7 +322,7 @@ describe("Table", () => {
rows: 1,
columns: 1,
});
- parentTable.getCell(0, 0).addParagraph(new Paragraph("Hello"));
+ parentTable.getCell(0, 0).add(new Paragraph("Hello"));
const tree = new Formatter().format(parentTable);
expect(tree)
.to.have.property("w:tbl")