PSPDFInkAnnotation

Objective-C


@interface PSPDFInkAnnotation : PSPDFAbstractShapeAnnotation <PSPDFOverridable>

Swift

class InkAnnotation : AbstractShapeAnnotation, Overridable

An ink annotation for freehand drawing or writing.

This annotation type is referred to as Drawing in the PSPDFKit UI. It allows the user to add one or more strokes on top of PDF content.

The lines are automatically scaled when the boundingBox is changed, and the boundingBox is updated when the lines are changed to enclose the new points.

See

The annotation tool is activated in the UI by PSPDFAnnotationStateManager and PSPDFAnnotationToolbar. The drawing interaction is handled by PSPDFDrawView. Some drawing-related behaviors can be set in the PSPDFConfiguration, such as with its drawCreateMode property, which controls whether a new ink annotation is created after each stroke).
  • Designated initializer.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithLines:
        (nonnull NSArray<NSArray<NSValue *> *> *)lines;

    Swift

    init(__lines lines: [[NSValue]])

    Parameters

    lines

    Array of arrays of boxed PSPDFDrawingPoint.

  • The lines (or strokes) of the ink annotation.

    This is an array of arrays of boxed PSPDFDrawingPoint. Each array represents a single line/stroke.

    Example:

    annotation.lines = @[@[
        @(PSPDFDrawingPointMake(CGPointMake(100,100), 0.5)),
        @(PSPDFDrawingPointMake(CGPointMake(100,200), 0.5)),
        @(PSPDFDrawingPointMake(CGPointMake(150,300), 0.5)),
    ]];
    

    The intensity values determine the line thickness for natural drawing.

    This property is equivalent to the pointSequences property inherited from PSPDFAbstractShapeAnnotation. Setting either property also sets the other.

    @warning: After setting lines, boundingBox will be automatically recalculated. Additionally, the lines will be scaled when the boundingBox changed.

    Declaration

    Objective-C

    @property (atomic, copy, readwrite, null_resettable)
        NSArray<NSArray<NSValue *> *> *lines;
  • The UIBezierPath will be dynamically created from the lines array.

    Declaration

    Objective-C

    @property (atomic, readonly) UIBezierPath *_Nonnull bezierPath;

    Swift

    var bezierPath: UIBezierPath { get }
  • Returns true if lines doesn’t contain any points.

    Declaration

    Objective-C

    @property (atomic, readonly, getter=isEmpty) BOOL empty;

    Swift

    var isEmpty: Bool { get }
  • Whether this ink annotation uses the natural drawing style.

    This is a proprietary extension — other viewers will not be able to detect this.

    See

    Whether natural drawing is enabled for new annotations can be set using the PSPDFConfiguration properties naturalDrawingAnnotationEnabled and naturalSignatureDrawingEnabled.

    Declaration

    Objective-C

    @property (atomic, assign, unsafe_unretained, readwrite)
        BOOL naturalDrawingEnabled;

    Swift

    var naturalDrawingEnabled: Bool { get set }
  • Whether this ink annotation is a PSPDFKit signature.

    This is a proprietary extension - other viewer will not be able to detect this.

    Signatures are created using the tool PSPDFAnnotationStringSignature.

    Declaration

    Objective-C

    @property (atomic, assign, unsafe_unretained, readwrite) BOOL isSignature;

    Swift

    var isSignature: Bool { get set }
  • By default, setting the boundingBox will transform all points in the lines array. Use this setter to manually change the boundingBox without changing lines.

    Declaration

    Objective-C

    - (void)setBoundingBox:(CGRect)boundingBox transformLines:(BOOL)transformLines;

    Swift

    func setBoundingBox(_ boundingBox: CGRect, transformLines: Bool)
  • Generate new line array by applying transform. This is used internally when boundingBox is changed.

    Declaration

    Objective-C

    - (nonnull NSArray *)copyLinesByApplyingTransform:(CGAffineTransform)transform;

    Swift

    func copyLines(byApplying transform: CGAffineTransform) -> [Any]

    Return Value

    Either an NSArray<PSPDFPointArray *> or an NSArray<NSArray<NSValue *> *>.

  • Undocumented

    Declaration

    Swift

    public convenience init(lines: [[DrawingPoint]])
  • Undocumented

    Declaration

    Swift

    public var lines: [[DrawingPoint]]? { get set }