Some test text!

menu

Add a stamp annotation

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

PDFTron 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.

linkStamp a PDF Page

To stamp an image to a page in a PDF document.

PDFDoc doc = new PDFDoc(filename);
Stamper s = new Stamper(Stamper.e_relative_scale, .05, .05);

Image img = Image.create(doc, imagename);
s.setSize(Stamper.e_relative_scale, 0.5, 0.5);

//set position of the image to the center, left of PDF pages
s.setAlignment(Stamper.e_horizontal_left, Stamper.e_vertical_center);
ColorPt pt = new ColorPt(0, 0, 0, 0);
s.setFontColor(pt);
s.setRotation(180);

// Specifies if the stamp is to be stamped in the background or the foreground.
//s.setAsBackground(false);

// Specifies if the stamp is to be stamped as an annotation.
// note that stamps created with this setting do not work with SetAsBackground, HasStamps, and DeleteStamps, if annotation is true.
s.setAsAnnotation(true); 

//only stamp first 2 pages
PageSet ps = new PageSet(1, 2);
s.stampImage(doc, img, 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).

linkAbout stamping a PDF page

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.

Get the answers you need: Support

close

Free Trial

Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.

Select a platform to get started with your free trial.

Unlimited usage. No email address required.

Join our live demo to learn about use cases & capabilities for WebViewer

Learn more
close