How to check that PDF printing not allowed

Checking that printing not allowed

GroupDocs.Viewer provides additional information for PDF documents when calling getViewInfo(…) method. To retrieve view information for PDF document call getViewInfo(…) method and cast output result to PdfViewInfo type.

Following example demonstrates how to retrieve view information for PDF document.

    try (Viewer viewer = new Viewer("sample.pdf")) {
        ViewInfoOptions viewInfoOptions = ViewInfoOptions.forHtmlView();
        PdfViewInfo viewInfo = (PdfViewInfo) viewer.getViewInfo(viewInfoOptions);
        System.out.println("Document type is: " + viewInfo.getFileType());
        System.out.println("Pages count: " + viewInfo.getPages().size());
        System.out.println("Printing allowed: " + viewInfo.isPrintingAllowed());

More resources

GitHub Examples

You may easily run the code above and see the feature in action in our GitHub examples:

Free Online App

Along with full-featured Java library we provide simple but powerful free Apps. You are welcome to view Word, PDF, Excel, PowerPoint documents with free to use online GroupDocs Viewer App.