Stamp Annotations Configuration

PSPDFKit supports stamp annotations, which you can customize to your liking. To change the default set of stamp annotations available for your application, use the defaultStampAnnotations class property on StampViewController:

var stamps = [StampAnnotation]()
let stampNames = ["Great!", "Stamp", "Like"]

for name in stampNames {
    let stampAnnotation = StampAnnotation(title: name.uppercased())
    let suggestedSize = stampAnnotation.sizeThatFits(CGSize(width: 200, height: 100))
    stampAnnotation.boundingBox = CGRect(x: 0, y: 0, width: suggestedSize.width, height: suggestedSize.height)
StampViewController.defaultStampAnnotations = stamps
NSMutableArray<PSPDFStampAnnotation *> *stamps = [[NSMutableArray alloc] init];
NSArray<NSString *> *stampNames = @[@"Great!", @"Stamp", @"Like"];

for (NSString *name in stampNames) {
    PSPDFStampAnnotation *stampAnnotation = [[PSPDFStampAnnotation alloc] initWithSubject:name.uppercaseString];
    CGSize suggestedSize = [stampAnnotation sizeThatFits:CGSizeMake(200.f, 100.f)];
    stampAnnotation.boundingBox = CGRectMake(0, 0, suggestedSize.width, suggestedSize.height);
    [stamps addObject:stampAnnotation];
[PSPDFStampViewController setDefaultStampAnnotations:stamps];

Custom Stamps

Default Stamp Annotations

PSPDFKit comes with some out-of-the-box stamp annotations available in the stamp picker dialog.

Default Stamps

ℹ️ Note: When customStampEnabled is set to true (this is the default), we enable the creation of custom stamps that the user can generate at runtime, and we add them to the StampViewController.

Image Stamp Annotations

PSPDFKit supports stamp annotations generated from a bitmap image. These annotations with supplied bitmaps cannot have localized subjects, subtext, or text colors. Use the image property on StampAnnotation to create a builder for bitmap stamp annotations:

stamp.image = UIImage(named: "exampleimage.jpg")
stamp.image = [UIImage imageNamed:@"exampleimage.jpg"];

Vector Stamp Annotations

PSPDFKit supports stamp annotations generated with an appearance stream. Use the appearanceStreamGenerator property on StampAnnotation to create a builder for vector stamp annotations:

// Create the URL of the appearance stream that uses a PDF file.
let samplesURL = Bundle.main.resourceURL!.appendingPathComponent("Samples")
let logoURL = samplesURL.appendingPathComponent("PSPDFKit Logo.pdf")

stamp.appearanceStreamGenerator = FileAppearanceStreamGenerator(fileURL: logoURL)
// Create the URL of the appearance stream that uses a PDF file.
NSURL *samplesURL = [NSBundle.mainBundle.resourceURL URLByAppendingPathComponent:@"Samples"];
NSURL *logoURL = [samplesURL URLByAppendingPathComponent:@"PSPDFKit Logo.pdf"];

stamp.appearanceStreamGenerator = [[PSPDFFileAppearanceStreamGenerator alloc] initWithFileURL:logoURL];

See our Appearance Streams guide for more information on how to programmatically add vector stamp annotations. And take a look at CustomStampAnnotationsExample inside the Catalog app, which shows how to create a different set of default stamp annotations.