About Api of add bookmark

I want to implement a function that when I open a docx file scroll to the specific position that I have marked with a bookmark. I implement it in frontend by using the rangApi like below

function onLabel(){
  const connector = connectorRef.current!;
  connector.callCommand(function () {
    var oDocument = Api.GetDocument();
    var oRange = oDocument.GetRangeBySelect();
    oRange.AddBookmark("newBook");
  }, true);
}

function onJump(){
  const connector = connectorRef.current!;
  connector.callCommand(function () {
    var oDocument = Api.GetDocument();
    var oRange = oDocument.GetBookmarkRange('newBook');
    oRange.Select()
  }, true);
}

How do I add bookmark by backend request ? then I can scroll to the specific position in frontend

my english is bad thank u

I try use RangeApi Select in events_onDocumentReady but sometimes it not work,selected but not scroll the document

Hello @fengjue

You can try adding your function to onDocumentReady event so it is called automatically when document is loaded completed, for instance, like that:

    "events": {
        "onDocumentReady": function() {
                        <your_funtion>
                    }

In general, we do not direct methods to scroll the document to specified position.


As I can see, you are using connector class (Automation API) that requires Developer license. If you have valid or trial license, please feel free to contact us via Zendesk to get prompt support.

Is there have a api or a sets of api to get range by specific page number or exist in business edition?

Iā€™m afraid there is no way to get range by page number.

1 Like

Ok thank u ,and thank you very much for your contribution to open source

1 Like