---
title: "Magic Ink tool — Draw and detect annotation shapes in PDFs | Nutrient"
canonical_url: "https://www.nutrient.io/guides/ios/annotations/magic-ink/"
md_url: "https://www.nutrient.io/guides/ios/annotations/magic-ink.md"
last_updated: "2026-05-23T00:08:18.099Z"
description: "Explore the new Magic Ink tool in Nutrient iOS SDK, enabling seamless PDF annotations with shape recognition for efficient document editing."
---

# Magic Ink tool: Draw and detect annotation shapes

The Magic Ink tool allows users to draw on a PDF like with the regular ink tool, but after drawing finishes, Nutrient will attempt to detect the shape that was drawn. If a shape is detected with high enough confidence, the drawn ink annotation will be replaced with a shape annotation. If not, the drawing is left untouched. This allows for a faster method of annotating your documents without needing to switch between different tools.

## Adding the Magic Ink tool

The Magic Ink tool is defined as a variant of the ink tool. This tool is now included in the default presets for the annotation toolbar. If you customize the annotation toolbar and would like to add the Magic Ink tool, you can use [`Annotation.Variant.inkMagic`](https://www.nutrient.io/api/ios/documentation/pspdfkit/annotation/variant-swift.struct/inkmagic) in the toolbar configuration as shown in our [annotation toolbar customization guide](https://www.nutrient.io/guides/ios/customizing-the-interface/customizing-the-annotation-toolbar.md):

### SWIFT

```swift

let configuration = AnnotationToolConfiguration(annotationGroups: [
    AnnotationToolConfiguration.ToolGroup(items: [
        AnnotationToolConfiguration.ToolItem(type:.ink, variant:.inkMagic, configurationBlock: AnnotationToolConfiguration.ToolItem.inkConfigurationBlock())
        ])
])

```

### OBJECTIVE-C

```objc

PSPDFAnnotationToolbarConfiguration *configuration = [[PSPDFAnnotationToolbarConfiguration alloc] initWithAnnotationGroups:@[
    [PSPDFAnnotationGroup groupWithItems:@[
        [PSPDFAnnotationGroupItem itemWithType:PSPDFAnnotationStringInk variant:PSPDFAnnotationStringInkMagic configurationBlock:[PSPDFAnnotationGroupItem inkConfigurationBlock]]]
    ]
]];

```

The [`AnnotationToolConfiguration.ToolItem.inkConfigurationBlock()`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/pspdfkit/annotationtoolconfiguration/toolitem/inkconfigurationblock()) automatically selects the correct image for the Magic Ink variant.

## Supported transformations

We support transformations of the following drawings into their corresponding shape annotations:

- Circle ([`CircleAnnotation`](https://www.nutrient.io/api/ios/documentation/pspdfkit/circleannotation))

- Rectangle ([`SquareAnnotation`](https://www.nutrient.io/api/ios/documentation/pspdfkit/squareannotation))

- Arrow ([`LineAnnotation`](https://www.nutrient.io/api/ios/documentation/pspdfkit/lineannotation) with the [`lineEnd`](https://www.nutrient.io/api/ios/documentation/pspdfkit/abstractlineannotation/lineend1) set to [`.openArrow`](https://www.nutrient.io/api/ios/documentation/pspdfkit/abstractlineannotation/endtype/openarrow))

- Line ([`LineAnnotation`](https://www.nutrient.io/api/ios/documentation/pspdfkit/lineannotation) without a [`lineEnd`](https://www.nutrient.io/api/ios/documentation/pspdfkit/abstractlineannotation/lineend1))

## Controlling replacement threshold

If you’d like to change the threshold at which Nutrient replaces the ink annotation with a shape annotation, this can be controlled using [`PDFConfiguration`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/pdfconfiguration)’s [`magicInkReplacementThreshold`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/pdfconfiguration/magicinkreplacementthreshold) property.

This property should always be set to a value between 0 (always replace) and 100 (replace only for perfect matches).
---

## Related pages

- [How to rotate annotations on iOS](/guides/ios/annotations/annotation-rotation.md)
- [PDF annotation library for iOS](/guides/ios/annotations/introduction-to-annotations.md)
- [Flatten annotations on iOS](/guides/ios/annotations/flatten.md)
- [Review and reply to annotations on iOS](/guides/ios/annotations/replies.md)

