Get file info
Leave feedback
On this page
GroupDocs.Comparison allows you to get the following file information:
- FileType represents the document file type (PDF, Word document, Excel spreadsheet, PowerPoint presentation or image etc.).
- PageCount represents count of document pages.
- FileSize represents the document file size.
- PagesInfo represents the page information.
The following code samples show how to get file information:
try (Comparer comparer = new Comparer(sourceFile)) {
IDocumentInfo info = comparer.getSource().getDocumentInfo();
for (int i = 0; i < info.getPageCount(); i++) {
System.out.printf("\nFile type: %s\nNumber of pages: %d\nDocument size: %d bytes\nWidth: %d\nHeight: %d%n",
info.getFileType().getFileFormat(), info.getPageCount(), info.getSize(), info.getPagesInfo().get(i).getWidth(), info.getPagesInfo().get(i).getHeight());
}
}
The result is as follows:
try (InputStream inputStream = new FileInputStream(sourceFile);
Comparer comparer = new Comparer(inputStream)) {
IDocumentInfo info = comparer.getSource().getDocumentInfo();
for (int i = 0; i < info.getPageCount(); i++) {
System.out.printf("\nFile type: %s\nNumber of pages: %d\nDocument size: %d bytes\nWidth: %d\nHeight: %d%n",
info.getFileType().getFileFormat(), info.getPageCount(), info.getSize(), info.getPagesInfo().get(i).getWidth(), info.getPagesInfo().get(i).getHeight());
}
}
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.