Annotations
-
Base class for Line, Polygon and PolyLine annotations.
See moreDeclaration
Objective-C
@interface PSPDFAbstractLineAnnotation : PSPDFAbstractShapeAnnotation
Swift
class AbstractLineAnnotation : AbstractShapeAnnotation
-
The base class for Ink, Rectangle, Circle, Line, Polygon and PolyLine annotations.
These annotations are created in the UI using
See morePSPDFDrawView
.Declaration
Objective-C
@interface PSPDFAbstractShapeAnnotation : PSPDFAnnotation
Swift
class AbstractShapeAnnotation : Annotation
-
Base class for Highlight, Underline, StrikeOut and Squiggly annotations. You should never create instances of this class directly. Use one of its subclasses instead.
See moreDeclaration
Objective-C
@interface PSPDFTextMarkupAnnotation : PSPDFAnnotation
Swift
class TextMarkupAnnotation : Annotation
-
PSPDFAnnotation
is the base class for all PDF annotations and forms.Don’t directly make an instance of this class, use subclasses like
PSPDFNoteAnnotation
orPSPDFLinkAnnotation
. This class will returnnil
if initialized directly, unless with the typePSPDFAnnotationTypeUndefined
.PSPDFAnnotationManager
searches the runtime for subclasses ofPSPDFAnnotation
and builds up a dictionary usingsupportedTypes
.As well as the various annotation subclasses, there are two types to model annotation types:
PSPDFAnnotationType
is mostly used for the type of an existing annotation. As an option set, it can be convenient to add and remote types from certain API such as thePDFConfiguration
’seditableAnnotationTypes
.PSPDFAnnotationString
is mostly used as the type of a tool for creating annotations. As well as annotation types it includes pure tools such asPSPDFAnnotationStringEraser
. The tools are activated in the UI withAnnotationToolbar
andPSPDFAnnotationStateManager
.
Note
Thread safety: Annotation objects should only ever be edited on the main thread. Modify properties on the main thread only if they are already active (for creation, it doesn’t matter which thread creates them). Before rendering, obtain a copy of the annotation to ensure it’s not mutated while properties are read. Once the
documentProvider
is set, modifying properties on a background thread will throw an exception.Annotation properties are specified in normalized PDF coordinates: they take page rotation and
CropBox
offset into account. Prior to PSPDFKit 8 for iOS and PSPDFKit 3 for macOS properties were specified in PDF coordinates: not taking the page rotation and offset into account. After unarchiving annotations fromNSCoder
archives created with older versions of PSPDFKit, the properties will be untransformed, and will be modified to apply the page transform when the annotation is added to a document.Annotations contain internal state once they are attached to a document. Don’t take them and add them to another document. Instead, create a new annotation and set the properties relevant for you, and add this annotation.
Warning
Annotations are mutable objects. Do not store them inNSSet
or other objects that require a hash-value that does not change.Declaration
Objective-C
@interface PSPDFAnnotation : PSPDFModel <PSPDFUndoSupport, NSSecureCoding>
extension Annotation: Identifiable
Swift
class Annotation : ModelObject, UndoSupport, NSSecureCoding
-
The types of author-specific state that may be associated with an annotation. States are grouped into categories defined by
See morePSPDFAnnotationAuthorStateModel
. See the Annotation States section in the PDF specification.Declaration
Objective-C
enum PSPDFAnnotationAuthorState {}
-
Collects annotations from the various
PSPDFAnnotationProvider
implementations.Usually you want to add your custom PSPDFAnnotationProvider instead of subclassing this class. If you subclass, use
overrideClass:withClass:
inDocument
.This class will set the
See moredocumentProvider
on both annotation adding and retrieving. You don’t have to handle this in yourannotationProvider
subclass.Declaration
Objective-C
@interface PSPDFAnnotationManager : NSObject <PSPDFAnnotationProviderChangeNotifier, PSPDFOverridable>
Swift
class AnnotationManager : NSObject, AnnotationProviderChangeNotifier, Overridable
-
With the annotation provider, you can mix in PDF annotations from any source (custom database, web, etc) Implement your custom provider class and register it in the
PSPDFAnnotationManager
.(Make sure to register the provider in the PSPDFDocument’s
didCreateDocumentProvider:
method, since aDocument
can have multiplePSPDFDocumentProviders
and thus multiplePSPDFAnnotationProviders
- and they can also be discarded on low memory situations.)Ensure everything is thread safe here - methods will be called from any threads and sometimes even concurrently at the same time. (If you’re doing parsing, block and then in the queue re-check so you’re not parsing multiple times for the same page)
Note
You should always usePSPDFContainerAnnotationProvider
as the base class for your custom annotation provider.Declaration
Objective-C
@protocol PSPDFAnnotationProvider <NSObject>
Swift
protocol AnnotationProvider : NSObjectProtocol
-
An annotation set may be used to add and position multiple annotations.
See moreDeclaration
Objective-C
@interface PSPDFAnnotationSet : PSPDFModel <NSFastEnumeration, NSSecureCoding>
Swift
class AnnotationSet : ModelObject, NSFastEnumeration, NSSecureCoding
-
Defines an annotation style.
See moreDeclaration
Objective-C
@interface PSPDFAnnotationStyle : PSPDFModel <NSSecureCoding>
Swift
class AnnotationStyle : ModelObject, NSSecureCoding
-
The annnotation style manager will save UI-specific properties for annotations and apply them after creation.
It also offers a selection of user-defined styles. There are three categories: Last used, key-specific and generic styles.
See moreDeclaration
Objective-C
@protocol PSPDFAnnotationStyleManager
Swift
protocol AnnotationStyleManager
-
Produces a summary of the annotations in a document.
See moreDeclaration
Objective-C
@interface PSPDFAnnotationSummarizer : NSObject
Swift
class AnnotationSummarizer : NSObject
-
Abstract subclass that contains an asset from a link
See moreDeclaration
Objective-C
@interface PSPDFAssetAnnotation : PSPDFLinkAnnotation
Swift
class AssetAnnotation : LinkAnnotation
-
A caret annotation (PDF 1.5) is a visual symbol that indicates the presence of text edits, and share much similarity with note (text) annotations.
Declaration
Objective-C
@interface PSPDFCaretAnnotation : PSPDFAnnotation <PSPDFOverridable>
Swift
class CaretAnnotation : Annotation, Overridable
-
The PDF Circle annotations (PDF 1.3) shall display an ellipse on the page.
See moreDeclaration
Objective-C
@interface PSPDFCircleAnnotation : PSPDFAbstractShapeAnnotation <PSPDFOverridable>
Swift
class CircleAnnotation : AbstractShapeAnnotation, Overridable
-
Default container for annotations. It’s crucial that you use this class as your base class if you implement a custom annotation provider, because this class offers efficient undo/redo which otherwise is almost impossible to replicate unless you understand the PSPDFKit internals extremely well.
This class conforms to the deprecated protocol
See morePSPDFAnnotationProviderRefreshing
. In a future release, this protocol will be removed. The reason is that this class handles refreshing internally. This class will continue to conform toPSPDFAnnotationProvider
.Declaration
Objective-C
@interface PSPDFContainerAnnotationProvider : NSObject <PSPDFAnnotationProviderRefreshing, PSPDFUndoSupport>
Swift
class PDFContainerAnnotationProvider : NSObject, PSPDFAnnotationProviderRefreshing, UndoSupport
-
Models a point used for natural drawing. Use
PSPDFDrawingPointFromCGPoint
to convert from a point with default intensity.Note
The type encoding of this struct needs to remain consistent, because drawing point data can be serialized in NSValue objects.Declaration
Objective-C
typedef struct PSPDFDrawingPoint PSPDFDrawingPoint
-
PDF File Attachment Annotation (see 12.5.6.15, “File attachment annotations”). A file attachment annotation (PDF 1.3) contains a reference to a file, which typically shall be embedded in the PDF file (see 7.11.4, “Embedded file streams”).
See moreDeclaration
Objective-C
@interface PSPDFFileAnnotation : PSPDFAnnotation <PSPDFOverridable>
Swift
class FileAnnotation : Annotation, Overridable
-
An implementation of the
PSPDFAnnotationProvider
protocol that uses the PDF document as source/target to load/save annotations. You almost always want to use thePSPDFFileAnnotationProvider
in yourPSPDFAnnotationManager
. You can also use this class inside a custom annotation provider, to parse PDF annotations once and then manage them in your custom database.Note
SubclassingPSPDFFileAnnotationProvider
will lead to slowerPSPDFProcessor
performance and is strongly discouraged. This will be blocked in future versions.Declaration
Objective-C
@interface PSPDFFileAnnotationProvider : PSPDFContainerAnnotationProvider <PSPDFOverridable>
Swift
class PDFFileAnnotationProvider : PDFContainerAnnotationProvider, Overridable
-
PDF FreeText Annotation.
A free text annotation (PDF 1.3) displays text directly on the page. Unlike an ordinary text annotation (see 12.5.6.4, “Text Annotations”), a free text annotation has no open or closed state; instead of being displayed in a pop-up window, the text shall be always visible.
See moreDeclaration
Objective-C
@interface PSPDFFreeTextAnnotation : PSPDFAnnotation <PSPDFRotatable, PSPDFOverridable>
Swift
class FreeTextAnnotation : Annotation, Rotatable, Overridable
-
Text Highlight Annotation
Warning
If you programmatically create a highlight annotation, you need to both set theboundingBox
AND the rects array. The rects array contains boxed variants ofCGRect
(NSValue
).Declaration
Objective-C
@interface PSPDFHighlightAnnotation : PSPDFTextMarkupAnnotation <PSPDFOverridable>
Swift
class HighlightAnnotation : TextMarkupAnnotation, 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 theboundingBox
is changed, and theboundingBox
is updated when thelines
are changed to enclose the new points.See
The annotation tool is activated in the UI byPSPDFAnnotationStateManager
andAnnotationToolbar
. The drawing interaction is handled byPSPDFDrawView
. Some drawing-related behaviors can be set in thePDFConfiguration
, such as with itsdrawCreateMode
property, which controls whether a new ink annotation is created after each stroke).Declaration
Objective-C
@interface PSPDFInkAnnotation : PSPDFAbstractShapeAnnotation <PSPDFOverridable>
Swift
class InkAnnotation : AbstractShapeAnnotation, Overridable
-
PDF Line annotation.
See moreDeclaration
Objective-C
@interface PSPDFLineAnnotation : PSPDFAbstractLineAnnotation <PSPDFOverridable>
Swift
class LineAnnotation : AbstractLineAnnotation, Overridable
-
The
PSPDFLinkAnnotation
represents both classic PDF page/document/web links, and more types not supported by other PDF readers (video, audio, image, etc)PSPDFKit will automatically figure out the type for PDF link annotations loaded from a document, based on the file type. (“mp4” belongs to
PSPDFLinkAnnotationVideo
; a YouTube-URL toPSPDFLinkAnnotationYouTube
, etc)If you create a
PSPDFLinkAnnotation
at runtime, be sure to set the correct type and use the URL parameter for your link.boundingBox
defines the frame, in PDF space coordinates.If you want to customize how links look in the PDF, customize
See morePSPDFLinkAnnotationView
’s properties. There’s currently no mapping betweencolor
/lineWidth
/etc and the properties of the view. This might change in a future release.Declaration
Objective-C
@interface PSPDFLinkAnnotation : PSPDFAnnotation <PSPDFOverridable>
Swift
class LinkAnnotation : Annotation, Overridable
-
PDF Note (Text) Annotation.
Note
Note annotations are rendered as fixed size; much like how Adobe Acrobat renders them. PSPDFKit will always render note annotations at a fixed size of 32x32pt. We recommend that you set theboundingBox
to the same value.Declaration
Objective-C
@interface PSPDFNoteAnnotation : PSPDFAnnotation <PSPDFOverridable>
Swift
class NoteAnnotation : Annotation, Overridable
-
Polyline annotations (PDF 1.5) are similar to polygons (`PSPDFPolygonAnnotation), except that the first and last vertex are not implicitly connected.
Note
SeePSPDFAbstractLineAnnotation
for details how to use and initialize.Declaration
Objective-C
@interface PSPDFPolyLineAnnotation : PSPDFAbstractLineAnnotation <PSPDFOverridable>
Swift
class PolyLineAnnotation : AbstractLineAnnotation, Overridable
-
Polygon annotations (PDF 1.5) display closed polygons on the page. Such polygons may have any number of vertices connected by straight lines. Polyline annotations (PDF 1.5) are similar to polygons, except that the first and last vertex are not implicitly connected.
Note
SeePSPDFAbstractLineAnnotation
for details how to use and initialize.Declaration
Objective-C
@interface PSPDFPolygonAnnotation : PSPDFAbstractLineAnnotation <PSPDFOverridable>
Swift
class PolygonAnnotation : AbstractLineAnnotation, Overridable
-
Undocumented
See moreDeclaration
Objective-C
@interface PSPDFPopupAnnotation : PSPDFAnnotation <PSPDFOverridable>
Swift
class PopupAnnotation : Annotation, Overridable
-
Redaction Annotation
Used to remove content from a document.
color
can be used to change the color of the overlay text. It has no effect if there is no overlay text specified. Defaults to a red color.fillColor
specifies the background color of the redaction area after is has been applied. The color is drawn on all the specifiedrects
. Defaults to black.lineWidth
can be set to change the border width of the redaction in its marked state. Defaults to 5.Note
Supports redacting text, images, paths, annotations, and forms.
Note
Redaction annotations need to be applied, after they were created and added to a document, to remove the content beneath them. See
PSPDFProcessorConfiguration
orPSPDFDocumentSaveOptionApplyRedactions
for further information.Warning
When programmatically creating a redaction annotation, both
boundingBox
andrects
need to be set. Therects
array contains boxed variants ofCGRect
(NSValue
).Declaration
Objective-C
@interface PSPDFRedactionAnnotation : PSPDFAnnotation <PSPDFOverridable>
Swift
class RedactionAnnotation : Annotation, Overridable
-
RichMedia annotations are defined in the ISO32000 Adobe Supplement and are the modern way of embedding video content. PSPDFKit also supports the matching
RichMediaExecute
action to control video state.Declaration
Objective-C
@interface PSPDFRichMediaAnnotation : PSPDFAssetAnnotation <PSPDFOverridable>
Swift
class RichMediaAnnotation : AssetAnnotation, Overridable
-
A screen annotation (PDF 1.5) specifies a region of a page upon which media clips may be played. It also serves as an object from which actions can be triggered. PSPDFKit also supports the matching Rendition Actions to control the video play state.
Note
iOS cannot play all video/audio formats that can be used for PDF.Declaration
Objective-C
@interface PSPDFScreenAnnotation : PSPDFAssetAnnotation <PSPDFOverridable>
Swift
class ScreenAnnotation : AssetAnnotation, Overridable
-
A sound annotation (PDF 1.2) shall analogous to a text annotation except that instead of a text note, it contains sound recorded from the iOS device’s microphone or imported from a file.
To ensure maximum compatibility set the
boundingBox
for sound annotations to the same size Adobe Acrobat uses (20x15pt). PSPDFKit will always render sound annotations at a fixed size of 74x44pt, centered in the providedboundingBox
.Note
Make sure you configured Microphone Permissions in your app. See https://pspdfkit.com/guides/ios/current/getting-started/permissions/#toc_microphone-permissions for futher documentation.Declaration
Objective-C
@interface PSPDFSoundAnnotation : PSPDFAnnotation <PSPDFOverridable>
Swift
class SoundAnnotation : Annotation, Overridable
-
Undocumented
See moreDeclaration
Objective-C
@interface PSPDFSoundAnnotationController : NSObject /// Stops any currently active recording or playback, except the sender. /// If the sender is nil, all annotations are stopped. + (void)stopRecordingOrPlaybackForAllExcept:(nullable id)sender; /// Checks if we have permission to record. + (void)requestRecordPermission:(nullable void (^)(BOOL granted))block; PSPDF_EMPTY_INIT_UNAVAILABLE - (instancetype)initWithSoundAnnotation:(PSPDFSoundAnnotation *)annotation NS_DESIGNATED_INITIALIZER; /// The controlled sound annotation. @property (nonatomic, weak, readonly) PSPDFSoundAnnotation *annotation; /// The current playback state. @property (nonatomic, readonly) PSPDFSoundAnnotationState state; /// The duration of the audio playback @property (nonatomic, readonly) NSTimeInterval playbackDuration; /// Starts or resumes playback. - (BOOL)startPlayback:(NSError **)error; /// Pauses playback or recording. - (void)pause; /// Stops playback or recording. - (BOOL)stop:(NSError **)error; #if !TARGET_OS_WATCH /// The audio player object. Only available if playback is ongoing or prepared. @property (nonatomic, readonly, nullable) AVAudioPlayer *audioPlayer; #endif #if PSPDF_HAS_RECORDING_FEATURE /// Starts or resumes recording. - (BOOL)startRecording:(NSError **)error; /// Discards the current recording. - (void)discardRecording; #endif @end
Swift
class SoundAnnotationController : NSObject
-
The PDF Square annotations (PDF 1.3) shall display a rectangle on the page.
See moreDeclaration
Objective-C
@interface PSPDFSquareAnnotation : PSPDFAbstractShapeAnnotation <PSPDFOverridable>
Swift
class SquareAnnotation : AbstractShapeAnnotation, Overridable
-
Text Squiggly Annotation
Warning
If you programmatically create a squiggly annotation, you need to both set theboundingBox
AND therects
array. The rects array contains boxed variants ofCGRect
(NSValue
).Declaration
Objective-C
@interface PSPDFSquigglyAnnotation : PSPDFTextMarkupAnnotation <PSPDFOverridable>
Swift
class SquigglyAnnotation : TextMarkupAnnotation, Overridable
-
PDF stamp annotation.
Stamp annotations that have no
image
and no knownstampType
will render theirtitle
.title
is a PSPDFKit addition that is not part of the PDF specification.Stamps may be rotated using the
rotation
property fromPSPDFRotatable
.Note
Make sure you configured Image Permissions in your app. See https://pspdfkit.com/guides/ios/current/getting-started/permissions/#toc_image-permissions for further documentation.Declaration
Objective-C
@interface PSPDFStampAnnotation : PSPDFAnnotation <PSPDFRotatable, PSPDFOverridable>
Swift
class StampAnnotation : Annotation, Rotatable, Overridable
-
Text StrikeOut Annotation
Warning
If you programmatically create a strikeout annotation, you need to both set theboundingBox
AND therects
array. The rects array contains boxed variants ofCGRect
(NSValue
).Declaration
Objective-C
@interface PSPDFStrikeOutAnnotation : PSPDFTextMarkupAnnotation <PSPDFOverridable>
Swift
class StrikeOutAnnotation : TextMarkupAnnotation, Overridable
-
Text Underline Annotation
Warning
If you programmatically create an underline annotation, you need to both set theboundingBox
AND therects
array. The rects array contains boxed variants ofCGRect
(NSValue
).Declaration
Objective-C
@interface PSPDFUnderlineAnnotation : PSPDFTextMarkupAnnotation <PSPDFOverridable>
Swift
class UnderlineAnnotation : TextMarkupAnnotation, Overridable
-
The PDF ‘Widget’ annotation. A Widget usually is a button, much like a link annotation.
See moreDeclaration
Objective-C
@interface PSPDFWidgetAnnotation : PSPDFAnnotation <PSPDFOverridable>
Swift
class WidgetAnnotation : Annotation, Overridable
-
Advanced appearance characteristics for a widget annotation. It contains additional information for constructing the annotation’s appearance stream
See moreDeclaration
Objective-C
@interface PSPDFAppearanceCharacteristics : PSPDFModel <NSSecureCoding, PSPDFOverridable>
Swift
class AppearanceCharacteristics : ModelObject, NSSecureCoding, Overridable
-
Container object for storing a signature containing an ink annotation and an optional signer.
See moreDeclaration
Objective-C
@interface PSPDFSignatureContainer : NSObject <NSSecureCoding, PSPDFOverridable>
Swift
class SignatureContainer : NSObject, NSSecureCoding, Overridable
-
A instance of this protocol can be set on any
PSPDFAnnotation
and instead of using the PSPDFKit provided appearance stream generation methods, any PDF can be returned.The annotation will use the first page of the returned PDF as its appearance and this content will be embedded into the PDF.
See moreDeclaration
Objective-C
@protocol PSPDFAppearanceStreamGenerating <NSObject>
Swift
protocol AppearanceStreamGenerating : NSObjectProtocol
-
The default appearance stream generator.
Calls
See more-[PSPDFAnnotation drawInContext:options:]
and transforms it into an appearance stream.Declaration
Objective-C
@interface PSPDFDrawingContextAppearanceStreamGenerator : NSObject <PSPDFAppearanceStreamGenerating>
Swift
class DrawingContextAppearanceStreamGenerator : NSObject, AppearanceStreamGenerating
-
An appearance stream generator that makes sure to retain the current appearance stream.
Declaration
Objective-C
@interface PSPDFRetainExistingAppearanceStreamGenerator : NSObject <PSPDFAppearanceStreamGenerating>
Swift
class RetainExistingAppearanceStreamGenerator : NSObject, AppearanceStreamGenerating
-
An appearance stream generator that takes an
NSURL
to any PDF file and returns it as the appearance stream.Custom appearance streams are only intended to be used with stamp annotations to create a vector stamp. Using this class with other annotation types is not supported.
See moreDeclaration
Objective-C
@interface PSPDFFileAppearanceStreamGenerator : NSObject <PSPDFAppearanceStreamGenerating>
Swift
class FileAppearanceStreamGenerator : NSObject, AppearanceStreamGenerating
-
Annotations that can be rotated conform to this protocol.
See moreDeclaration
Objective-C
@protocol PSPDFRotatable <NSObject>
Swift
protocol Rotatable : NSObjectProtocol
-
Defines the z-index position where an annotation should be moved to.
See moreDeclaration
Objective-C
enum PSPDFAnnotationZIndexMove {}
-
Protcol allowing annotation updates.
See moreDeclaration
Objective-C
@protocol PSPDFAnnotationUpdate <NSObject>
Swift
protocol AnnotationUpdate : NSObjectProtocol
-
Property keys for annotation inspector customization.
See
PSPDFAnnotationStyleViewControllerSee
PSPDFConfigurationDeclaration
Objective-C
typedef NSString *PSPDFAnnotationStyleKey