PSPDFDrawView

Objective-C


@interface PSPDFDrawView
    : PSPDFContainerView <PSPDFAnnotationPresenting, PSPDFOverridable>

PSPDFDrawView allows drawing or erasing on top of a PDFPageView and handles new annotation creation.

Unless otherwise noted, boxed points need to be of type PSPDFDrawingPoint.

  • The DrawView delegate which is responsible for updating the Document with the changes made to the annotations.

    Declaration

    Objective-C

    @property (nonatomic, weak) id<PSPDFDrawViewDelegate> _Nullable delegate;

    Swift

    weak var delegate: DrawViewDelegate? { get set }
  • Current annotation type that is being created/edited.

    Declaration

    Objective-C

    @property (nonatomic) PSPDFAnnotationType annotationType;

    Swift

    var annotationType: Annotation.Kind { get set }
  • The selected tool variant. Applied to new annotations.

    Declaration

    Objective-C

    @property (nonatomic, nullable) PSPDFAnnotationVariantString annotationVariant;

    Swift

    var annotationVariant: Annotation.Variant? { get set }
  • Determines what effect touch events have. Defaults to PSPDFDrawViewInputModeDraw. PSPDFDrawViewInputModeErase only affects Ink annotations.

    Declaration

    Objective-C

    @property (nonatomic) PSPDFDrawViewInputMode inputMode;

    Swift

    var inputMode: DrawView.InputMode { get set }
  • The gesture recognizer used to detect drawings.

    Setting its allowedTouchTypes property can be used to limit the allowed types however the draw view may still ignore touches even if they are in the list of allowed types. This is used for Apple Pencil support.

    The default allowedTouchTypess are direct, pencil, and indirectPointer.

    See

    -[PSPDFAnnotationStateManager stylusMode]

    Declaration

    Objective-C

    @property (nonatomic, readonly) UIGestureRecognizer *_Nonnull drawGestureRecognizer;

    Swift

    var drawGestureRecognizer: UIGestureRecognizer { get }
  • Defines how ink annotations are created.

    This determines whether a new annotation is created when a stroke ends.

    See

    PDFConfiguration for details.

    Note

    The default value for this setting is read from the current active PDFConfiguration object.

    Declaration

    Objective-C

    @property (nonatomic) PSPDFDrawCreateMode drawCreateMode;

    Swift

    var drawCreateMode: DrawCreateMode { get set }
  • Enables natural drawing via tracking the pressure sensitivity of the points.

    See

    PDFConfiguration for details.

    Note

    The default value for this setting is read from the current active PDFConfiguration object.

    Declaration

    Objective-C

    @property (nonatomic) BOOL naturalDrawingEnabled;

    Swift

    var naturalDrawingEnabled: Bool { get set }
  • Enables the use of predictive touches. Defaults to NO. Enabling this for ink annotation improves the drawing experience.

    Declaration

    Objective-C

    @property (nonatomic) BOOL predictiveTouchesEnabled;

    Swift

    var predictiveTouchesEnabled: Bool { get set }
  • Used to compute approximate line widths during drawing. When a pageView is associated this will automatically be set to it’s scaleForPageView. Defaults to 1.

    Declaration

    Objective-C

    @property (nonatomic) CGFloat scale;

    Swift

    var scale: CGFloat { get set }
  • Draw view zoom scale, used for zoom dependent eraser sizing. When a pageView is associated this will automatically be set to it’s scrollView.zoomScale. Defaults to 1.

    Declaration

    Objective-C

    @property (nonatomic) CGFloat zoomScale;

    Swift

    var zoomScale: CGFloat { get set }
  • Current stroke color.

    Declaration

    Objective-C

    @property (nonatomic, nullable) UIColor *strokeColor;

    Swift

    var strokeColor: UIColor? { get set }
  • Current fill color.

    Declaration

    Objective-C

    @property (nonatomic, nullable) UIColor *fillColor;

    Swift

    var fillColor: UIColor? { get set }
  • Current line width.

    Declaration

    Objective-C

    @property (nonatomic) CGFloat lineWidth;

    Swift

    var lineWidth: CGFloat { get set }
  • Starting line end type for lines and polylines.

    Declaration

    Objective-C

    @property (nonatomic) PSPDFLineEndType lineEnd1;

    Swift

    var lineEnd1: AbstractLineAnnotation.EndType { get set }
  • Ending line end type for lines and polylines.

    Declaration

    Objective-C

    @property (nonatomic) PSPDFLineEndType lineEnd2;

    Swift

    var lineEnd2: AbstractLineAnnotation.EndType { get set }
  • The stroke dash pattern. Draws a solid line when nil (default).

    Declaration

    Objective-C

    @property (nonatomic, copy, nullable) NSArray<NSNumber *> *dashArray;

    Swift

    var dashArray: [NSNumber]? { get set }
  • The border effect style.

    Declaration

    Objective-C

    @property (nonatomic) PSPDFAnnotationBorderEffect borderEffect;

    Swift

    var borderEffect: Annotation.BorderEffect { get set }
  • The border effect intensity (if set to cloudy). A number describing the intensity of the effect, in the range 0 to 2. Default value: 0.

    Declaration

    Objective-C

    @property (nonatomic) CGFloat borderEffectIntensity;

    Swift

    var borderEffectIntensity: CGFloat { get set }
  • Defines a custom blend mode. Supported values include kCGBlendModeNormal to kCGBlendModeExclusion.

    Declaration

    Objective-C

    @property (nonatomic) CGBlendMode blendMode;

    Swift

    var blendMode: CGBlendMode { get set }
  • Guide color. Defaults to UIColor.pspdf_guideColor.

    Declaration

    Objective-C

    @property (nonatomic, nullable) UIColor *guideBorderColor;

    Swift

    var guideBorderColor: UIColor? { get set }
  • All annotations currently managed by the draw view.

    Declaration

    Objective-C

    @property (nonatomic, readonly) NSArray<PSPDFAnnotation *> *_Nonnull annotations;

    Swift

    var annotations: [Annotation] { get }
  • Adds the provided annotations to the draw view, making them available for editing.

    Note

    Currently only supports Ink annotations (to facilitate ink erasing).

    Declaration

    Objective-C

    - (void)updateForAnnotations:
        (nonnull NSArray<PSPDFInkAnnotation *> *)annotations;

    Swift

    func update(for annotations: [PSPDFInkAnnotation])
  • Clears all drawings, associated annotations and biometric data.

    Declaration

    Objective-C

    - (void)clear;

    Swift

    func clear()
  • Point sequences that are in this draw view. An array of arrays holding NSValues boxing PSPDFDrawingPoints.

    If this draw view is attached to a PSPDFPageView then the points are in the coordinate space of the PDF page that the page view is displaying, so the origin is in the bottom-left. Use PSPDFPageView.pdfCoordinateSpace to convert these points to the coordinate space of the draw view. Alternatively, if this draw view is not attached to a PSPDFPageView then the points are in the coordinate space of the draw view but scaled by scale, so the origin is in the top-left.

    Point sequences is an empty array until endDrawing is invoked, unless the view was created using an existing annotation.

    Declaration

    Objective-C

    @property (nonatomic, readonly) NS_REFINED_FOR_SWIFT NSArray<NSArray<NSValue *> *> *pointSequences;
  • An array of boxed floating point values. Representing the intensity of each touch in the order they occurred.

    Includes the same number of objects as timePoints and touchRadii.

    Note

    Predicted touches are not included.

    Declaration

    Objective-C

    @property (nonatomic, readonly) NSArray<NSNumber *> *_Nonnull pressureList;

    Swift

    var pressureList: [NSNumber] { get }
  • An array of boxed NSTimeIntervals representing the timestamp of each touch in the order they occurred.

    Includes the same number of objects as pressureList and touchRadii.

    The times are in seconds relative to the first touch, so the first value in this array will be zero. Forwards in time is positive, so all values after the first will be positive.

    Note

    Predicted touches are not included.

    Declaration

    Objective-C

    @property (nonatomic, readonly) NSArray<NSNumber *> *_Nonnull timePoints;

    Swift

    var timePoints: [NSNumber] { get }
  • An array of boxed floating point values representing the radius of each touch (or the altitude if an Apple Pencil was used) in the order the touches occurred.

    Includes the same number of objects as pressureList and timePoints.

    Note

    Predicted touches are not included.

    Declaration

    Objective-C

    @property (nonatomic, readonly) NSArray<NSNumber *> *_Nonnull touchRadii;

    Swift

    var touchRadii: [NSNumber] { get }
  • The device that was used to create the signature.

    When signing a document with the default UI, this is set to the last used input method of the created ink signature.

    Declaration

    Objective-C

    @property (nonatomic, readonly) PSPDFDrawInputMethod inputMethod;

    Swift

    var inputMethod: DrawInputMethod { get }
  • Starts a drawing operation at the given point. The inputMode needs to be set to PSPDFDrawViewInputModeDraw.

    Declaration

    Objective-C

    - (void)startDrawingAtPoint:(PSPDFDrawingPoint)location;

    Swift

    func startDrawing(at location: DrawingPoint)
  • Continues a drawing operation at with the given points and optional predicted points. The inputMode needs to be PSPDFDrawViewInputModeDraw.

    Declaration

    Objective-C

    - (void)continueDrawingAtPoints:(nonnull NSArray<NSValue *> *)locations
                    predictedPoints:
                        (nonnull NSArray<NSValue *> *)predictedLocations;

    Swift

    func continueDrawing(atPoints locations: [NSValue], predictedPoints predictedLocations: [NSValue])

    Parameters

    locations

    Boxed PSPDFDrawingPoint objects.

    predictedLocations

    Boxed PSPDFDrawingPoint objects.

  • Commits the drawing. The inputMode needs to be set to PSPDFDrawViewInputModeDraw.

    Declaration

    Objective-C

    - (void)endDrawing;

    Swift

    func endDrawing()
  • Cancels the drawing. The inputMode needs to be set to PSPDFDrawViewInputModeDraw.

    Declaration

    Objective-C

    - (void)cancelDrawing;

    Swift

    func cancelDrawing()
  • Defines how aggressively shapes snap to square aspect ratio. Defaults to 20. Set to zero to disable guides.

    Declaration

    Objective-C

    @property (nonatomic) CGFloat guideSnapAllowance;

    Swift

    var guideSnapAllowance: CGFloat { get set }
  • Performs an erase at the given locations. Boxed PSPDFDrawingPoint objects. The inputMode needs to be set to PSPDFDrawViewInputModeErase.

    Declaration

    Objective-C

    - (void)eraseAt:(nonnull NSArray<NSValue *> *)locations;

    Swift

    func erase(at locations: [NSValue])
  • Commits the erase operation. The inputMode needs to be set to PSPDFDrawViewInputModeErase.

    Declaration

    Objective-C

    - (void)endErase;

    Swift

    func endErase()
  • Cancels the erasing. The inputMode needs to be set to PSPDFDrawViewInputModeErase.

    Note

    Discards any erasing performed after the last endErase call.

    Declaration

    Objective-C

    - (void)cancelErase;

    Swift

    func cancelErase()
  • Point sequences that are in this draw view. An array of arrays holding DrawingPoints.

    If this draw view is attached to a PDFPageView then the points are in the coordinate space of the PDF page that the page view is displaying, so the origin is in the bottom-left. Use PDFPageView.pdfCoordinateSpace to convert these points to the coordinate space of the draw view. Alternatively, if this draw view is not attached to a PDFPageView then the points are in the coordinate space of the draw view but scaled by scale, so the origin is in the top-left.

    Point sequences is an empty array until endDrawing is invoked, unless the view was created using an existing annotation.

    Declaration

    Swift

    var pointSequences: [[DrawingPoint]] { get }
  • This publisher fires whenever the drawView’s pointSequences or drawLayers change.

    Declaration

    Swift

    var pointSequencesPublisher: AnyPublisher<[[DrawingPoint]], Never> { get }