PTAnnotEditTool
@interface PTAnnotEditTool
: PTTool <PTSelectionRectViewDelegate,
UIPopoverPresentationControllerDelegate, UITextViewDelegate,
PTAnnotStyleViewControllerDelegate>
The PTAnnotEditTool is used to change the properties, position and size of annotations. It also handles link annotations.
-
The transparent parent view that holds the shaded annotation selection rectangle and resize handles.
Declaration
Objective-C
@property (nonatomic, strong, readonly) PTSelectionRectContainerView *_Nonnull selectionRectContainerView;
Swift
var selectionRectContainerView: PTSelectionRectContainerView { get }
-
When the user is resizing the annotation, the resize handle that is currently in use.
Declaration
Objective-C
@property (nonatomic, weak, readonly) UIView *_Nullable touchedSelectWidget;
Swift
weak var touchedSelectWidget: UIView? { get }
-
When true, only corner resize handles are available, and the aspect ratio will be maintained. Default is true for stamp and signatures annotations, false for others.
Declaration
Objective-C
@property (nonatomic) BOOL maintainAspectRatio;
Swift
var maintainAspectRatio: Bool { get set }
-
When enabled, a visual guide is shown while resizing an annotation to indicate the line along which the annotation’s original aspect ratio is maintained.
This property is enabled by default.
Declaration
Objective-C
@property (nonatomic, assign, unsafe_unretained, readwrite, getter=isAspectRatioGuideEnabled) BOOL aspectRatioGuideEnabled;
Swift
var isAspectRatioGuideEnabled: Bool { get set }
-
Whether to scale the contents of the selected annotation while maintaining the aspect ratio.
The default value of this property is
NO
.Declaration
Objective-C
@property (nonatomic) BOOL scaleAnnotationContents;
Swift
var scaleAnnotationContents: Bool { get set }
-
The minimum size that annotations can be resized to, expressed in page space. The default value is 0.
Declaration
Objective-C
@property (nonatomic) CGFloat minimumAnnotationSize;
Swift
var minimumAnnotationSize: CGFloat { get set }
-
The maximum size that annotations can be resized to, expressed in page space. By default, there is no maximum size limit.
Declaration
Objective-C
@property (nonatomic) CGFloat maximumAnnotationSize;
Swift
var maximumAnnotationSize: CGFloat { get set }
-
The
PTAnnotEditTool
‘s delegate object.Declaration
Objective-C
@property (nonatomic, weak, nullable) id<PTAnnotEditToolDelegate> delegate;
Swift
weak var delegate: (any PTAnnotEditToolDelegate)? { get set }
-
Selects the specified annotation.
Declaration
Objective-C
- (BOOL)selectAnnotation:(nonnull PTAnnot *)annotation onPageNumber:(unsigned int)pageNumber;
Swift
func selectAnnotation(_ annotation: PTAnnot, onPageNumber pageNumber: UInt32) -> Bool
Parameters
annotation
the annotation to select
pageNumber
the page number of the annotation
Return Value
YES
if the annotation was selected,NO
otherwise. -
Selects the specified annotation and optionally shows the annotation selection menu.
Declaration
Objective-C
- (BOOL)selectAnnotation:(nonnull PTAnnot *)annotation onPageNumber:(unsigned int)pageNumber showMenu:(BOOL)showMenu;
Swift
func selectAnnotation(_ annotation: PTAnnot, onPageNumber pageNumber: UInt32, showMenu: Bool) -> Bool
Parameters
annotation
the annotation to select
pageNumber
the page number of the annotation
showMenu
whether the annotation selection menu should be shown
Return Value
YES
if the annotation was selected,NO
otherwise. -
Sets the annotation’s border thickness.
Declaration
Objective-C
- (void)setAnnotationBorder:(float)thickness;
Swift
func setAnnotationBorder(_ thickness: Float)
-
Selects the annotation where the user tapped or long pressed. If it is a link, the link will be followed.
Declaration
Objective-C
- (BOOL)makeNewAnnotationSelection: (nonnull UIGestureRecognizer *)gestureRecognizer;
Swift
func makeNewAnnotationSelection(_ gestureRecognizer: UIGestureRecognizer) -> Bool
-
Deselects the currently selected annotation
currentAnnotation
.Declaration
Objective-C
- (void)deselectAnnotation;
Swift
func deselectAnnotation()
-
Sets the
currentAnnotation
‘s opacity.Declaration
Objective-C
- (void)setAnnotationOpacity:(double)opacity;
Swift
func setAnnotationOpacity(_ opacity: Double)
-
Action to flatten the currently selected annotations.
Declaration
Objective-C
- (void)flattenSelectedAnnotations:(nonnull id)sender;
Swift
func flattenSelectedAnnotations(_ sender: Any)
-
Action to copy the currently selected annotations to the pasteboard.
Declaration
Objective-C
- (void)copySelectedAnnotations:(nonnull id)sender;
Swift
func copySelectedAnnotations(_ sender: Any)
-
Allows the user to set the
currentAnnotation
‘s stroke color.Declaration
Objective-C
- (void)editSelectedAnnotationStrokeColor;
Swift
func editSelectedAnnotationStrokeColor()
-
Allows the user to set the
currentAnnotation
‘s border thickness.Declaration
Objective-C
- (void)editSelectedAnnotationBorder;
Swift
func editSelectedAnnotationBorder()
-
Allows the user to set the
currentAnnotation
‘s opacity.Declaration
Objective-C
- (void)editSelectedAnnotationOpacity;
Swift
func editSelectedAnnotationOpacity()
-
Edits the currently selected
PTFreeText
annotation’s contents.Declaration
Objective-C
- (void)editSelectedAnnotationFreeText;
Swift
func editSelectedAnnotationFreeText()
-
Allows the user to edit the
currentAnnotation
‘s style.Declaration
Objective-C
- (void)editSelectedAnnotationStyle;
Swift
func editSelectedAnnotationStyle()
-
Commits the user-selected style for the
currentAnnotation
.Declaration
Objective-C
- (void)commitSelectedAnnotationStyle;
Swift
func commitSelectedAnnotationStyle()
-
Allows the user to edit the
currentAnnotation
‘s date. This method only functions correctly if thecurrentAnnotation
has anextendedAnnotType
ofPTExtendedAnnotTypeDateText
.Declaration
Objective-C
- (void)editSelectedDateTextAnnotationDate;
Swift
func editSelectedDateTextAnnotationDate()
-
Action method to export and save the currently selected file attachment annotation to disk.
Declaration
Objective-C
- (void)saveFileAttachmentAnnotation:(nullable id)sender;
Swift
func saveFileAttachmentAnnotation(_ sender: Any?)
-
This method creates a new annotation group from the annotations specified in the method’s parameters.
Declaration
Objective-C
+ (void) createAnnotationGroupWithToolManager:(nonnull PTToolManager *)toolManager primaryAnnotation:(nonnull PTAnnot *)primaryAnnotation annotationsInGroup: (nonnull NSArray<PTAnnot *> *)annotationsInGroup pageNumber:(int)pageNumber;
Swift
class func createAnnotationGroup(with toolManager: PTToolManager, primaryAnnotation: PTAnnot, annotationsInGroup: [PTAnnot], pageNumber: Int32)
Parameters
toolManager
The tool manager used to perform the annotation grouping.
primaryAnnotation
The primary or main annotation of the annotation group.
annotationsInGroup
The annotations to add to the group. This parameter should not include the primary annotation.
pageNumber
The page number of the annotations.
-
This method ungroups the annotations specified.
Declaration
Objective-C
+ (void)ungroupAnnotationsWithToolManager:(nonnull PTToolManager *)toolManager annotationsInGroup: (nonnull NSArray<PTAnnot *> *)annotationsInGroup pageNumber:(int)pageNumber;
Swift
class func ungroupAnnotations(with toolManager: PTToolManager, annotationsInGroup: [PTAnnot], pageNumber: Int32)
Parameters
toolManager
The tool manager used to perform the annotation grouping.
annotationsInGroup
The annotations to ungroup.
pageNumber
The page number of the annotations.
-
This method returns all annotations in this group if the annotation passed in is in an annotation group.
Declaration
Objective-C
+ (nullable NSArray<PTAnnot *> *) getAnnotationsInGroupForAnnotation:(nonnull PTAnnot *)annotation pdfViewCtrl:(nonnull PTPDFViewCtrl *)pdfViewCtrl;
Swift
class func getAnnotationsInGroup(forAnnotation annotation: PTAnnot, pdfViewCtrl: PTPDFViewCtrl) -> [PTAnnot]?
Parameters
annotation
The annotation to check for a group.
pdfViewCtrl
The
PTPDFViewCtrl
object. -
This method returns the primary or main annotation in a group if the array of annotations passed in are grouped..
Declaration
Objective-C
+ (nullable PTAnnot *) getPrimaryAnnotationInGroup:(nonnull NSArray<PTAnnot *> *)annotations pdfViewCtrl:(nonnull PTPDFViewCtrl *)pdfViewCtrl;
Swift
class func getPrimaryAnnotation(inGroup annotations: [PTAnnot], pdfViewCtrl: PTPDFViewCtrl) -> PTAnnot?
Parameters
annotations
The list of annotations to check for a group and find the primary annotation.
pdfViewCtrl
The
PTPDFViewCtrl
object.
-
Redacts all pending redactions in the document.
Declaration
Objective-C
- (void)redactDoc;
Swift
func redactDoc()
-
Redacts the selected redactions in the document.
Declaration
Objective-C
- (void)applySelectedRedaction;
Swift
func applySelectedRedaction()
-
Used to allow the toolmanager that the user wishes to open a file attachment
Declaration
Objective-C
- (void)handleFileAttachment:(nonnull PTFileAttachment *)fileAttachment onPageNumber:(unsigned long)pageNumber;
Swift
func handle(_ fileAttachment: PTFileAttachment, onPageNumber pageNumber: UInt)
Parameters
fileAttachment
The file attachment.
pageNumber
The page number that the annotation is on.
-
Override point for when the user has requested to save the file attchment
Declaration
Objective-C
- (void)saveFileAttachment:(nonnull PTFileAttachment *)fileAttachment onPageNumber:(unsigned long)pageNumber;
Swift
func save(_ fileAttachment: PTFileAttachment, onPageNumber pageNumber: UInt)
Parameters
fileAttachment
The file attachment to be saved.
pageNumber
The page number that the annotation is on.
-
Returns a tight page bounding box around the annotation.
The default implementation of this method returns the value of
-[PTAnnot GetRect]
.Declaration
Parameters
annot
the annotation
Return Value
a tight page bounding box around the annotation
-
Returns a tight screen bounding box around the annotation.
The default implementation of this method returns the value of
-[PTAnnot GetRect]
, in screen coordinates.Declaration
Objective-C
- (CGRect)tightScreenBoundingBoxForAnnot:(nonnull PTAnnot *)annot onPageNumber:(int)pageNumber;
Swift
func tightScreenBoundingBox(for annot: PTAnnot, onPageNumber pageNumber: Int32) -> CGRect
Parameters
annot
the annotation
pageNumber
the annotation’s page number
Return Value
a tight screen bounding box around the annotation
-
Bounds a point in screen space to the current page’s crop box.
Declaration
Objective-C
- (CGPoint)boundPointToPage:(CGPoint)point;
Swift
func boundPoint(toPage point: CGPoint) -> CGPoint
Parameters
point
a point in screen space
Return Value
a point in screen space, guaranteed to be within the page.
-
Ensures that a rect in page space is within the page it’s on.
Declaration
Parameters
pageRect
the rect in page space
pageNumber
the page number
Return Value
the new rectangle, guaranteed to be within the page.
-
Ensures that a new rect’s position lies within the page it’s on.
Declaration
Objective-C
- (CGRect)boundRectToPage:(CGRect)annotRect isResizing:(BOOL)resizing;
Swift
func boundRect(toPage annotRect: CGRect, isResizing resizing: Bool) -> CGRect
Parameters
annotRect
the annotation’s proposed new rectangle.
resizing
if the annotation was changed via a resize (as opposed to a move)
Return Value
the new rectangle, guaranteed to be within the page.
-
The frame for editing the currently selected free text annotation, in the
selectionRectContainerView
‘s local coordinate system.Declaration
Objective-C
- (CGRect)frameForEditingFreeTextAnnotation;
Swift
func frameForEditingFreeTextAnnotation() -> CGRect