AddBookmarkCrossRef
Adds a bookmark cross-reference to the current paragraph.
Please note that this paragraph must be in the document.
Parameters:
Name |
Type |
Default |
Description |
sRefType |
bookmarkRefTo
|
|
The text or numeric value of a bookmark reference you want to insert. |
sBookmarkName |
string
|
|
The name of the bookmark to be referred to (must be in the document). |
bLink |
boolean
|
true |
Specifies if the reference will be inserted as a hyperlink. |
bAboveBelow |
boolean
|
false |
Specifies if the above/below words indicating the position of the reference should be included (don't used with the "text" and "aboveBelow" sRefType). |
sSepWith |
string
|
"" |
A number separator (used only with the "fullCtxParaNum" sRefType). |
Returns:
- Type
-
boolean
Example
Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oParagraph = oDocument.GetElement(0);
oParagraph.AddText("ONLYOFFICE Document Builder");
var oRange = oDocument.GetRange(0, 9);
oRange.AddBookmark("Bookmark");
var aBookmarks = oDocument.GetAllBookmarksNames();
oParagraph = Api.CreateParagraph();
oParagraph.AddText("A bookmark was added ");
oDocument.Push(oParagraph);
oParagraph.AddBookmarkCrossRef("aboveBelow", aBookmarks[0]);
builder.SaveFile("docx", "AddBookmarkCrossRef.docx");
builder.CloseFile();
Resulting document