Merge pull request #944 from devoidfury/fix/docs-update
Updates and fixes for documentation
This commit is contained in:
@ -12,14 +12,14 @@ const doc = new Document({
|
|||||||
new Paragraph({
|
new Paragraph({
|
||||||
text: "Bullet points",
|
text: "Bullet points",
|
||||||
bullet: {
|
bullet: {
|
||||||
level: 0 //How deep you want the bullet to be
|
level: 0 //How deep you want the bullet to be
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
new Paragraph({
|
new Paragraph({
|
||||||
text: "Are awesome",
|
text: "Are awesome",
|
||||||
bullet: {
|
bullet: {
|
||||||
level: 0
|
level: 0
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
}];
|
}];
|
||||||
|
@ -5,35 +5,49 @@
|
|||||||
?> **Note:** This feature only works on Headers and Footers
|
?> **Note:** This feature only works on Headers and Footers
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
doc.Header.createParagraph().addRun(new TextRun("Page Number: ").pageNumber()).addRun(new TextRun("to ").numberOfTotalPages());
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new TextRun({
|
||||||
|
children: ["Page #: ", PageNumber.CURRENT],
|
||||||
|
})
|
||||||
|
]
|
||||||
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
## Current page number
|
## Current page number
|
||||||
|
|
||||||
To get the current page number, call the `.pageNumber()` method on a `TextRun`. Then add the newly created `TextRun` into a paragraph
|
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
pageNumber();
|
PageNumber.CURRENT
|
||||||
```
|
```
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
const currentPageRun = new TextRun("Current Page Number: ").pageNumber();
|
new Paragraph({
|
||||||
paragraph.addRun(currentPageRun);
|
children: [
|
||||||
|
new TextRun({
|
||||||
|
children: ["Page Number ", PageNumber.CURRENT],
|
||||||
|
})
|
||||||
|
]
|
||||||
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
## Total number of pages
|
## Total number of pages
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
numberOfTotalPages();
|
PageNumber.TOTAL_PAGES
|
||||||
```
|
```
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
const lastPage = new TextRun("Total Page Number: ").numberOfTotalPages();
|
new Paragraph({
|
||||||
paragraph.addRun(lastPage);
|
children: [
|
||||||
|
new TextRun({
|
||||||
|
children: ["Total Pages Number: ", PageNumber.TOTAL_PAGES],
|
||||||
|
})
|
||||||
|
]
|
||||||
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -42,17 +56,14 @@ paragraph.addRun(lastPage);
|
|||||||
You can combine the two to get "Page 2 of 10" effect:
|
You can combine the two to get "Page 2 of 10" effect:
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
const currentPageRun = new TextRun("Page ").pageNumber();
|
new Paragraph({
|
||||||
const lastPage = new TextRun("of ").numberOfTotalPages();
|
children: [
|
||||||
|
new TextRun("My awesome text here for my university dissertation. ")
|
||||||
paragraph.addRun(currentPageRun);
|
new TextRun({
|
||||||
paragraph.addRun(lastPage);
|
children: ["Page ", PageNumber.CURRENT, " of ", PageNumber.TOTAL_PAGES],
|
||||||
```
|
})
|
||||||
|
]
|
||||||
Or:
|
})
|
||||||
|
|
||||||
```ts
|
|
||||||
doc.Header.createParagraph().addRun(new TextRun("Page ").pageNumber()).addRun(new TextRun("of ").numberOfTotalPages());
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
> Everything (text, images, graphs etc) in OpenXML is organized in paragraphs.
|
> Everything (text, images, graphs etc) in OpenXML is organized in paragraphs.
|
||||||
|
|
||||||
!> Paragraphs requires an understanding of [Sections](sections.md).
|
!> Paragraphs requires an understanding of [Sections](usage/sections.md).
|
||||||
|
|
||||||
You can create `Paragraphs` in the following ways:
|
You can create `Paragraphs` in the following ways:
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ const paragraph = new Paragraph("Short hand Hello World");
|
|||||||
|
|
||||||
### Children Method
|
### Children Method
|
||||||
|
|
||||||
This method is useful for adding different [text](text.md) with different styles, [symbols](symbols.md), or adding [images](images.md) inline.
|
This method is useful for adding different [text](usage/text.md) with different styles, [symbols](usage/symbols.md), or adding [images](usage/images.md) inline.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
const paragraph = new Paragraph({
|
const paragraph = new Paragraph({
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
# Symbol Runs
|
# Symbol Runs
|
||||||
|
|
||||||
!> SymbolRuns require an understanding of [Paragraphs](paragraph.md).
|
!> SymbolRuns require an understanding of [Paragraphs](usage/paragraph.md).
|
||||||
|
|
||||||
You can add multiple `symbol runs` in `Paragraphs` along with [text runs](text.md) using the Paragraph's `children` property.
|
You can add multiple `symbol runs` in `Paragraphs` along with [text runs](usage/text.md) using the Paragraph's `children` property.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { Paragraph, TextRun, SymbolRun } from "docx";
|
import { Paragraph, TextRun, SymbolRun } from "docx";
|
||||||
@ -50,4 +50,4 @@ const symbol = new SymbolRun({
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
See the [text run](text.md) documentation for more info.
|
See the [text run](usage/text.md) documentation for more info.
|
||||||
|
@ -237,12 +237,6 @@ const cell = new TableCell({
|
|||||||
| NIL | is considered as zero |
|
| NIL | is considered as zero |
|
||||||
| PCT | percent of table width |
|
| PCT | percent of table width |
|
||||||
|
|
||||||
#### Example
|
|
||||||
|
|
||||||
```ts
|
|
||||||
cell.Properties.setWidth(100, WidthType.DXA);
|
|
||||||
```
|
|
||||||
|
|
||||||
### Nested Tables
|
### Nested Tables
|
||||||
|
|
||||||
To have a table within a table, simply add it in the `children` block of a `table cell`:
|
To have a table within a table, simply add it in the `children` block of a `table cell`:
|
||||||
|
Reference in New Issue
Block a user