Annotation-Editing Configuration

Annotation editing can be configured using PdfActivityConfiguration.Builder when using PdfActivity, or using PdfConfiguration.Builder when using PdfFragment.

Control Which Annotation Types Can Be Edited

By default, PSPDFKit enables editing of all supported annotation types. You can disable editing for all annotation types via #disableAnnotationEditing.

If you want to control which annotation types are editable, use #editableAnnotationTypes. Passing null or an empty list to this method means that all supported annotation types are editable. For example:

Copy
1
2
3
4
5
6
val config =
    PdfActivityConfiguration.Builder(context)
        // By default, all supported annotation types are editable.
        // You can selectively enable certain types by providing them here.
        .editableAnnotationTypes(listOf(AnnotationType.NOTE, AnnotationType.INK, AnnotationType.STAMP))
        .build()
Copy
1
2
3
4
5
6
final PdfActivityConfiguration config =
    new PdfActivityConfiguration.Builder(context)
        // By default, all supported annotation types are editable.
        // You can selectively enable certain types by providing them here.
        .editableAnnotationTypes(Arrays.asList(AnnotationType.NOTE, AnnotationType.INK, AnnotationType.STAMP))
        .build();

Control Which Annotation Tools Are Enabled

You can control which annotation tools are enabled in the annotation creation toolbar via #enabledAnnotationTools. Passing null or an empty list to this method means that all supported annotation tools are enabled. For example:

Copy
1
2
3
4
5
6
7
8
9
10
// In this example, we want to enable all annotation tools except the `IMAGE` tool.
val enabledAnnotationTools = AnnotationTool.values().toMutableList()
enabledAnnotationTools.remove(AnnotationTool.IMAGE)

val config =
    PdfActivityConfiguration.Builder(context)
        // By default, all supported annotation tools are enabled.
        // You can selectively enable certain tools by providing them here.
        .enabledAnnotationTools(enabledAnnotationTools)
        .build()
Copy
1
2
3
4
5
6
7
8
9
10
11
// In this example, we want to enable all annotation tools except the `IMAGE` tool.
List<AnnotationTool> enabledAnnotationTools = new ArrayList<>();
enabledAnnotationTools.addAll(Arrays.asList(AnnotationTool.values()));
enabledAnnotationTools.remove(AnnotationTool.IMAGE);

final PdfActivityConfiguration config =
    new PdfActivityConfiguration.Builder(context)
        // By default, all supported annotation tools are enabled.
        // You can selectively enable certain tools by providing them here.
        .enabledAnnotationTools(enabledAnnotationTools)
        .build();

Note: Certain AnnotationTools are enabled only when their underlying annotation type, AnnotationTool#toAnnotationType, is editable and annotation editing is enabled.

Control Whether or Not the Annotation Inspector Is Enabled

You can control whether or not the annotation inspector is enabled in PdfActivity via the #setAnnotationInspectorEnabled method in PdfActivityConfiguration.Builder. When the annotation inspector is disabled, the annotation picker icon is hidden from toolbars.