GroupDocs.Redaction provides general document information, which includes:
FileType
PageCount
FileSize
The following code examples demonstrate how to get document information.
Get file info for a file from local disk
fromgroupdocs.redactionimportRedactordefget_local_file_info():# Load the document from local diskwithRedactor("./sample.docx")asredactor:# Retrieve general document informationinfo=redactor.get_document_info()print(f"File type: {info.file_type}")print(f"Number of pages: {info.page_count}")print(f"Document size: {info.size} bytes")if__name__=="__main__":get_local_file_info()
sample.docx is the sample file used in this example. Click here to download it.
File type: Microsoft Word Open XML Document (.docx)
Number of pages: 1
Document size: 19370 bytes
fromgroupdocs.redactionimportRedactordefget_file_info_from_stream():# Open the document as a binary streamwithopen("./sample.docx","rb")asstream:# Load the document from the streamwithRedactor(stream)asredactor:# Retrieve general document informationinfo=redactor.get_document_info()print(f"File type: {info.file_type}")print(f"Number of pages: {info.page_count}")print(f"Document size: {info.size} bytes")if__name__=="__main__":get_file_info_from_stream()
sample.docx is the sample file used in this example. Click here to download it.
File type: Microsoft Word Open XML Document (.docx)
Number of pages: 1
Document size: 19370 bytes