ArcGIS Pro 3.8 API Reference Guide
ArcGIS.Core.OCR Namespace / OCRManager Class / GetDocumentPageCount Method
The document file.
Example

In This Topic
    GetDocumentPageCount Method
    In This Topic
    Gets the number of pages in the specified document. See IsValidDocumentForOCR for information about the file extensions supported. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public int GetDocumentPageCount( 
       string documentFileName
    )
    Public Function GetDocumentPageCount( _
       ByVal documentFileName As String _
    ) As Integer

    Parameters

    documentFileName
    The document file.

    Return Value

    The number of pages in the document. If the file cannot be read then 0 is returned.
    Exceptions
    ExceptionDescription
    documentFileName is null.
    The document image cannot be found or has an invalid extension for OCR.
    An error occurred within the OCR engine.
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Remarks
    PDF and TIFF files are typically the only OCR supported file types that can contain multiple pages.
    Example
    Get number of pages in a document
    {
      string docFileName = "c:\\MyData\\MyDocument.pdf";
      var pageCount = OCRManager.Instance.GetDocumentPageCount(docFileName);
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.8 or higher.
    See Also