Document Permissions

PSPDFKit for Web respects the document permissions set in a PDF document and makes it possible to restrict them further.

If you use the Server-backed version of PSPDFKit for Web, you can also restrict the permissions of a document in the JSON Web Token (JWT) used for authentication.

Be aware that restricted document permissions set in a PDF itself or in the JWT cannot be overwritten.

The permissions outlined below can be set in PSPDFKit for Web.

Text Selection

When this permission is not given, users are not allowed to select text in a document. This permission is granted by default, but it can be disabled by setting the Configuration.disableTextSelection configuration value to true.

Printing

This permission specifies whether or not printing a document is allowed. This permission is granted by default, but it can be disabled via the JavaScript API.

High-Quality Printing

This permission specifies whether or not a document will be printed in high quality. When high-quality printing is enabled, a document will print with a resolution of 300 DPI; otherwise, 150 DPI will be used.

Be aware that high-quality printing uses more resources than low-quality printing, and this might affect the performance while printing.

Setting this permission will only have an effect if the print mode is set to PSPDFKit.PrintMode.DOM. If you want to print a document in lower quality, you can set the Configuration.disableHighQualityPrinting configuration value to true. This permission defaults to printing in high quality.

Permissions

Global

This permission specifies whether or not modifying a document is allowed. Modification is allowed by default, but it can be disabled using the Instance#setViewState function:

1
instance.setViewState(v => v.set("readOnly", true));
1
2
3
instance.setViewState(function(v) {
  return v.set("readOnly", true);
});

Annotation Types

This permission specifies which annotation types can be edited. When using this API, it will also hide the toolbar icons for the annotation types that can’t be modified. By default, the PSPDFKit.defaultEditableAnnotationTypes are editable:

Copy
1
2
3
4
5
6
instance.setEditableAnnotationTypes([
  PSPDFKit.Annotations.ShapeAnnotation,
  PSPDFKit.Annotations.TextAnnotation,
  PSPDFKit.Annotations.HighlightAnnotation,
  PSPDFKit.Annotations.SquiggleAnnotation
]);
Copy
1
2
3
4
5
6
instance.setEditableAnnotationTypes([
  PSPDFKit.Annotations.ShapeAnnotation,
  PSPDFKit.Annotations.TextAnnotation,
  PSPDFKit.Annotations.HighlightAnnotation,
  PSPDFKit.Annotations.SquiggleAnnotation
]);

Individual Annotations

To allow only specific annotations to be editable, you can use PSPDFKit.setIsEditableAnnotation, which accepts a callback that needs to return a Boolean. The callback will be called multiple times while PSPDFKit for Web is running, so you should not perform anything with side effects, like an XHR request.

You need to customize the toolbar on your own, since this API will not hide any toolbar items:

Copy
1
2
3
4
// Only allow editing of annotations when the name of the creator is "Alice."
instance.setIsEditableAnnotation(annotation => {
  return annotation.creatorName === "Alice";
});
Copy
1
2
3
4
// Only allow editing of annotations when the name of the creator is "Alice."
instance.setIsEditableAnnotation(function(annotation) {
  return annotation.creatorName === "Alice";
});

Forms

When this permission is disabled, users are not allowed to fill out forms. This permission is granted by default, but it can be disabled by setting the Configuration.disableForms configuration value to true.