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:
import com.groupdocs.comparison.Comparer;
import com.groupdocs.comparison.interfaces.IDocumentInfo;
// ...
try (Comparer comparer = new Comparer("source.docx")) {
IDocumentInfo info = comparer.getSource().getDocumentInfo();
for (int i = 0; i < info.getPageCount(); i++) {
System.out.printf("\n" +
"File type: %s\n" +
"Number of pages: %d\n" +
"Document size: %d bytes\n" +
"Width: %d\n" +
"Height: %d%n",
info.getFileType().getFileFormat(),
info.getPageCount(),
info.getSize(),
info.getPagesInfo().get(i).getWidth(),
info.getPagesInfo().get(i).getHeight());
}
}
The result is as follows:
import com.groupdocs.comparison.Comparer;
import com.groupdocs.comparison.interfaces.IDocumentInfo;
import java.io.FileInputStream;
import java.io.InputStream;
// ...
try (InputStream inputStream = new FileInputStream("source.docx");
Comparer comparer = new Comparer(inputStream)) {
IDocumentInfo info = comparer.getSource().getDocumentInfo();
for (int i = 0; i < info.getPageCount(); i++) {
System.out.printf("\n" +
"File type: %s\n" +
"Number of pages: %d\n" +
"Document size: %d bytes\n" +
"Width: %d\n" +
"Height: %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.