Get document info

GroupDocs.Metadata allows users to get document information which includes:

  • File format (detected by the internal structure)
  • File extension
  • MIME type
  • Number of pages
  • File size
  • A value indicating whether a file is encrypted

The following code sample demonstrates how to extract basic format information from a file.

basic_usage.GetDocumentInfo

with gm.Metadata(constants.input_xlsx) as metadata:
        info = metadata.get_document_info()
        print(f"File format: {info.file_type.file_format}")
        print(f"File extension: {info.file_type.extension}")
        print(f"MIME Type: {info.file_type.mime_type}")
        print(f"Number of pages: {info.page_count}")
        print(f"Document size: {info.size} bytes")
        print(f"Is document encrypted: {info.is_encrypted}")

More resources

Advanced usage topics

To learn more about library features and get familiar how to manage metadata and more, please refer to theadvanced usage section.

GitHub examples

You may easily run the code above and see the feature in action in our GitHub examples:

Free online document metadata management App

Along with a full featured Java library we provide simple, but powerful free Apps.

You are welcome to view and edit metadata of PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX, emails, images and more with our free online Free Online Document Metadata Viewing and Editing App.