Get the format family and the additional information

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Viewer MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-viewer -- dnx GroupDocs.Viewer.Mcp --yes
Folders, licensing and more →

A format family is a group of several file types for which an application provides additional information. For example, archive files (.7z, .rar, .zip, etc.) or Outlook files (.ost, .pst) are format families.

You can get the format family and the additional information using the getViewInfo method that returns a ViewInfo object.

GroupDocs.Viewer provides additional information for the following format families:

Get the file type and the pages count from a file

The following code snippet shows how to get the file type and the pages count from a file:

import { Viewer, ViewInfoOptions } from '@groupdocs/groupdocs.viewer';

const viewer = new Viewer("resume.pdf")
// Get file information.
const viewInfoOptions = ViewInfoOptions.forHtmlView()
const viewInfo = viewer.getViewInfo(viewInfoOptions)
console.log("Document type is: " + viewInfo.getFileType())
console.log("Pages count: " + viewInfo.getPages().size())

resume.pdf is the sample file used in this example. Click here to download it.

The following image shows a sample console output: