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 PDFConfigurationBuilder with a dictionary containing a Annotation.Tool 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:

let configuration = PDFConfiguration {
    // Do not show color presets.
    var typesShowingColorPresets = $0.typesShowingColorPresets
    typesShowingColorPresets.remove(.ink)
    $0.typesShowingColorPresets = typesShowingColorPresets

    // Configure the properties for ink annotations to only show the color and blend mode setting in the annotation inspector.
    var properties = $0.propertiesForAnnotations
    properties[.ink] = [[AnnotationStyle.Key.color, AnnotationStyle.Key.blendMode]]
    $0.propertiesForAnnotations = properties
}
PSPDFConfiguration *configuration = [PSPDFConfiguration configurationWithBuilder:^(PSPDFConfigurationBuilder *builder) {
    // Do not show color presets.
    PSPDFAnnotationType typesShowingColorPresetes = builder.typesShowingColorPresets;
    typesShowingColorPresetes = typesShowingColorPresetes &~ PSPDFAnnotationTypeInk;
    builder.typesShowingColorPresets = typesShowingColorPresetes;

    // Configure the properties for ink annotations to only show the color and blend mode setting in the annotation inspector.
    NSMutableDictionary<PSPDFAnnotationString, id> *propertiesForAnnotations = [builder.propertiesForAnnotations mutableCopy];
    propertiesForAnnotations[PSPDFAnnotationStringInk] = @[@[PSPDFAnnotationStyleKeyColor, PSPDFAnnotationStyleKeyBlendMode]];
    builder.propertiesForAnnotations = propertiesForAnnotations;
}];

Eample 2

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

let configuration = PDFConfiguration {
    // Configure the properties for free text annotations to hid the font name and size settings in the annotation inspector.
    var properties = $0.propertiesForAnnotations
    properties[.freeText] = [[AnnotationStyle.Key.textAlignment, AnnotationStyle.Key.color, AnnotationStyle.Key.fillColor, AnnotationStyle.Key.alpha]]
    $0.propertiesForAnnotations = properties
}
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 PSPDFKit Catalog example app.