Skip to main content

AddBookmarkCrossRef

Adds a bookmark cross-reference to the current paragraph. 💡 Please note that this paragraph must be in the document.

Syntax

expression.AddBookmarkCrossRef(sRefTo, sBookmarkName, bLink, bAboveBelow, sSepWith);

expression - A variable that represents a ApiParagraph class.

Parameters

NameRequired/OptionalData typeDefaultDescription
sRefToRequiredbookmarkRefToThe text or numeric value of a bookmark reference you want to insert.
sBookmarkNameRequiredstringThe name of the bookmark to be referred to (must be in the document).
bLinkOptionalbooleantrueSpecifies if the reference will be inserted as a hyperlink.
bAboveBelowOptionalbooleanfalseSpecifies if the above/below words indicating the position of the reference should be included (don't used with the "text" and "aboveBelow" sRefType).
sSepWithOptionalstring""A number separator (used only with the "fullCtxParaNum" sRefType).

Returns

boolean

Example

This example adds a bookmark cross-reference to the paragraph.

let doc = Api.GetDocument(); 
let paragraph = doc.GetElement(0);
paragraph.AddText("ONLYOFFICE Document Builder");
let range = doc.GetRange(0, 9);
range.AddBookmark("Bookmark");
let bookmarks = doc.GetAllBookmarksNames();
paragraph = Api.CreateParagraph();
paragraph.AddText("A bookmark was added ");
doc.Push(paragraph);
paragraph.AddBookmarkCrossRef("aboveBelow", bookmarks[0]);