Get file 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.Redaction 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-redaction -- dnx GroupDocs.Redaction.Mcp --yes
Folders, licensing and more →

Get file info

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

final Redactor redactor = new Redactor(stream);
try 
{
    IDocumentInfo info = redactor.getDocumentInfo();
    System.out.println("\nFile type: " + info.getFileType() + "\nNumber of pages: " + info.getPageCount() + 
            "\nDocument size: " + info.getSize() + " bytes");
}
finally { redactor.close(); }

Get file info for a file from Stream

FileInputStream stream = new FileInputStream("D:\\Sample.docx");
final Redactor redactor = new Redactor("D:\Sample.docx");
try 
{
    IDocumentInfo info = redactor.getDocumentInfo();
    System.out.println("\nFile type: " + info.getFileType() + "\nNumber of pages: " + info.getPageCount() + 
            "\nDocument size: " + info.getSize() + " bytes");
}
finally 
{ 
    redactor.close(); 
    stream.close();
}