ONLYOFFICE Docs v7.3 released: enhanced forms, SmartArt, new security settings, Watch Window, and more
ONLYOFFICE Docs v7.3 released

Api.GetTables is not a function

Hello, I’m getting the following error when trying to call Api.GetTables

sdk-all.js:12625 TypeError: Api.GetTables is not a function
    at eval (eval at f (sdk-all.js:12625:270), <anonymous>:8:28)
    at eval (eval at f (sdk-all.js:12625:270), <anonymous>:10:11)
    at eval (eval at f (sdk-all.js:12625:270), <anonymous>:11:3)
    at f (sdk-all.js:12625:270)

Here’s the relevant code: (this is inside a plugin’s init() function`

  document
    .getElementById("buttonAddOptionalField")
    .addEventListener("click", function () {
      window.Asc.plugin.callCommand(
        function () {
          var oDocument = Api.GetDocument()
          var oParagraph = Api.CreateParagraph()
          var tables = Api.GetTables()
          console.log(tables)
        },
        false,
        true,
        (args) => {
          console.log(args)
        }
      )
    })

I found out that I was using Api.GetTables wrong and instead found the ApiDocument.GetAllTablesOnPage(pageNumber) function.
However, I’m now unable to find a way to get the amount of pages. Is there a way to do this? I can’t seem to be able to find one.

Hello @fr3fou

Sorry for the late reply.
Unfortunately, right now we do not have methods to get amount of pages via API. We have created enhancement suggestion number 60309 to add this method in future release.