Get document info

GroupDocs.Parser provides the functionality to get the basic document info by the getDocumentInfo() method:

parser.getDocumentInfo(); // returns IDocumentInfo

The IDocumentInfo interface has the following members:

MemberDescription
getFileType()The document type.
getPageCount()The total number of document pages.
getRawPageCount()The total number of document raw pages.
getSize()The size of the document in bytes.

Here are the steps to get document info:

  • Instantiate the Parser object for the initial document;
  • Call the getDocumentInfo() method and obtain the object with the IDocumentInfo interface;
  • Call methods such as getFileType(), getPageCount() or getSize().

The following example shows how to get document info:

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

// Create an instance of Parser class
const parser = new groupdocs.Parser('sample.docx');
try {
  // Get the document info
  const info = parser.getDocumentInfo();
  // Print document information
  console.log(`FileType: ${info.getFileType().toString()}`);
  console.log(`PageCount: ${info.getPageCount()}`);
  console.log(`Size: ${info.getSize()}`);
} finally {
  parser.close();
}

process.exit(0);

The output looks like this:

FileType: Microsoft Word Open XML Document (.docx)
PageCount: 2
Size: 15214

More resources

Advanced usage topics

To learn more about document data extraction features and get familiar how to extract text, images, forms and more, please refer to the advanced usage section.

Free online document parser App

Along with the full-featured library we provide simple, but powerful free Apps.

You are welcome to extract data from PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX, Emails and more with our free online Free Online Document Parser App.

Close
Loading

Analyzing your prompt, please hold on...

An error occurred while retrieving the results. Please refresh the page and try again.