Some test text!
A stamp in a PDF document is analogous to applying a rubber stamp on a paper document.
PDFTron SDK benefits include:
To stamp text, image, and a PDF page to a PDF document.
doc = PDFDoc(filename) s = Stamper(Stamper.e_relative_scale, 0.05, 0.05) # 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) s.SetAlignment(Stamper.e_horizontal_right, Stamper.e_vertical_bottom) s.SetAlignment(Stamper.e_horizontal_center, Stamper.e_vertical_top) s.SetFont(Font.Create(doc.GetSDFDoc(), Font.e_courier, True)) red = ColorPt(1, 0, 0) s.SetFontColor(red) # set text color to red s.SetTextAlignment(Stamper.e_align_right) s.SetAsBackground(True) # set text stamp as background ps = PageSet(1, 2) s.StampText(doc, "This is a title!", ps) img = Image.Create(doc.GetSDFDoc(), imagename) s.SetAsBackground(False) # set image stamp as foreground first_page_ps = PageSet(1) s.StampImage(doc, img, first_page_ps) src_doc = PDFDoc(src_filename) src_page = src_doc.GetPage(1) s.StampPage(doc, src_page, 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).
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
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.