The following code sample demonstrates how to extract basic format information from a file.
basic_usage.GetDocumentInfo
// Constants.InputXlsx is an absolute or relative path to your document. Ex: @"C:\Docs\source.xlsx"try(Metadatametadata=newMetadata(Constants.InputXlsx)){if(metadata.getFileFormat()!=FileFormat.Unknown){IDocumentInfoinfo=metadata.getDocumentInfo();System.out.println(String.format("File format: %s",info.getFileType().getFileFormat()));System.out.println(String.format("File extension: %s",info.getFileType().getExtension()));System.out.println(String.format("MIME Type: %s",info.getFileType().getMimeType()));System.out.println(String.format("Number of pages: %s",info.getPageCount()));System.out.println(String.format("Document size: %s bytes",info.getSize()));System.out.println(String.format("Is document encrypted: %s",info.isEncrypted()));}}
More resources
Advanced usage topics
To learn more about library features and get familiar how to manage metadata and more, please refer to theadvanced usage section.
GitHub examples
You may easily run the code above and see the feature in action in our GitHub examples: