Get file info

With GroupDocs.Comparison you can retrieve the following information about a file:

  • FileType represents the document file type (PDF, Word document, Excel spreadsheet, PowerPoint presentation, image etc.).
  • PageCount represents the number of pages in a document.
  • FileSize represents the document file size.
  • PagesInfo represents the page information.

The following code samples show how to get file information:

Get file info for the file from a local disk

const comparer = new groupdocs.comparison.Comparer(Constants.SOURCE_WORD);

let info = await comparer.getSource().getDocumentInfo();

console.log(`\nFile type: ${info.getFileType().getFileFormat()}`);
console.log(`Number of pages: ${info.getPageCount()}`);
console.log(`Document size: ${info.getSize()} bytes`);

The result is as follows:

Get file info for the file from a stream

const comparer = new groupdocs.comparison.Comparer(new FileInputStream(Constants.SOURCE_WORD));

let info = await comparer.getSource().getDocumentInfo();

console.log(`\nFile type: ${info.getFileType().getFileFormat()}`);
console.log(`Number of pages: ${info.getPageCount()}`);
console.log(`Document size: ${info.getSize()} bytes`);