Adding a stamp to PDFs on Server/Desktop

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.

1PDFDoc doc = new PDFDoc(filename);
2Stamper s = new Stamper(Stamper.SizeType.e_relative_scale, .05, .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(true);
7
8s.SetAlignment(Stamper.HorizontalAlignment.e_horizontal_right, Stamper.VerticalAlignment.e_vertical_bottom);
9s.SetAlignment(Stamper.HorizontalAlignment.e_horizontal_center, Stamper.VerticalAlignment.e_vertical_top);
10s.SetFont(Font.Create(doc, Font.StandardType1Font.e_courier, true));
11s.SetFontColor(new ColorPt(1, 0, 0, 0)); //set color to red
12s.SetTextAlignment(Stamper.TextAlignment.e_align_right);
13s.SetAsBackground(true); //set text stamp as background
14s.StampText(doc, "This is a title!", new PageSet(1, 2));
15
16Image img = Image.Create(doc, imagename);
17s.SetAsBackground(false); // set image stamp as foreground
18s.StampImage(doc, img, new PageSet(1));
19
20PDFDoc src_doc = new PDFDoc(src_filename);
21Page src_page = src_doc.GetPage(1);
22s.StampPage(doc, src_page, new PageSet(1));

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