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 setDefaultStampAnnotations: on PSPDFStampViewController:

Copy
1
2
3
4
5
6
7
8
9
10
var stamps = [PSPDFStampAnnotation]()
let stampNames = ["Great!", "Stamp", "Like"]

for name in stampNames {
    let stampAnnotation = PSPDFStampAnnotation(subject: name.uppercased())
    let suggestedSize = stampAnnotation.sizeThatFits(CGSize(width: 200, height: 100))
    stampAnnotation.boundingBox = CGRect(x: 0, y: 0, width: suggestedSize.width, height: suggestedSize.height)
    stamps.append(stampAnnotation)
}
PSPDFStampViewController.setDefaultStampAnnotations(stamps)
Copy
1
2
3
4
5
6
7
8
9
10
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];

💡 Tip: You can retrieve the default set of stamp annotations defined by PSPDFKit using PSPDFStampViewController.defaultStampAnnotations.

Default Stamp Annotations

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

ℹ️ 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 PSPDFStampViewController.

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 PSPDFStampAnnotation to create a builder for bitmap stamp annotations:

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

Vector Stamp Annotations

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

Copy
1
2
3
4
5
// 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 = PSPDFFileAppearanceStreamGenerator(fileURL: logoURL)
Copy
1
2
3
4
5
// 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.