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

const redaction = require('@groupdocs/groupdocs.redaction');

const redactor = new redaction.Redactor(stream);
try 
{
const info = redactor.getDocumentInfo();
    console.log('\nFile type: ' + info.getFileType() + '\nNumber of pages: ' + info.getPageCount() + 
            '\nDocument size: ' + info.getSize() + ' bytes');
}
finally {
  redactor.close();
}

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

Download full output

Get file info for a file from Stream

const redaction = require('@groupdocs/groupdocs.redaction');
const java = require('java');
const FileInputStream = java.import('java.io.FileInputStream');

const stream = new FileInputStream('sample.docx');
const redactor = new redaction.Redactor(stream);
try 
{
    const info = redactor.getDocumentInfo();
    console.log('\nFile type: ' + info.getFileType() + '\nNumber of pages: ' + info.getPageCount() + 
            '\nDocument size: ' + info.getSize() + ' bytes');
}
finally 
{ 
    redactor.close(); 
    stream.close();
}

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

Download full output