Get document Info

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Watermark MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-watermark -- dnx GroupDocs.Watermark.Mcp --yes
Folders, licensing and more →

GroupDocs.Watermark allows to get document information which includes:

The following code samples demonstrate how to get document information.

Get document information from a file from local disk

This example demonstrates how to get document information from the local file.

basic_usage.GetDocumentInfoForTheFileFromLocalDisk

// Specify an absolute or relative path to your document. Ex.: "C:\\Docs\\source.docx"
Watermarker watermarker = new Watermarker("source.docx");                                      
IDocumentInfo info = watermarker.getDocumentInfo();                                                 
System.out.println("File type: " + info.getFileType());                                             
System.out.println("Number of pages: " + info.getPageCount());                                      
System.out.println("Document size: " + info.getSize() + " bytes");
watermarker.dispose();

Get document information from a stream

This example demonstrates how to get document information from the file stream.

basic_usage.GetDocumentInfoForTheFileFromStream

// Specify an absolute or relative path to your document. Ex: "C:\\Docs\\source.docx"
FileInputStream stream = new FileInputStream("source.docx");                                  
Watermarker watermarker = new Watermarker(stream);                                                     
IDocumentInfo info = watermarker.getDocumentInfo();                                                    
System.out.println("File type: " + info.getFileType());                                                
System.out.println("Number of pages: " + info.getPageCount());                                         
System.out.println("Document size: " + info.getSize() + " bytes");
watermarker.dispose();
stream.close();