Add more documentation
This commit is contained in:
@ -172,6 +172,12 @@ const paragraph = new Paragraph({
|
|||||||
|
|
||||||
**Example:**
|
**Example:**
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const paragraph = new Paragraph({
|
||||||
|
outlineLevel: 0,
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
## Styles
|
## Styles
|
||||||
|
|
||||||
To create styles, please refer to the styling Wiki: https://github.com/dolanmiu/docx/wiki/Styling
|
To create styles, please refer to the styling Wiki: https://github.com/dolanmiu/docx/wiki/Styling
|
||||||
@ -239,10 +245,15 @@ The result is:
|
|||||||
|
|
||||||
## Thematic Break
|
## Thematic Break
|
||||||
|
|
||||||
To add a break in the page, simply add `.thematicBreak()` on a paragraph:
|
To add a thematic break in the `Paragraph`:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
var paragraph = new docx.Paragraph("Amazing Heading").heading1().thematicBreak();
|
var paragraph = new docx.Paragraph("Amazing Heading");
|
||||||
|
const paragraph = new Paragraph({
|
||||||
|
text: "Amazing Heading",
|
||||||
|
heading: HeadingLevel.HEADING_1,
|
||||||
|
thematicBreak: true,
|
||||||
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
The above example will create a heading with a page break directly under it.
|
The above example will create a heading with a page break directly under it.
|
||||||
@ -251,8 +262,8 @@ The above example will create a heading with a page break directly under it.
|
|||||||
|
|
||||||
To move to a new page (insert a page break), simply add `.pageBreak()` on a paragraph:
|
To move to a new page (insert a page break), simply add `.pageBreak()` on a paragraph:
|
||||||
|
|
||||||
```js
|
```ts
|
||||||
var paragraph = new docx.Paragraph("Amazing Heading").heading1().pageBreak();
|
const paragraph = new docx.Paragraph("Amazing Heading").pageBreak();
|
||||||
```
|
```
|
||||||
|
|
||||||
The above example will create a heading and start a new page immediately afterwards.
|
The above example will create a heading and start a new page immediately afterwards.
|
||||||
@ -261,8 +272,11 @@ The above example will create a heading and start a new page immediately afterwa
|
|||||||
|
|
||||||
This option (available in word) will make sure that the paragraph will start on a new page (if it's not already on a new page).
|
This option (available in word) will make sure that the paragraph will start on a new page (if it's not already on a new page).
|
||||||
|
|
||||||
```js
|
```ts
|
||||||
var paragraph = new docx.Paragraph("Hello World on another page").pageBreakBefore();
|
const paragraph = new Paragraph({
|
||||||
|
text: "Hello World on another page",
|
||||||
|
pageBreakBefore: true,
|
||||||
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
|
@ -5,3 +5,17 @@
|
|||||||
A section is a grouping of paragraphs that have a specific set of properties used to define the pages on which the text will appear. Properties include page size, page numbers, page orientation, headers, borders and margins.
|
A section is a grouping of paragraphs that have a specific set of properties used to define the pages on which the text will appear. Properties include page size, page numbers, page orientation, headers, borders and margins.
|
||||||
|
|
||||||
For example, you could have one section which is portrait with a header and footer, and another section in landscape with no footer, and a header showing the current page number.
|
For example, you could have one section which is portrait with a header and footer, and another section in landscape with no footer, and a header showing the current page number.
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
This creates a simple section in a document with one paragraph inside:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
doc.addSection({
|
||||||
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
children: [new TextRun("Hello World")],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
```
|
||||||
|
Reference in New Issue
Block a user