Get document info
GroupDocs.Parser provides the functionality to get the basic document info by the getDocumentInfo method:
IDocumentInfo getDocumentInfo();
IDocumentInfo interface has the following members:
Member | Description |
---|---|
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 Parser object for the initial document;
- Call getDocumentInfo method and obtain the object with IDocumentInfo interface;
- Call properties such as getFileType, getPageCount or getSize.
The following example shows how to get document info:
// Create an instance of Parser class
try (Parser parser = new Parser(Constants.SampleDocx)) {
// Get the document info
IDocumentInfo info = parser.getDocumentInfo();
// Print document information
System.out.println(String.format("FileType: %s", info.getFileType()));
System.out.println(String.format("PageCount: %d", info.getPageCount()));
System.out.println(String.format("Size: %d", info.getSize()));
}
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.
GitHub examples
You may easily run the code above and see the feature in action in our GitHub examples:
Free online document parser App
Along with full featured Java 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.