Skip to main content

AddHeadingCrossRef

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

Syntax

expression.AddHeadingCrossRef(sRefType, oParaTo, bLink, bAboveBelow);

expression - A variable that represents a ApiParagraph class.

Parameters

NameRequired/OptionalData typeDefaultDescription
sRefTypeRequiredheadingRefToThe text or numeric value of a heading reference you want to insert.
oParaToRequiredApiParagraphThe heading paragraph 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).

Returns

boolean

Example

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

let doc = Api.GetDocument();
let newDocumentStyle = doc.GetStyle("Heading 1");
let paragraph = doc.GetElement(0);
paragraph.SetStyle(newDocumentStyle);
paragraph.AddText("Cross-reference method");
let headingParagraphs = doc.GetAllHeadingParagraphs();
paragraph = Api.CreateParagraph();
paragraph.AddText("Heading 1 style is applied to the heading ");
doc.Push(paragraph);
paragraph.AddHeadingCrossRef("text", headingParagraphs[0]);