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:

using System;
using GroupDocs.Viewer;
using GroupDocs.Viewer.Options;
using GroupDocs.Viewer.Results;
// ...

using (Viewer viewer = new Viewer("sample.pdf"))
{
    // Get file information.
    ViewInfoOptions viewInfoOptions = ViewInfoOptions.ForHtmlView();
    ViewInfo viewInfo = viewer.GetViewInfo(viewInfoOptions);

    // Display file type and pages count.
    Console.WriteLine("Document type is: " + viewInfo.FileType);
    Console.WriteLine("Pages count: " + viewInfo.Pages.Count);
}
Imports System
Imports GroupDocs.Viewer
Imports GroupDocs.Viewer.Options
Imports GroupDocs.Viewer.Results
' ...

Module Program
    Sub Main(args As String())
        Using viewer As Viewer = New Viewer("sample.pdf")
            ' Get file information.
            Dim viewInfoOptions As ViewInfoOptions = ViewInfoOptions.ForHtmlView()
            Dim viewInfo As ViewInfo = viewer.GetViewInfo(viewInfoOptions)

            ' Display file type and pages count.
            Console.WriteLine("Document type is: " & viewInfo.FileType.ToString())
            Console.WriteLine("Pages count: " & viewInfo.Pages.Count.ToString())
        End Using
    End Sub
End Module

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

Document type is: Portable Document Format File (.pdf)
Pages count: 4

Download full output

Get the file type and the pages count from a stream

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

using System;
using System.IO;
using GroupDocs.Viewer;
using GroupDocs.Viewer.Options;
using GroupDocs.Viewer.Results;
// ...

using (Viewer viewer = new Viewer(File.OpenRead("sample.pdf")))
{
    ViewInfoOptions viewInfoOptions = ViewInfoOptions.ForHtmlView();
    ViewInfo viewInfo = viewer.GetViewInfo(viewInfoOptions);
 
    Console.WriteLine("Document type is: " + viewInfo.FileType);
    Console.WriteLine("Pages count: " + viewInfo.Pages.Count);
}
Imports System
Imports System.IO
Imports GroupDocs.Viewer
Imports GroupDocs.Viewer.Options
Imports GroupDocs.Viewer.Results
' ...

Module Program
    Sub Main(args As String())
        Using viewer As Viewer = New Viewer(File.OpenRead("sample.pdf"))
            Dim viewInfoOptions As ViewInfoOptions = ViewInfoOptions.ForHtmlView()
            Dim viewInfo As ViewInfo = viewer.GetViewInfo(viewInfoOptions)

            Console.WriteLine("Document type is: " & viewInfo.FileType.ToString())
            Console.WriteLine("Pages count: " & viewInfo.Pages.Count.ToString())
        End Using
    End Sub
End Module

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

Document type is: Portable Document Format File (.pdf)
Pages count: 4

Download full output