Get Started
Usage API
More information

AddHeadingCrossRef

AddHeadingCrossRef(sRefType, oParaTo, [bLink], [bAboveBelow]) → { boolean }

Adds a heading cross-reference to the current paragraph. The paragraph must be in the document.

Parameters:

Name Type Default Description
sRefType headingRefTo

The text or numeric value of a heading reference you want to insert.

oParaTo ApiParagraph

The heading paragraph 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).

Returns:

Type
boolean

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oNewDocumentStyle = oDocument.GetStyle("Heading 1");
var oParagraph = oDocument.GetElement(0);
oParagraph.SetStyle(oNewDocumentStyle);
oParagraph.AddText("Cross-reference method");
var aHeadingParagraphs = oDocument.GetAllHeadingParagraphs();
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Heading 1 style is applied to the heading ");
oDocument.Push(oParagraph);
oParagraph.AddHeadingCrossRef("text", aHeadingParagraphs[0]);
builder.SaveFile("docx", "AddHeadingCrossRef.docx");
builder.CloseFile();

Resulting document