PSPDFStampAnnotation
Objective-C
@interface PSPDFStampAnnotation
: PSPDFAnnotation <PSPDFRotatable, PSPDFOverridable>
Swift
class StampAnnotation : Annotation, Rotatable, Overridable
PDF stamp annotation.
Stamp annotations that have no image
and no known stampType
will render their title
.
title
is a PSPDFKit addition that is not part of the PDF specification.
Stamps may be rotated using the rotation
property from PSPDFRotatable
.
Note
Make sure you configured Image Permissions in your app. See https://pspdfkit.com/guides/ios/getting-started/permissions/#toc_image-permissions for further documentation.-
Returns predefined colors for known names, like red for “void” or green for “completed”. Returns a default color (blue) for any other name, including
nil
and empty ones.Declaration
Objective-C
+ (nonnull UIColor *)colorForStampType:(nullable PSPDFStampType)stampType;
Swift
class func color(for stampType: StampAnnotation.Kind?) -> UIColor
-
Creates a new stamp annotation with a known identifier. Standard names are defined in the PDF specification. Most names that Adobe Acrobat creates are also supported. The stamp color will be set using using
colorForStampType:
.Declaration
Objective-C
- (nonnull instancetype)initWithStampType:(nullable PSPDFStampType)stampType;
Swift
init(stampType: StampAnnotation.Kind?)
-
Creates a new stamp annotation that displays custom text. The stamp color will be blue.
Declaration
Objective-C
- (nonnull instancetype)initWithTitle:(nullable NSString *)title;
Swift
init(title: String?)
-
A standard, known stamp identifier.
This is not text displayed to the user. It’s an identifier used to look up the image or localized text to display.
The “Name” key in the PDF. Be careful not to confuse this with the
name
property onPSPDFAnnotation
, which is the “NM” key in the PDF.Setting this to a standard type will change the title and subtitle to the predefined values for that type.
As with all annotation properties, post a
.PSPDFAnnotationChanged
notification to propagate changes.Declaration
Objective-C
@property (copy, nullable) PSPDFStampType stampType;
Swift
var stampType: StampAnnotation.Kind? { get set }
-
The main text shown by the stamp. This is a PSPDFKit addition that is not part of the PDF specification. This is set automatically to the correct localized text when a standard stamp type is set. Usually this property should only be changed for stamps with no stamp type.
As with all annotation properties, post a
.PSPDFAnnotationChanged
notification to propagate changes.Declaration
Objective-C
@property (copy, nullable) NSString *title;
Swift
var title: String? { get set }
-
The text shown in the second line of a custom text stamp. This is a PSPDFKit addition that is not part of the PDF specification. This property does nothing for stamps with an
image
. Usually this property should not be set for stamps with a known stamp type.As with all annotation properties, post a
.PSPDFAnnotationChanged
notification to propagate changes.Declaration
Objective-C
@property (copy, nullable) NSString *subtitle;
Swift
var subtitle: String? { get set }
-
The counterclockwise angle of the annotation relative to the page, in degrees. The angle should be between 0 and 359. Defaults to 0.
To set the rotation, use
setRotation(_:updateBoundingBox:)
.NOTE: Only the default (Acrobat stamps) and vector stamps support rotation but in limited document saving configurations. See
Rotatable
for more details.As with all annotation properties, post a
.PSPDFAnnotationChanged
notification to propagate changes.Declaration
Objective-C
@property (readonly) NSUInteger rotation;
Swift
var rotation: UInt { get }
-
Stamp image. Defaults to nil. Set to render an image.
Note
An image set will take priority over the internal appearance stream.As with all annotation properties, post a
.PSPDFAnnotationChanged
notification to propagate changes. -
Parses the AP stream, searches for an image and loads it. This can return nil if the
image
has been set manually. -
Stamp image transform. Defaults to
CGAffineTransformIdentity
.Declaration
Objective-C
@property CGAffineTransform imageTransform;
Swift
var imageTransform: CGAffineTransform { get set }
-
Whether this stamp 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 }
-
Return ‘best’ size to fit given size. does not actually resize the
boundingBox
. Will only work for simple stamp annotations with a subtitle.Declaration
Objective-C
- (CGSize)sizeThatFits:(CGSize)size;
Swift
func sizeThatFits(_ size: CGSize) -> CGSize
-
Calls
sizeThatFits:
with the currentboundingBox
and changes theboundingBox
. -
Parses the AP stream, searches for an image and loads it. This can return nil if the
image
has been set manually. @note This will not updateimage
orimageTransform
- do that manually if required.Declaration
Swift
public func loadImage(with transform: inout CGAffineTransform) throws -> UIImage