PTAnnotationManager
@interface PTAnnotationManager : NSObject <PTOverridable>
Instances of the PTAnnotationManager class manage the annotations in a PTPDFViewCtrl and
maintain annotation model objects that correspond to the PDF annotations.
-
Initializes a newly created
PTAnnotationManagerwith the givenPTPDFViewCtrlinstance.Declaration
Objective-C
- (nonnull instancetype)initWithPDFViewCtrl: (nonnull PTPDFViewCtrl *)pdfViewCtrl;Swift
init(pdfViewCtrl: PTPDFViewCtrl)Parameters
pdfViewCtrlThe
PTPDFViewCtrlthat this annotation manager will coordinate with.Return Value
an initialized
PTAnnotationManagerinstance -
Initializes a newly created
PTAnnotationManagerwith the givenPTToolManagerinstance.Declaration
Objective-C
- (nonnull instancetype)initWithToolManager: (nonnull PTToolManager *)toolManager;Swift
convenience init(toolManager: PTToolManager)Parameters
toolManagerThe
PTToolManagerthat this annotation manager will coordinate with.Return Value
an initialized
PTAnnotationManagerinstance -
Undocumented
Declaration
Objective-C
- (instancetype)init NS_UNAVAILABLE; -
The
PTPDFViewCtrlinstance that this annotation manager coordinates with.Declaration
Objective-C
@property (nonatomic, strong) PTPDFViewCtrl *_Nonnull pdfViewCtrl;Swift
var pdfViewCtrl: PTPDFViewCtrl { get set } -
The
PTToolManagerinstance that this annotation manager coordinates with.Declaration
Objective-C
@property (nonatomic, weak, nullable) PTToolManager *toolManager;Swift
weak var toolManager: PTToolManager? { get set } -
The
PTUndoRedoManagerinstance that this annotation manager coordinates with.Declaration
Objective-C
@property (nonatomic, strong, nullable) PTUndoRedoManager *undoRedoManager;Swift
var undoRedoManager: PTUndoRedoManager? { get set } -
The identifier of the current annotation author.
Declaration
Objective-C
@property (nonatomic, copy, nullable) NSString *annotationAuthorIdentifier;Swift
var annotationAuthorIdentifier: String? { get set } -
Controls whether annotations made by other authors can be edited by the current author, specified by the
annotationAuthorIdentifierproperty.When the value of this property is set to
PTAnnotationModeEditOwn, the annotation manager will also automatically enable thePTToolManager.annotationAuthorCheckEnabledproperty on the currenttoolManager.The default value of this property is
PTAnnotationModeEditAll.Declaration
Objective-C
@property (nonatomic) PTAnnotationEditMode annotationEditMode;Swift
var annotationEditMode: PTAnnotationManager.AnnotationEditMode { get set } -
Finds the annotation on the specified page number with a matching annotation identifier.
Note
In Swift, this method is imported as a throwing function.
Declaration
Objective-C
- (nullable PTAnnot *) findAnnotationWithIdentifier:(nonnull NSString *)annotationIdentifier onPageNumber:(int)pageNumber withError:(out NSError *_Nullable *_Nullable)error;Swift
func findAnnotation(withIdentifier annotationIdentifier: String, onPageNumber pageNumber: Int32) throws -> PTAnnotParameters
annotationIdentifierThe identifier of the annotation to be found
pageNumberthe PDF page number to search for the annotation
errorOn input, a pointer to an error object. If an error occurs , this pointer is set to an actual error object containing the error information. You may specify
nilfor this parameter if you do not want the error information.Return Value
the matching annotation, or
nilif the annotation could not be found. If an error occurs, thennilwill be returned and theerrorparameter will contain the error information. -
Returns whether the specified annotation is editable by the given author.
Declaration
Parameters
annotationthe annotation that will be edited
documentthe document containing the annotation
otherAnnotationAuthorIdentifierthe identifier of the author editing the annotation
Return Value
YESif the annotation can be edited by the given author,NOotherwise -
Returns whether the specified annotation, with the specified author identifier, is editable by the given author.
Declaration
Objective-C
- (BOOL)isAnnotation:(nonnull PTAnnot *)annotation withAuthorIdentifier: (nonnull NSString *)annotationAuthorIdentifier editableByAuthorWithIdentifier: (nonnull NSString *)otherAnnotationAuthorIdentifier;Swift
func isAnnotation(_ annotation: PTAnnot, withAuthorIdentifier annotationAuthorIdentifier: String, editableByAuthorWithIdentifier otherAnnotationAuthorIdentifier: String) -> BoolParameters
annotationthe annotation that will be edited
annotationAuthorIdentifierthe identifier of the annotation’s author
otherAnnotationAuthorIdentifierthe identifier of the author editing the annotation
Return Value
YESif the annotation can be edited by the given author,NOotherwise -
Returns whether an annotation with the specified annotation author identifier is editable by the given author.
Declaration
Objective-C
- (BOOL)isAnnotationWithAuthorIdentifier: (nonnull NSString *)annotationAuthorIdentifier editableByAuthorWithIdentifier: (nonnull NSString *)otherAnnotationAuthorIdentifier;Swift
func isAnnotation(withAuthorIdentifier annotationAuthorIdentifier: String, editableByAuthorWithIdentifier otherAnnotationAuthorIdentifier: String) -> BoolParameters
annotationAuthorIdentifierthe identifier of the annotation’s author
otherAnnotationAuthorIdentifierthe identifier of the author editing the annotation
Return Value
YESif the annotation can be edited by the given author,NOotherwise -
Generates and sets a new unique identifier for the specified annotation.
Note
This method acquires a write-lock on the
pdfViewCtrl.Declaration
Objective-C
- (void)generateIdentifierForAnnotation:(nonnull PTAnnot *)annotation;Swift
func generateIdentifier(forAnnotation annotation: PTAnnot)Parameters
annotationThe annotation for which to generate and set a new unique identifier
-
Updates the modification date for the specified annotation to the current date and time.
Note
This method acquires a write-lock on the
pdfViewCtrl.Declaration
Objective-C
- (void)updateModificationDateForAnnotation:(nonnull PTAnnot *)annotation;Swift
func updateModificationDate(forAnnotation annotation: PTAnnot)Parameters
annotationThe annotation for which to update the modification date
-
Sets the author of the specified annotation.
Declaration
Objective-C
- (void)setAuthorForAnnotation:(nonnull PTAnnot *)annotation authorIdentifier:(nonnull NSString *)authorIdentifier;Swift
func setAuthorForAnnotation(_ annotation: PTAnnot, authorIdentifier: String)Parameters
annotationThe annotation for which to set the author
authorIdentifierThe identifier of the author
-
Sets the display name for the annotation author with the specified identifier.
Declaration
Objective-C
- (void)setAuthorName:(nonnull NSString *)authorName forIdentifier:(nonnull NSString *)authorIdentifier completion: (nonnull void (^)(BOOL, NSError *_Nullable))completionHandler;Swift
func setAuthorName(_ authorName: String, forIdentifier authorIdentifier: String) async throws -> BoolParameters
authorNameThe name to display for the author
authorIdentifierThe identifier of the annotation author
completionHandlerA block that will be invoked when the operation has completed. If an error occurs then the
successparameter isNOand theerrorparameter contains the error information. -
Returns the name of the annotation author with the specified identifier.
Note
In Swift, this method is imported as a throwing function.
Declaration
Objective-C
- (nullable NSString *) authorNameForIdentifier:(nonnull NSString *)authorIdentifier error:(out NSError *_Nullable *_Nullable)error;Swift
func authorName(forIdentifier authorIdentifier: String) throws -> StringParameters
authorIdentifierThe identifier of the annotation author
errorOn input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify
nilfor this parameter if you do not want the error information.Return Value
the name of the annotation author, or
nilif an error occurred
-
Removes all of the PDF annotations on the specified PDF page in the current document.
Note
In Swift, this method is imported as a throwing function.
Declaration
Objective-C
- (BOOL)removeAllAnnotationsOnPageNumber:(int)pageNumber withError:(NSError *_Nullable *_Nullable)error;Swift
func removeAllAnnotations(onPageNumber pageNumber: Int32) throwsParameters
pageNumberthe PDF page number containing the annotations to remove
errorOn input, a pointer to an error object. If an error occurs , this pointer is set to an actual error object containing the error information. You may specify
nilfor this parameter if you do not want the error information.Return Value
YESif the annotations were successfully removed,NOif an error occurred. -
Removes all of the PDF annotations in the current document.
Note
In Swift, this method is imported as a throwing function.
Declaration
Objective-C
- (BOOL)removeAllAnnotationsWithError:(NSError *_Nullable *_Nullable)error;Swift
func removeAllAnnotations() throwsParameters
errorOn input, a pointer to an error object. If an error occurs , this pointer is set to an actual error object containing the error information. You may specify
nilfor this parameter if you do not want the error information.Return Value
YESif the annotations were successfully removed,NOif an error occurred.
-
Updates the annotations in the document with the provided XFDF string.
Note
In Swift, this method is imported as a throwing function.
Declaration
Objective-C
- (BOOL)updateAnnotationsWithXFDFString:(nonnull NSString *)xfdfString error:(NSError *_Nullable *_Nullable)error;Swift
func updateAnnotations(withXFDFString xfdfString: String) throwsParameters
xfdfStringThe XFDF string containing the updated annotation data.
errorOn input, a pointer to an error object. If an error occurs , this pointer is set to an actual error object containing the error information. You may specify
nilfor this parameter if you do not want the error information.Return Value
YESif the annotations in the document were updated successfuly, orNOif an error occurred. -
Updates the annotations in the document with the provided XFDF command string.
Note
In Swift, this method is imported as a throwing function.
Declaration
Objective-C
- (BOOL)updateAnnotationsWithXFDFCommand:(nonnull NSString *)xfdfCommand error:(NSError *_Nullable *_Nullable)error;Swift
func updateAnnotations(withXFDFCommand xfdfCommand: String) throwsParameters
xfdfCommandThe XFDF command string containing the updated annotation data.
errorOn input, a pointer to an error object. If an error occurs , this pointer is set to an actual error object containing the error information. You may specify
nilfor this parameter if you do not want the error information.Return Value
YESif the annotations in the document were updated successfuly, orNOif an error occurred.
-
The top-level document model object representing the current PDF document in the
pdfViewCtrl.Declaration
Objective-C
@property (nonatomic, strong, readonly, nullable) id<PTDocumentModel> documentModel;Swift
var documentModel: (any PTDocumentModel)? { get } -
Whether the document model for the current PDF document is currently being loaded.
Declaration
Objective-C
@property (nonatomic, assign, unsafe_unretained, readonly, getter=isLoadingDocumentModel) BOOL loadingDocumentModel;Swift
var isLoadingDocumentModel: Bool { get } -
Whether the
documentModelis loaded.The default value of this property is
NO.Declaration
Objective-C
@property (nonatomic, assign, unsafe_unretained, readonly, getter=isDocumentModelLoaded) BOOL documentModelLoaded;Swift
var isDocumentModelLoaded: Bool { get } -
Loads the document model for the current PDF document displayed in the
pdfViewCtrl. It is safe to call this method multiple times.Declaration
Objective-C
- (void)loadDocumentModel;Swift
func loadDocumentModel() -
Loads the document model for the current PDF document displayed in the
pdfViewCtrl.Declaration
Objective-C
- (void)loadDocumentModelWithCompletionHandler: (void (^_Nullable)(id<PTDocumentModel> _Nullable, NSError *_Nullable))completion;Swift
func loadDocumentModel() async throws -> any PTDocumentModelParameters
completionan optional completion block to be executed when the document model has been loaded. On success, the
documentModelparameter will contain the loaded document model, otherwise theerrorparameter will contain information describing the reason for failure.
-
If the annotation manager is currently loading annotation models.
Changes to the document page ordering / number should not be made while annotations are loading.
Declaration
Objective-C
@property (nonatomic, assign, unsafe_unretained, readonly, getter=isLoadingAnnotations) BOOL loadingAnnotations;Swift
var isLoadingAnnotations: Bool { get } -
Whether the annotation models have been loaded.
The default value of this property is
NO.Declaration
Objective-C
@property (nonatomic, assign, unsafe_unretained, readonly, getter=areAnnotationsLoaded) BOOL annotationsLoaded;Swift
var areAnnotationsLoaded: Bool { get } -
Starts or restarts the loading of annotation models by this annotation manager.
Declaration
Objective-C
- (void)loadAnnotationModels;Swift
func loadAnnotationModels() -
Fetches or creates the annotation model object for the given PDF annotation.
Declaration
Objective-C
- (void)annotationModelForAnnotation:(nonnull PTAnnot *)annotation onPageNumber:(int)pageNumber withCompletionHandler: (nonnull void (^)(id<PTAnnotationModel> _Nullable, NSError *_Nullable))completionHandler;Swift
func annotationModel(forAnnotation annotation: PTAnnot, onPageNumber pageNumber: Int32) async throws -> any PTAnnotationModelParameters
annotationThe annotation for which to get the model object
pageNumberThe PDF page number of the annotation
completionHandlerA block that will be called asynchronously with the results of this method. On success, the
annotationModelblock parameter will contain the annotation model object for the PDF annotation. If the annotation model object cannot be fetched or created, theannotationModelparameter will beniland error information will be passed in theerrorblock parameter. -
Returns whether the specified annotation model object can be edited by the current annotation author.
Declaration
Objective-C
- (BOOL)canEditAnnotationModel:(nonnull id<PTAnnotationModel>)annotationModel;Swift
func canEdit(_ annotationModel: any PTAnnotationModel) -> BoolReturn Value
YESif the specified annotation model object can be edited by the current annotation author,NOotherwise.
-
Using the provided block, modifies the specified annotation. The appropriate annotation-change events will be triggered before and after the modification.
Declaration
Parameters
annotationThe PDF annotation to be modified
pageNumberThe PDF page number containing the annotation
modificationBlockThe block to run during the annotation modification operation
-
Using the provided block, modifies the specified annotations. The appropriate annotation-change events will be triggered before and after the modification.
Declaration
Parameters
annotationsThe PDF annotations to be modified
pageNumberThe PDF page number containing the annotations
modificationBlockThe block to run during the annotation modification operation
-
Removes the given PDF annotation from the specified PDF page in the current document.
Note
In Swift, this method is imported as a throwing function.
Declaration
Objective-C
- (BOOL)removeAnnotation:(nonnull PTAnnot *)annotation onPageNumber:(int)pageNumber withError:(NSError *_Nullable *_Nullable)error;Swift
func removeAnnotation(_ annotation: PTAnnot, onPageNumber pageNumber: Int32) throwsParameters
annotationThe PDF annotation to be removed
pageNumberThe PDF page number containing the annotation
errorOn input, a pointer to an error object. If an error occurs , this pointer is set to an actual error object containing the error information. You may specify
nilfor this parameter if you do not want the error information.Return Value
YESif the annotation was successfully removed,NOif an error occurred. -
Removes the given PDF annotations from the specified PDF page in the current document.
Note
In Swift, this method is imported as a throwing function.
Declaration
Objective-C
- (BOOL)removeAnnotations:(nonnull NSArray<PTAnnot *> *)annotations onPageNumber:(int)pageNumber withError:(NSError *_Nullable *_Nullable)error;Swift
func removeAnnotations(_ annotations: [PTAnnot], onPageNumber pageNumber: Int32) throwsParameters
annotationsThe PDF annotations to be removed
pageNumberThe PDF page number containing the annotations
errorOn input, a pointer to an error object. If an error occurs , this pointer is set to an actual error object containing the error information. You may specify
nilfor this parameter if you do not want the error information.Return Value
YESif the annotations were successfully removed,NOif an error occurred.
-
Note
In Swift, this method is imported as a throwing function. -
Note
In Swift, this method is imported as a throwing function.
-
Used to notify the annotation manager that an annotation has been added.
Declaration
Objective-C
- (void)annotationAdded:(nonnull PTAnnot *)annotation onPageNumber:(int)pageNumber;Swift
func annotationAdded(_ annotation: PTAnnot, onPageNumber pageNumber: Int32)Parameters
annotationThe annotation that was added.
pageNumberThe page number of the PDF to which the annotation was added.
-
Used to notify the annotation manager that annotations have been added.
Declaration
Objective-C
- (void)annotationsAdded:(nonnull NSArray<PTAnnot *> *)annotations onPageNumber:(int)pageNumber;Swift
func annotationsAdded(_ annotations: [PTAnnot], onPageNumber pageNumber: Int32)Parameters
annotationsThe annotations that were added.
pageNumberThe page number of the PDF that the annotations were added to.
-
Used to notify the annotation manager that an annotation will be modified
Declaration
Objective-C
- (void)willModifyAnnotation:(nonnull PTAnnot *)annotation onPageNumber:(int)pageNumber;Swift
func willModifyAnnotation(_ annotation: PTAnnot, onPageNumber pageNumber: Int32)Parameters
annotationThe annotation will be modified.
pageNumberThe page number of the PDF that the annotation was modified on.
-
Used to notify the annotation manager that annotations will be modified.
Declaration
Objective-C
- (void)willModifyAnnotations:(nonnull NSArray<PTAnnot *> *)annotations onPageNumber:(int)pageNumber;Swift
func willModifyAnnotations(_ annotations: [PTAnnot], onPageNumber pageNumber: Int32)Parameters
annotationsThe annotations will be modified.
pageNumberThe page number of the PDF that the annotations were modified on.
-
Used to notify the annotation manager that an annotation has been modified.
Declaration
Objective-C
- (void)annotationModified:(nonnull PTAnnot *)annotation onPageNumber:(int)pageNumber;Swift
func annotationModified(_ annotation: PTAnnot, onPageNumber pageNumber: Int32)Parameters
annotationThe annotation that was modified.
pageNumberThe page number of the PDF that the annotation was modified on.
-
Used to notify the annotation manager that annotations have been modified.
Declaration
Objective-C
- (void)annotationsModified:(nonnull NSArray<PTAnnot *> *)annotations onPageNumber:(int)pageNumber;Swift
func annotationsModified(_ annotations: [PTAnnot], onPageNumber pageNumber: Int32)Parameters
annotationsThe annotations that were modified.
pageNumberThe page number of the PDF that the annotations were modified on.
-
Used to notify the annotation manager that the data of a form field has been modified.
Declaration
Objective-C
- (void)formFieldDataModifiedForAnnotation:(nonnull PTAnnot *)annotation onPageNumber:(int)pageNumber;Swift
func formFieldDataModified(forAnnotation annotation: PTAnnot, onPageNumber pageNumber: Int32)Parameters
annotationThe form field annotation that has modified data.
pageNumberThe page number of the PDF that the form field annotation is on.
-
Used to notify the annotation manager that an annotation will be removed.
Declaration
Objective-C
- (void)willRemoveAnnotation:(nonnull PTAnnot *)annotation onPageNumber:(int)pageNumber;Swift
func willRemoveAnnotation(_ annotation: PTAnnot, onPageNumber pageNumber: Int32)Parameters
annotationThe annotation that will be removed.
pageNumberThe page number of the PDF that the annotation was removed from.
-
Used to notify the annotation manager that annotations will be removed.
Declaration
Objective-C
- (void)willRemoveAnnotations:(nonnull NSArray<PTAnnot *> *)annotations onPageNumber:(int)pageNumber;Swift
func willRemoveAnnotations(_ annotations: [PTAnnot], onPageNumber pageNumber: Int32)Parameters
annotationsThe annotations that will be removed.
pageNumberThe page number of the PDF that the annotations will be removed from.
-
Used to notify the annotation manager that an annotation has been removed.
Declaration
Objective-C
- (void)annotationRemoved:(nonnull PTAnnot *)annotation onPageNumber:(int)pageNumber;Swift
func annotationRemoved(_ annotation: PTAnnot, onPageNumber pageNumber: Int32)Parameters
annotationThe annotation that was removed.
pageNumberThe page number of the PDF that the annotation was removed from.
-
Used to notify the annotation manager that annotations have been removed.
Declaration
Objective-C
- (void)annotationsRemoved:(nonnull NSArray<PTAnnot *> *)annotations onPageNumber:(int)pageNumber;Swift
func annotationsRemoved(_ annotations: [PTAnnot], onPageNumber pageNumber: Int32)Parameters
annotationsThe annotations that were removed.
pageNumberThe page number of the PDF that the annotations were removed from.
-
Used to notify the annotation manager that annotations will be flattened.
Declaration
Objective-C
- (void)willFlattenAnnotations:(nonnull NSArray<PTAnnot *> *)annotations onPageNumber:(int)pageNumber;Swift
func willFlattenAnnotations(_ annotations: [PTAnnot], onPageNumber pageNumber: Int32)Parameters
annotationsThe annotations that will be flattened.
pageNumberThe page number of the PDF that the annotations will be flattened on.
-
Used to notify the annotation manager that annotations have been flattened.
Declaration
Objective-C
- (void)didFlattenAnnotations:(nonnull NSArray<PTAnnot *> *)annotations onPageNumber:(int)pageNumber;Swift
func didFlattenAnnotations(_ annotations: [PTAnnot], onPageNumber pageNumber: Int32)Parameters
annotationsThe annotation that were flattened.
pageNumberThe page number of the PDF that the annotation were flattened on.
-
Used to notify the annotation manager that annotations will be changed in the document.
Declaration
Objective-C
- (void)annotationsWillChangeWithChanges: (nonnull NSArray<PTPDFAnnotationChange *> *)changes;Swift
func annotationsWillChange(with changes: [PTPDFAnnotationChange])Parameters
changesThe changes that will be made to the document’s annotations
-
Used to notify the annotation manager that annotations were changed in the document.
Declaration
Objective-C
- (void)annotationsDidChangeWithChanges: (nonnull NSArray<PTPDFAnnotationChange *> *)changes;Swift
func annotationsDidChange(with changes: [PTPDFAnnotationChange])Parameters
changesThe changes that were made to the document’s annotations
-
Used to notify the annotation manager that annotations will be updated with an XFDF string.
Declaration
Objective-C
- (void)willUpdateAnnotationsWithXFDFString:(nonnull NSString *)xfdfString;Swift
func willUpdateAnnotations(withXFDFString xfdfString: String)Parameters
xfdfStringThe XFDF string containing the updated annotation data.
-
Used to notify the annotation manager that annotations have been updated with an XFDF string.
Declaration
Objective-C
- (void)didUpdateAnnotationsWithXFDFString:(nonnull NSString *)xfdfString;Swift
func didUpdateAnnotations(withXFDFString xfdfString: String)Parameters
xfdfStringThe XFDF string containing the updated annotation data.
-
Used to notify the annotation manager that annotations will be updated with an XFDF command string.
Declaration
Objective-C
- (void)willUpdateAnnotationsWithXFDFCommand:(nonnull NSString *)xfdfCommand;Swift
func willUpdateAnnotations(withXFDFCommand xfdfCommand: String)Parameters
xfdfCommandThe XFDF command string containing the updated annotation data.
-
Used to notify the annotation manager that annotations have been updated with an XFDF command string.
Declaration
Objective-C
- (void)didUpdateAnnotationsWithXFDFCommand:(nonnull NSString *)xfdfCommand;Swift
func didUpdateAnnotations(withXFDFCommand xfdfCommand: String)Parameters
xfdfCommandThe XFDF command string containing the updated annotation data.
PTAnnotationManager Class Reference