Adding a stamp to PDFs on iOS

A stamp in a PDF document is analogous to applying a rubber stamp on a paper document.

Apryse SDK benefits include:

  • Stamp PDF pages with text, images, or with other PDF pages.
  • Embed fonts and images, and copy graphical elements from one page to another.

Use Stamper to stamp content (text, image, PDF page)

To stamp text, image, and a PDF page to a PDF document.

1PTPDFDoc *doc = [[PTPDFDoc alloc] initWithFilepath: filename];
2PTStamper *s = [[PTStamper alloc] initWithSize_type: e_ptrelative_scale a: 0.05 b: 0.05];
3
4// Specifies if the stamp is to be stamped as an annotation.
5// note that stamps created with this setting do not work with SetAsBackground, HasStamps, and DeleteStamps, if annotation is true.
6//[s SetAsAnnotation: YES];
7
8[s SetAlignment: e_pthorizontal_right vertical_alignment: e_ptvertical_bottom];
9[s SetAlignment: e_pthorizontal_center vertical_alignment: e_ptvertical_top];
10[s SetFont: [PTFont Create: [doc GetSDFDoc] type: e_ptcourier embed: YES]];
11PTColorPt *red = [[PTColorPt alloc] initWithX: 1 y: 0 z: 0 w: 0];
12[s SetFontColor: red]; //set color to red
13[s SetTextAlignment: e_ptalign_right];
14[s SetAsBackground: YES]; //set text stamp as background
15PTPageSet *ps = [[PTPageSet alloc] initWithRange_start: 1 range_end: 2 filter: e_ptall];
16[s StampText: doc src_txt: @"This is a title!" dest_pages: ps];
17
18PTImage *img = [PTImage Create: [doc GetSDFDoc] filename: imagename];
19[s SetAsBackground: NO]; // set image stamp as foreground
20PTPageSet *first_page_ps = [[PTPageSet alloc] initWithOne_page: 1];
21[s StampImage: doc src_img: img dest_pages: first_page_ps];
22
23PTPDFDoc *src_doc = [[PTPDFDoc alloc ] initWithFilepath: src_filename];
24PTPage *src_page = [src_doc GetPage: 1];
25[s StampPage: doc src_page: src_page dest_pages: ps];

Stamp a PDF File
Full code sample which shows how to stamp PDF pages with text, images, or with other PDF pages and how to add new content (or watermark).

About Stamper

Stamper can be used for PDF pages with text, images, or with other PDF content in only a few lines of code. Although Stamper is very simple to use compared to ElementBuilder/ElementWriter it is not as powerful or flexible. In case you need full control over PDF creation use ElementBuilder/ElementWriter to add new content to existing PDF pages as shown in the ElementBuilder sample project .

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales