PDF Viewer - Protect PDF document

GroupDocs.Viewer enables you to protect PDF document by setting permissions, password for opening and password for changing permissions.

The following steps are to be followed in order to set PDF document permissions.

Following example demonstrates how to protect output PDF document.

    try (Viewer viewer = new Viewer("sample.docx")) {
        Security security = new Security();
        security.setPermissions(Permissions.ALLOW_ALL ^ Permissions.DENY_PRINTING);
        PdfViewOptions viewOptions = new PdfViewOptions(filePath);

More resources

Advanced Usage Topics

To learn more about document viewing features, please refer to the advanced usage section.

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.