How do I Customize the Options in the Annotation Inspector?

Q: How do I Customize the Options in the Annotation Inspector?

A: To customize the options in the annotation inspector you’ll have to change the propertiesForAnnotations of PSPDFConfigurationBuilder with a dictionary containing a PSPDFAnnotationString specifying the annotation type as a key and the value for it should be an array of strings of the allowed properties.

Eample 1

The example below shows how to customize the Annotation Inspector options ink annotations:

Copy
1
2
3
4
5
6
7
8
9
10
11
let configuration = PSPDFConfiguration { builder in
    // Do not show color presets.
    var typesShowingColorPresets = builder.typesShowingColorPresets
    typesShowingColorPresets.remove(.ink)
    builder.typesShowingColorPresets = typesShowingColorPresets

    // Configure the properties for ink annotations to only show the color and blend mode setting in the annotation inspector.
    var properties = builder.propertiesForAnnotations
    properties[AnnotationString.ink] = [[AnnotationStyleKey.color, AnnotationStyleKey.blendMode]]
    builder.propertiesForAnnotations = properties
}

Eample 2

This example illustrates how to remove the font name and size options from the Annotation Inspector for free text annotations:

Copy
1
2
3
4
5
6
PSPDFConfiguration *configuration = [PSPDFConfiguration configurationWithBuilder:^(PSPDFConfigurationBuilder *builder) {
    // Configure the properties for free text annotations to hid the font name and size settings in the annotation inspector.
    NSMutableDictionary<PSPDFAnnotationString, id> *propertiesForAnnotations = [builder.propertiesForAnnotations mutableCopy];
    propertiesForAnnotations[PSPDFAnnotationStringFreeText] = @[@[PSPDFAnnotationStyleKeyTextAlignment], @[PSPDFAnnotationStyleKeyColor, PSPDFAnnotationStyleKeyFillColor, PSPDFAnnotationStyleKeyAlpha]];
    builder.propertiesForAnnotations = propertiesForAnnotations;
}];

Also be sure to check out the AnnotationInspectorBlendModeStampExample.swift and BlendModeMenuForMarkupAnnotationsExample.swift examples from our PSPDFCatalog example app.