Get the PDF output file 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 →

You can get the information about the PDF output file using the GetViewInfo method that returns a ViewInfo object. The object contains the Pages collection that represents each Page of the document.

The following code snippet shows how to get the page count and the width and height of each document page:

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.ForPdfView();
    ViewInfo viewInfo = viewer.GetViewInfo(viewInfoOptions);

    // Display page count.
    Console.WriteLine("Pages count: " + viewInfo.Pages.Count);

    // Display width and height of each page.
    foreach (Page page in viewInfo.Pages)
    {
        Console.WriteLine($"Page: {page.Number}; Width: {page.Width}, pixels");
        Console.WriteLine($"Page: {page.Number}; Height: {page.Height}, pixels");
    }
}
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.ForPdfView()
            Dim viewInfo As ViewInfo = viewer.GetViewInfo(viewInfoOptions)
        
            ' Display page count.
            Console.WriteLine("Pages count: " & viewInfo.Pages.Count.ToString())
        
            ' Display width and height of each page.
            For Each page As Page In viewInfo.Pages
                Console.WriteLine($"Page: {page.Number}; Width: {page.Width}, pixels")
                Console.WriteLine($"Page: {page.Number}; Height: {page.Height}, pixels")
            Next
        End Using
    End Sub
End Module

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

Pages count: 4
Page: 1; Width: 595, pixels
Page: 1; Height: 842, pixels
Page: 2; Width: 595, pixels
Page: 2; Height: 842, pixels
Page: 3; Width: 595, pixels
Page: 3; Height: 842, pixels
Page: 4; Width: 595, pixels
Page: 4; Height: 842, pixels

Download full output