CPDFAnnotation Class Reference
| Inherits from | NSObject |
|---|---|
| Declared in | CPDFAnnotation.h |
Overview
CPDFAnnotation does not conform to NSCopying. Use \c copyToPage: to copy an annotation to a target page.
– initWithPage:document:
Creates a new annotation object associated with the given page and document.
- (nullable instancetype)initWithPage:(CPDFPage *)page document:(CPDFDocument *)documentParameters
page |
The page on which the annotation will eventually reside. |
|---|---|
document |
The document that owns the page. |
Return Value
A new annotation instance, or @c nil if creation failed.
Discussion
Creates a new annotation object associated with the given page and document.
This initializer creates the underlying engine annotation object (via @c CreateAnnot) and binds it to the page. Call @c [CPDFPage updateAndAddAnnotation:] to finish the wrapper-side registration, appearance generation, and undo/redo notification.
Declared In
CPDFAnnotation.h
page
Returns the page that the annotation is associated with (may return nil if annotation not associated with a page).
@property (nonatomic, readonly, weak) CPDFPage *pageDiscussion
Returns the page that the annotation is associated with (may return nil if annotation not associated with a page).
New annotation objects are associated with a page during @c initWithPage:document: creation.
Declared In
CPDFAnnotation.h
– copyToPage:
Copies the annotation to the specified target page.
- (nullable CPDFAnnotation *)copyToPage:(CPDFPage *)pageParameters
page |
The target page to copy the annotation to. The copied annotation will be added to this page. |
|---|
Return Value
For an ordinary annotation, a new annotation wrapper on the target page. For a restorable copy returned by @c copyForUndoRestore, the original wrapper may be returned when it is still alive and has been physically removed. Returns @c nil when copying or safe restoration fails.
Discussion
Copies the annotation to the specified target page.
Declared In
CPDFAnnotation.h
– copyForUndoRestore
Creates a restorable copy for undo/redo before the receiver is removed.
- (nullable CPDFAnnotation *)copyForUndoRestoreReturn Value
A restorable annotation copy, or nil if the copy failed.
Discussion
Creates a restorable copy for undo/redo before the receiver is removed.
The returned annotation is backed by an internal temporary document that is retained by the copied annotation. Keep the returned object in your undo item, then call @c copyToPage: on it to restore a new annotation to the target page during undo/redo. Call this method before removing the original annotation from its page. The SDK weakly associates the original wrapper with this copy. Restoring through @c copyToPage: reuses that wrapper when safe, without retaining its page or native annotation. If the original wrapper has already been released, restoration creates a new wrapper as a compatibility fallback.
Declared In
CPDFAnnotation.h
– releaseUndoRestoreDocument
Releases the temporary document retained by @c copyForUndoRestore.
- (void)releaseUndoRestoreDocumentDiscussion
Releases the temporary document retained by @c copyForUndoRestore.
Call this after the undo/redo restore has successfully copied the restorable annotation back to the target page with @c copyToPage:. After calling this method, do not use the same restorable annotation as a copy source again.
Declared In
CPDFAnnotation.h
type
Returns the type of the annotation. Examples include: “Text”, “Link”, “Line”, etc.
@property (nonatomic, readonly) NSString *typeDiscussion
Returns the type of the annotation. Examples include: “Text”, “Link”, “Line”, etc.
The type of the annotation. Types include Line, Link, Text, and so on, referring to the CPDFAnnotation subclasses. In the Adobe PDF Specification, this attribute is called Subtype, and the common “type” for all annotations in the PDF Specification is Annot.
Declared In
CPDFAnnotation.h
bounds
Method to get / set the bounding box for the annotation in page space. Required for all annotations.
@property (nonatomic, assign) CGRect boundsDiscussion
Method to get / set the bounding box for the annotation in page space. Required for all annotations.
Page space is coordinate system with the origin at the lower-left corner of the current page.
Declared In
CPDFAnnotation.h
contents
Method to get / set the textual content (if any) associated with the annotation.
@property (nonatomic, strong) NSString *contentsDiscussion
Method to get / set the textual content (if any) associated with the annotation.
Textual content is typically associated with CPDFTextAnnotation and CPDFFreeTextAnnotation annotations.
Declared In
CPDFAnnotation.h
borderWidth
Method to get / set the stroke thickness for the annotation.
@property (nonatomic, assign) CGFloat borderWidthDiscussion
Method to get / set the stroke thickness for the annotation.
For the “geometry” annotations (Circle, Ink, Line, Square), the stroke thickness indicates the line width. CPDFAnnotation markup types (Highlight, Strikethrough, Underline) ignores the stroke thickness.
Declared In
CPDFAnnotation.h
border
Optional border or border style that describes how to draw the annotation border (if any).
@property (nonatomic, strong) CPDFBorder *borderDiscussion
Optional border or border style that describes how to draw the annotation border (if any).
For the “geometry” annotations (Circle, Ink, Line, Square), the border indicates the line width and whether to draw with a dash pattern or solid pattern. CPDFAnnotation markup types (Highlight, Strikethrough, Underline) ignores the border.
Declared In
CPDFAnnotation.h
opacity
Method to get / set the opacity for the annotation.
@property (nonatomic, assign) CGFloat opacityDiscussion
Method to get / set the opacity for the annotation.
Declared In
CPDFAnnotation.h
color
Method to get / set the color for the annotation.
@property (nonatomic, strong) CPDFKitPlatformColor *colorDiscussion
Method to get / set the color for the annotation.
For many annotations (“Circle”, “Square”) the stroke color. Used for other annotations as well.
Declared In
CPDFAnnotation.h
– modificationDate
Returns the modification date of the annotation.
- (NSDate *_Nullable)modificationDateDiscussion
Returns the modification date of the annotation.
Declared In
CPDFAnnotation.h
– creationDate
Returns the creation date of the annotation.
- (NSDate *_Nullable)creationDateDiscussion
Returns the creation date of the annotation.
Declared In
CPDFAnnotation.h
– userName
Returns the name of the user who created the annotation.
- (NSString *)userNameDiscussion
Returns the name of the user who created the annotation.
Declared In
CPDFAnnotation.h
– anntationImage
- Returns the image of the annotation.
- (CPDFKitPlatformImage *_Nonnull)anntationImageDiscussion
- Returns the image of the annotation.
Declared In
CPDFAnnotation.h
– flags
Returns the flags of the annotation.
- (CPDFAnnotationFlags)flagsDiscussion
Returns the flags of the annotation.
See Also
Declared In
CPDFAnnotation.h
– setFlags:
– updateAppearanceStream
Update appearance stream for the annotation.
- (void)updateAppearanceStreamDiscussion
Update appearance stream for the annotation.
ComPDFKit will update the annotation appearance by default when you modify the annotation properties. You can also manually update the appearance by calling the updateAppearanceStream method, but you must call the updateAppearanceStream method manually when you modify the bounds of CPDFTextAnnotation, CPDFStampAnnotation, CPDFSignatureAnnotation annotations.
Declared In
CPDFAnnotation.h
annotationRotation
Sets the rotation angle for the annotation in degrees.
@property (nonatomic, readonly) NSInteger annotationRotationDiscussion
Sets the rotation angle for the annotation in degrees.
Rotation on a annotation. Must be -180 ~ 180.
Declared In
CPDFAnnotation.h
saveRectRotationPoints
Method to get the all rect vertex points after rotation.
@property (nonatomic, readonly) NSArray<NSValue*> *saveRectRotationPointsDiscussion
Method to get the all rect vertex points after rotation.
Vertex points of the current page.
Declared In
CPDFAnnotation.h
saveSourceRect
Method to get the rect befer rotation.based on the rect when the rotation angle is 0 degrees.
@property (nonatomic, readonly) CGRect saveSourceRectDiscussion
Method to get the rect befer rotation.based on the rect when the rotation angle is 0 degrees.
rect of the current page.
Declared In
CPDFAnnotation.h
– updateAnnotationRotation:
Method to Quickly set the annotation rotation angle, and simultaneously update the saveRectRotationPoints and annotationRotation property.
- (void)updateAnnotationRotation:(NSInteger)annotationRotationDiscussion
Method to Quickly set the annotation rotation angle, and simultaneously update the saveRectRotationPoints and annotationRotation property.
Rotation on a annotation. The annotationRotation based on when the rotation angle is 0 degrees. Must be -180 ~ 180.
Declared In
CPDFAnnotation.h
– moveAnnotationWithActivePage:offset:
Method to move stampAnnotation
- (void)moveAnnotationWithActivePage:(CPDFPage *_Nonnull)newActivePage offset:(CPDFKitPlatformPoint)offsetDiscussion
Method to move stampAnnotation
offset
Declared In
CPDFAnnotation.h
– dragAnnotationWithCurrentPagePoint:draggedIndex:
Method to drag stampAnnotation
- (void)dragAnnotationWithCurrentPagePoint:(CGPoint)currentPagePoint draggedIndex:(CPDFAnnotationDraggedHandle)draggedIndexDiscussion
Method to drag stampAnnotation
draggedIndex
Declared In
CPDFAnnotation.h
– createReplyStateAnnotation:
- (CPDFAnnotation *)createReplyStateAnnotation:(CPDFAnnotationState)state– drawWithBox:inContext:
Draw method. Draws in page-space relative to origin of “box” passed in and to the given context.
- (void)drawWithBox:(CPDFDisplayBox)box inContext:(CGContextRef _Nonnull)contextDiscussion
Draw method. Draws in page-space relative to origin of “box” passed in and to the given context.
Declared In
CPDFAnnotation.h
– setCountMeasureInfo:document:
Applies count measurement information to the annotation.
- (void)setCountMeasureInfo:(CPDFCountMeasureInfo *_Nonnull)measureInfo document:(CPDFDocument *_Nonnull)documentDiscussion
Applies count measurement information to the annotation.
Count measurement requires a document for initialization.
Declared In
CPDFAnnotation.h
– setAngleMeasureInfo:
Applies angle measurement information to the annotation.
- (void)setAngleMeasureInfo:(CPDFAngleMeasureInfo *_Nonnull)measureInfoDiscussion
Applies angle measurement information to the annotation.
Declared In
CPDFAnnotation.h
+ prepareRulerSnappingSnapshotWithDocument:pageIndex:mode:
Initializes the ruler snapping snapshot for a given page.
+ (BOOL)prepareRulerSnappingSnapshotWithDocument:(CPDFDocument *_Nonnull)document pageIndex:(NSInteger)pageIndex mode:(CPDFSnappingMode)modeParameters
document |
The target document. |
|---|---|
pageIndex |
Zero-based page index. |
mode |
The snapping mode. |
Return Value
YES if succeeded.
Discussion
Initializes the ruler snapping snapshot for a given page.
Declared In
CPDFAnnotation.h
+ closeRulerSnappingSnapshot
Closes the ruler snapping snapshot.
+ (BOOL)closeRulerSnappingSnapshotDiscussion
Closes the ruler snapping snapshot.
Declared In
CPDFAnnotation.h
+ snapPointToNearest:outMode:radius:
Snaps a point to the nearest snapping target within a radius.
+ (BOOL)snapPointToNearest:(CPDFKitPlatformPoint *_Nonnull)point outMode:(CPDFSnappingMode *_Nullable)outMode radius:(double)radiusParameters
point |
The input point (page space). On success it will be updated to the snapped point. |
|---|---|
outMode |
The output snapping mode if snapped (optional). |
radius |
The snapping radius. |
Return Value
YES if a snapping target is found.
Discussion
Snaps a point to the nearest snapping target within a radius.
Declared In
CPDFAnnotation.h