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 byPSPDFAnnotationStateManager
and AnnotationToolbar
.
The drawing interaction is handled by PSPDFDrawView
. Some drawing-related behaviors
can be set in the PDFConfiguration
, 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;
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 fromPSPDFAbstractShapeAnnotation
. Setting either property also sets the other.@warning: After setting lines,
boundingBox
will be automatically recalculated. Additionally, the lines will be scaled when theboundingBox
changed.Declaration
Objective-C
@property (copy, null_resettable) NSArray<NSArray<NSValue *> *> *lines;
-
The
UIBezierPath
will be dynamically created from the lines array.Declaration
Objective-C
@property (readonly) NSBezierPath *_Nonnull bezierPath;
Swift
var bezierPath: NSBezierPath { get }
-
Returns
true
iflines
doesn’t contain any points.Declaration
Objective-C
@property (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 thePDFConfiguration
propertiesnaturalDrawingAnnotationEnabled
andnaturalSignatureDrawingEnabled
.Declaration
Objective-C
@property 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
Annotation.Tool.signature
.Declaration
Objective-C
@property 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 theboundingBox
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 anNSArray<NSArray<NSValue *> *>
. -
Undocumented
Declaration
Swift
public convenience init(lines: [[DrawingPoint]])
-
Undocumented
Declaration
Swift
public var lines: [[DrawingPoint]]? { get set }