Foxit PDF SDK for Web

Introduction to PDF SDK for Web Permissions

PDF SDK for Web enables you to integrate a PDF viewer in a website and provides a very flexible permission configuration to help you control documents better. It supports viewer side user permissions to control how users can interact with documents. By default, users can directly interact with documents and can be restricted by document permissions. You can define user permissions on a web viewer level to confine users to interact with documents within your rules.

Note: The user permissions in both web viewer and PDF document level follow the same rules specified in PDF References. All the permissions and bit positions have the same meaning. For details, see Supported User Permissions.

Document User Permissions

In the PDF standard, you can set the user permissions for PDF documents. In Web Viewer, you can set password, user permissions and encryption algorithm by using the method PDFDoc. SetPasswordAndPermission () .

Sample: The following example code sets the password and permissions for the current document.

pdfdoc.setPasswordAndPermission('userPassword','ownerPassword', 0b111100, 'aes25', true);

Doc User Permissions Graph
When loading a document, you can get document user permissions by using the method
PDFDoc.getUserPermissions() or PDFDoc.getPermissions().

PDFDoc.getUserPermissions()This method checks only the specified document user restricted permissions.

PDFDoc.getPermissions() This method checks the specified document user permissions including user and owner. If you are the owner, it returns all permission, otherwise, it returns the same value of PDFDoc.getUserPermissions().

When you want to check what permissions you currently have set for the document, you can use the methods supported on the class UserPermission. For specific methods, refer to PDFViewCtrl.UserPermission.

UserPermissionA class used to facilitate you to check user permissions.

Sample: The following sample code shows how to open a document with user and owner password protection, and get values for the user permissions.

var pdfDoc = pdfViwer.openPDFByFile(file, {password: 'userPassword'}).then(function (pdfDoc) {
pdfDoc.getUserPermissions() === 0b111100;
PDFDoc.getPermissions() === 0b111100;

var pdfDoc = pdfViwer.openPDFByFile(file, {password: 'ownerPassword'}).then(function (pdfDoc) {
pdfDoc.getUserPermissions() === 0b111100;
PDFDoc.getPermissions() > 0b111100;

Web Viewer User Permissions
The user permissions at document level help you to control the security of your documents. But what if you only want to supervise users on an application level? You can configure the option
PDFViewer.options.customs.getDocPermissions on the Web Viewer constructor to set the permissions. When the Web Viewer has finished its initialization, it will take the intersection of the return values (see the image below) from PDFViewer.options.customs.getDocPermissions and PDFDoc.getPermissions() , and then define the final user access permissions on the Web Viewer. If the intersection value is 0, the Web Viewer determines the user access permission is set to read-only.

The following code sets read-only permissions on the constructor by presuming the current document has no user permissions.

Sample 1: By setting values

Tip: The values that can be set are -1 and 0. -1 represents owner permissions, 0 represents read-only.

var PDFUI = UIExtension.PDFUI;
var pdfui = new PDFUI({
viewerOptions: {
jr: {
customs: {
getDocPermissions: function (pdfDoc) {
return 0;
// 0 means read-only 

Sample 2By using the set methods

Currently the supported methods:

putCannotModifyAny() – Permission are set as read-only.

putCannotModifyExcludeAssemble() – Permissions that allow only insert, rotate, or delete pages and create bookmarks or thumbnails

function example (PDFViewerUserPermission) {
var pdfViewer = new PDFViewer({
customs: {
getDocPermissions: function (pdfDoc) {
// Set read-only permissions
var userPermission = new UserPermission();
return userPermission.getValue();

All permissions set at the Web Viewer level will no be written into documents.

When Web Viewer has finished its initialization, you may want to view the configured permissions on constructor and/or the final user access permissions for current document. You can get the permission values by using the following two methods.

UserPermission.getValue(): To get the user permissions on constructor.

PDFDocRender.getUserPermission(): To get the final user permissions for accessing documents.

Custom Web Viewer User Permissions

The Custom Web Viewer here means you customized some components or add-ons pertinent to PDF in Web Viewer. In this scenario, when you configure user permissions on the constructor, you should explicitly call PDFDocRender.getUserPermission() to get the final user permissions to access documents in the viewer.

function example (PDFViewerUserPermission) {
var pdfViewer = new PDFViewer({
customs: {
getDocPermissions: function (pdfDoc) {
// All users have read-only access only
var userPermission = new UserPermission();
return (userPermission).getValue();
var pdfDocRender = pdfViewer.getPDFDocRender();
if (pdfDocRender) {
pdfDocRender.getUserPermission().then(function (docViewerPermission) {
if (!docViewerPermission.checkPrint()) {
// Print is disallowed
// No subsequent execution


Supported User Permissions

PDF References uses 32-bit binary values to specify user access permissions. The supported bit positions include 3, 4, 5, 6, 9, 10, 11, 12. Each bit position has a corresponding access meaning. See the table below for details.

Tip 1: The binary number 0 is interpreted as the corresponding permission ‘disallowed’, and number 1 is ‘allowed’. For example, the 0b100, the 3rd bit position is 1, then the related access permission for print should be enabled.

The following table lists the bit position and its pertinent meaning that are applied to Viewer, Security standard handler and Foxit DRM.

Bit Position Meaning
3 Print PDF document with normal mode. (Bit 3 in permission value)
4 Modify PDF contents. (Bit 4 in permission value)
If this value is set, user can modify contents of PDF document by operations other than those controlled by values User_Permissions==annotForm, User_Permissions==efillForm and User_Permissions==assemble.
5 Extract PDF contents. (Bit 5 in permission value)
If this value is set, user can copy or otherwise extract text and graphics from the document by operations other than that controlled by value User_Permissions==extractAccess.
6 Operate text annotations and fill in interactive form fields. (Bit 6 in permission value)
If value User_Permissions==modify is also set, user can create or modify interactive form fields (including signature fields).
9 Fill PDF form. (Bit 9 in permission value)
If this value is set, user can fill in interactive form fields (including signature fields), even if the value User_Permissions==annotForm is not used.
10 Disabilities support. (Bit 10 in permission value)
If this value is set, user can extract text and graphics in support of accessibility to users with disabilities or for other purposes.
11 Assemble PDF document. (Bit 11 in permission value)
If this value is set, it enables to create the document (Insert, rotate, or delete pages and create bookmarks or thumbnail images), regardless if value User_Permissions==modify is set or not.
12 Print PDF document with higher qualities. (Bit 12 in permission value)
If this value is not set (and value User_Permissions==print is set), printing is limited to a low-level representation of the appearance, possibly of degraded quality.

For the bit positions that are not reserved in PDF References, like 1, 2, 7, 8, and 13-32, PDF SDK for Web reserves these positions, and interprets 1,2 as the binary number 0; 7, 8 and 13-32 as the binary number 1. These bit positions won’t affect your project, they are preserved just for future usage when more permissions are specified. For example, 0b11000100, the seventh and eighth position is number 1, they will be ignored in the execution.

Updated on September 3, 2021

Was this article helpful?
Thanks for your feedback. If you have a comment on how to improve the article, you can write it here: