Add the pageref element

This instruction is useful if you want to get the number of the page
containing a specific bookmark.
This commit is contained in:
Thomas Gerbet
2021-08-03 15:58:26 +02:00
parent 14013273af
commit 3f257bf5a4
8 changed files with 173 additions and 1 deletions

View File

@ -24,6 +24,17 @@ const link = this.doc.createInternalHyperLink('anchorForChapter1', 'This is a li
paragraph.addHyperLink(link);
```
You can also get the page number of the bookmark by creating a page reference to it:
```ts
new Paragraph({
children: [
new TextRun("The chapter1 can be seen on page "),
new PageRef("anchorForChapter1"),
]
})
```
## External
To create an external hyperlink you just need to specify the url and the text of the link, then add it to a paragraph with `doc.createHyperlink(url, text)`: