Annotation-Editing Configuration

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

Control which annotation types can be edited

PSPDFKit enables editing of all supported annotation types by default. You can disable editing for all annotation types via the #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 annotation creation toolbar via #enabledAnnotationTools. Passing null or 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 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 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 AnnotationTool is enabled only when its underlying annotation type AnnotationTool#toAnnotationType is editable and annotation editing is enabled.

Control whether annotation inspector is enabled

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