Skip to main content

AddBookmarkCrossRef

Adds a bookmark cross-reference to the current paragraph.

note

This paragraph must be in the document.

Syntax​

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

expression - A variable that represents an 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​

Insert a cross-reference that links to a bookmark in a document.

// How do I add a navigable reference pointing to a named bookmark in a document?

// Connect one paragraph to another location by referencing a bookmark by name in a document.

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]);