GroupDocs.Watermark can obtain document information:
FileType
PageCount
Size
IsEncrypted
Get document information from a file from local disk
GroupDocs.Watermark lets you extract key details about a document before working with it. You can check its format, size, number of pages, and encryption status either from a file on disk or directly from a stream.
importgroupdocs.watermarkasgwwithgw.Watermarker("source.docx")aswatermarker:info=watermarker.get_document_info()print("File type:",info.file_type)print("Number of pages:",info.page_count)print("Document size:",info.size)
Get document information from a stream
importioimportgroupdocs.watermarkasgwwithopen("source.docx","rb")asf:stream=io.BytesIO(f.read())withgw.Watermarker(stream)aswatermarker:info=watermarker.get_document_info()print("File type:",info.file_type)print("Number of pages:",info.page_count)print("Document size:",info.size)
🔹 Use case: Validate documents before processing (e.g., reject encrypted files, check page limits, or confirm file type).
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.
On this page
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.