public int GetDocumentPagesCount(string fileId, long size, int scale) { var guid = Guid.Parse(fileId); var pages = _filesStorage.GetPages(guid).ToList(); if (pages.Any()) { return(pages.Count); } var actor = _contextService.GetTokenActor(HttpContext); var fileLoader = _contextService.GetFileLoader(actor); var file = fileLoader.Download(guid, size); pages = _documentRender.RenderPages(file, scale).ToList(); if (pages.Any()) { _fileSaver.PutFilesAsync(guid, pages); } return(pages.Count); }