GetStatistics

function GetStatistics(): object

Description

Returns the document statistics represented as an object with the following parameters: PageCount - number of pages; WordsCount - number of words; ParagraphCount - number of paragraphs; SymbolsCount - number of symbols; SymbolsWSCount - number of symbols with spaces.

Returns

object

Try It

var oDocument = Api.GetDocument();
var oParagraph = oDocument.GetElement(0);
oParagraph.AddText("This is just a sample paragraph.");
var oStatistics = oDocument.GetStatistics();
oParagraph.AddLineBreak();
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Document statistics");
oParagraph.SetBold(true);
oDocument.Push(oParagraph);
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Pages: " + oStatistics.PageCount);
oDocument.Push(oParagraph);
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Words: " + oStatistics.WordsCount);
oDocument.Push(oParagraph);
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Paragraphs: " + oStatistics.ParagraphCount);
oDocument.Push(oParagraph);
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Symbols: " + oStatistics.SymbolsCount);
oDocument.Push(oParagraph);
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Symbols with spaces: " + oStatistics.SymbolsWSCount);
oDocument.Push(oParagraph);

Get Help

  • If you have any questions about ONLYOFFICE Docs, try the FAQ section first.
  • You can request a feature or report a bug by posting an issue on GitHub.
  • You can also ask our developers on ONLYOFFICE forum (registration required).