PSPDFStampAnnotation


@interface PSPDFStampAnnotation : PSPDFAnnotation <PSPDFRotatable>

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. Rotation is not supported for vector stamps.

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.
  • 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: PSPDFStampType?) -> 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: PSPDFStampType?)
  • 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?)
  • Create a new stamp annotation with an image.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithImage:(nullable UIImage *)image;

    Swift

    init(image: UIImage?)
  • 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 on PSPDFAnnotation, 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.

    Declaration

    Objective-C

    @property (readwrite, copy, atomic, nullable) PSPDFStampType stampType;

    Swift

    var stampType: PSPDFStampType? { 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.

    Declaration

    Objective-C

    @property (readwrite, copy, atomic, 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.

    Declaration

    Objective-C

    @property (readwrite, copy, atomic, nullable) NSString *subtitle;

    Swift

    var subtitle: String? { get set }
  • Stamp image. Defaults to nil. Set to render an image.

    Note

    An image set will take priority over the internal appearance stream.

    Declaration

    Objective-C

    @property (assign, readwrite, atomic, nullable) UIImage *image;

    Swift

    var image: UIImage? { get set }
  • 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 update image or imageTransform - do that manually if required.

    Declaration

    Objective-C

    - (nullable UIImage *)
        loadImageWithTransform:(out nullable CGAffineTransform *)transform
                         error:(NSError *_Nullable *_Nullable)error;

    Swift

    func loadImage(with transform: UnsafeMutablePointer<CGAffineTransform>?) throws -> UIImage
  • Stamp image transform. Defaults to CGAffineTransformIdentity.

    Declaration

    Objective-C

    @property (assign, readwrite, atomic) CGAffineTransform imageTransform;

    Swift

    var imageTransform: CGAffineTransform { get set }
  • Return ‘best’ size to fit given size. does not actually resize the boundingBox. Will only work for simple stamp annotations with a subtext.

    Declaration

    Objective-C

    - (CGSize)sizeThatFits:(CGSize)size;

    Swift

    func sizeThatFits(_ size: CGSize) -> CGSize
  • Calls sizeThatFits: with the current boundingBox and changes the boundingBox.

    Declaration

    Objective-C

    - (void)sizeToFit;

    Swift

    func sizeToFit()