Get file info

With GroupDocs.Comparison you can retrieve the following information about a file:

  • FileType represents the document file type (PDF, Word document, Excel spreadsheet, PowerPoint presentation, image etc.).
  • PageCount represents the number of pages in a document.
  • FileSize represents the document file size.
  • PagesInfo represents the page information.

The following code samples show how to get file information:

Get file info for the file from a local disk

import groupdocs.comparison as gc

def run():
    comparer = gc.Comparer(sourcePath)

    info = comparer.source.get_document_info()

    print(info)
    
    print(f"\nFile type: {info.file_type.file_format}")
    print(f"Number of pages: {info.page_count}")
    print(f"Document size: {info.size} bytes")
    
    print("\nDocument info extracted successfully.")

The result is as follows:

Get file info for the file from a stream

import groupdocs.comparison as gc

def run():
    with open(sourcePath, 'rb') as source_stream:
        comparer = gc.Comparer(source_stream)

        info = comparer.source.get_document_info()
        
        print(f"\nFile type: {info.file_type.file_format}")
        print(f"Number of pages: {info.page_count}")
        print(f"Document size: {info.size} bytes")
        
        print("\nDocument info extracted successfully.")