Get document Info

GroupDocs.Watermark allows to get document information which includes:

The following code samples demonstrate how to get document information.

Get document information from a file from local disk

This example demostrates how to get document information from the local file.

basic_usage.GetDocumentInfoForTheFileFromLocalDisk

// Constants.InSourceDocx is an absolute or relative path to your document. Ex.: "C:\\Docs\\source.docx"
Watermarker watermarker = new Watermarker(Constants.InSourceDocx);                                      
IDocumentInfo info = watermarker.getDocumentInfo();                                                 
System.out.println("File type: " + info.getFileType());                                             
System.out.println("Number of pages: " + info.getPageCount());                                      
System.out.println("Document size: " + info.getSize() + " bytes");
watermarker.dispose();

Get document information from a stream

This example demonstrates how to get document information from the file stream.

basic_usage.GetDocumentInfoForTheFileFromStream

// Constants.InSourceDocx is an absolute or relative path to your document. Ex: "C:\\Docs\\source.docx"
FileInputStream stream = new FileInputStream(Constants.InSourceDocx);                                  
Watermarker watermarker = new Watermarker(stream);                                                     
IDocumentInfo info = watermarker.getDocumentInfo();                                                    
System.out.println("File type: " + info.getFileType());                                                
System.out.println("Number of pages: " + info.getPageCount());                                         
System.out.println("Document size: " + info.getSize() + " bytes");
watermarker.dispose();
stream.close();

More resources

Advanced usage topics

To learn more about document watermarking features and get familiar how to manage watermarks 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:

Free online document watermarking App

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

You are welcome to add watermark to PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX, Emails and more with our free online Free Online Document Watermarking App.