[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Collapse]Office File API
  Demo Application
  Redistribution and Deployment
 [Expand]Spreadsheet Document API
 [Expand]Word Processing Document API
 [Collapse]PDF Document API
   Getting Started
   Coordinate Systems
   Document Generation
  [Expand]PDF Graphics
  [Expand]Document Manipulation
  [Expand]Additional Content
  [Expand]Interactive Forms
  [Expand]Text Markup Annotations
  [Collapse]Document Security
    Document Protection
    Signing Document
  [Expand]Examples
 [Expand]Excel Export Library
 [Expand]Snap Report API
 [Expand]Zip Compression and Archive API
 [Expand]Barcode Generation API
 [Expand]Unit Conversion API
 [Expand]API Reference
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Document Protection

By default, most documents do not impose restrictions on opening a file used for reading. The PDF Document API component can protect a document with a password using both user and owner passwords. Passwords are used to prevent users from accessing or modifying PDF documents.

The sections below provide more detailed descriptions on the user and owner passwords and explain how to customize PDF Document API encryption options to protect a document.

Expanded Encryption Settings

Before encrypting, the PDF Document API component must have a document (the document can be created by any operation using, for example, the Document Creation API).

All required settings to protect a document are contained in the PdfEncryptionOptions object, which you can access using the PdfSaveOptions.EncryptionOptions property.

To encrypt the document with these settings, call the overloaded PdfDocumentProcessor.CreateEmptyDocument or PdfDocumentProcessor.SaveDocument method and pass the PdfSaveOptions object containing these settings as a parameter.

Expanded User password

The user password is used when you want to prevent unauthorized access to a document. This password protects sensitive information. So, if you want to open a protected document, you need to enter the user password.

The image below shows a dialog box displayed if you are trying to open a protected document in the PDF Viewer.

Specify the user password using the PdfEncryptionOptions.UserPasswordString property to protect your document from being opened.

Expanded Owner password

If a document is opened with a user password or without a password (if the user password is not specified), you can perform only permitted operations. To get full access to a document, specify the owner password using the PdfEncryptionOptions.OwnerPasswordString property.

Important

If the Owner and User passwords are the same or the Owner password is missing and the document is protected only with the User password, the resulting document will have a document opening restriction. In this case, any user will have full access to this document after opening it.

You can control the document access either by restricting or allowing printing, data extraction, document modification and interactive operations.

Note

The restrictions on data extraction, data modification, interactive, or printing operations with a document can't be applied without the owner password.

Expanded How to Restrict Operations

To restrict data extraction, data modification, interactive, or printing operations with a PDF document, create a PdfEncryptionOptions object and specify the owner password using the PdfEncryptionOptions.OwnerPasswordString property and permissions listed below.

To encrypt a document with printing permissions, use the PdfEncryptionOptions.PrintingPermissions property. This property can be set to one of the following values.

Name Description
Allowed Permit document printing.
LowQuality Prohibit document printing at the highest quality level.
NotAllowed Prohibit document printing.

To encrypt a document with data extraction permissions, use the PdfEncryptionOptions.DataExtractionPermissions property. These permissions impose the following restrictions on data extraction operations.

Name Description
Allowed Permit data extraction operations (copying, or text and graphics extraction from the document) including access to software that uses assistive technologies.
Accessibility Allow PDF Viewers to access document content by using the Viewer's accessibility features.
NotAllowed Prohibit data extraction operations (copying, or text and graphics extraction from the document) including access to software that uses assistive technologies.

To encrypt a document with document modification restrictions, set the PdfEncryptionOptions.ModificationPermissions property to one of the following values.

Name Description
Allowed Permit document modification and assembling.
DocumentAssembling Allow only document assembling such as inserting, rotating or deleting pages, as well as bookmark creation on the navigation pane.
NotAllowed Prohibit document modification and assembling.

To set interactivity permissions, use the PdfEncryptionOptions.InteractivityPermissions property. The following values are supported.

Name Description
Allowed Permit interactive operations (adding or modifying text annotations, filling in interactive form fields, and creating or modifying interactive form fields) in a PDF document.
FormFillingAndSigning Prohibit interactive operations in a PDF document except form filling in the existing form fields and document signing.
NotAllowed Prohibit all interactive operations (adding or modifying text annotations, filling in interactive form fields, and creating or modifying interactive form fields) in a PDF document.

Expanded Example

This example shows how to protect a PDF document using both the owner and user passwords.

Tip

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T243764.

Is this topic helpful?​​​​​​​