Some test text!

Stamp content

Adding a stamp to PDFs in Go

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.

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

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

doc := NewPDFDoc(filename)
s := NewStamper(StamperE_relative_scale, 0.5, 0.5)

// 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.SetAlignment(StamperE_horizontal_right, StamperE_vertical_bottom)
s.SetAlignment(StamperE_horizontal_center, StamperE_vertical_center)
red := NewColorPt(1.0, 0.0, 0.0) // set text color to red
s.StampText(doc, "This is a title!", NewPageSet(1, doc.GetPageCount()))

img := ImageCreate(doc.GetSDFDoc(), imagename)
ps := NewPageSet(1, 2)
s.StampImage(doc, img, ps)

src_doc := NewPDFDoc(src_filename)
srcPage := src_doc.GetPage(1)
s.StampPage(doc, srcPage, 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 .

Get the answers you need: Support