Get file info
Leave feedback
On this page
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:
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:
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.")
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.