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/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 NSColor *)colorForStampType:(nullable PSPDFStampType)stampType;

    Swift

    class func color(for stampType: StampAnnotation.Kind?) -> NSColor
  • 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?)
  • Create a new stamp annotation with an image.

    Declaration

    Objective-C

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

    Swift

    init(image: NSImage?)
  • 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 (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.

    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.

    Declaration

    Objective-C

    @property (copy, 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 (nullable) NSImage *image;

    Swift

    var image: NSImage? { 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 NSImage *)
        loadImageWithTransform:(out nullable CGAffineTransform *)transform
                         error:(NSError *_Nullable *_Nullable)error;

    Swift

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

    Declaration

    Objective-C

    @property 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 subtitle.

    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()
  • 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

    Swift

    public func loadImage(with transform: inout CGAffineTransform) throws -> UIImage