Get the width and height of the document pages

You can get the width and height of each document page 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 width and height of each document page:

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

    // 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");
    }
}

The following image shows a sample console output: