A stamp in a PDF document is analogous to applying a rubber stamp on a paper document.
Apryse SDK benefits include:
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));
1PDFDoc doc(filename);
2Stamper s(Stamper::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::e_horizontal_right, Stamper::e_vertical_bottom);
9s.SetAlignment(Stamper::e_horizontal_center, Stamper::e_vertical_top);
10s.SetFont(Font::Create(doc, Font::e_courier, true));
11ColorPt red(1, 0, 0, 0);
12s.SetFontColor(red); //set color to red
13s.SetTextAlignment(Stamper::e_align_right);
14s.SetAsBackground(true); //set text stamp as background
15PageSet ps(1, 2);
16s.StampText(doc, "This is a title!", ps);
17
18Image img = Image::Create(doc, imagename);
19s.SetAsBackground(false); // set image stamp as foreground
20PageSet first_page_ps(1);
21s.StampImage(doc, img, first_page_ps);
22
23PDFDoc src_doc(src_filename);
24Page src_page = src_doc.GetPage(1);
25s.StampPage(doc, src_page, first_page_ps);
1doc := NewPDFDoc(filename)
2s := NewStamper(StamperE_relative_scale, 0.5, 0.5)
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(StamperE_horizontal_right, StamperE_vertical_bottom)
9s.SetAlignment(StamperE_horizontal_center, StamperE_vertical_center)
10red := NewColorPt(1.0, 0.0, 0.0) // set text color to red
11s.SetFontColor(red)
12s.StampText(doc, "This is a title!", NewPageSet(1, doc.GetPageCount()))
13
14img := ImageCreate(doc.GetSDFDoc(), imagename)
15s.SetAsBackground(false)
16ps := NewPageSet(1, 2)
17s.StampImage(doc, img, ps)
18
19src_doc := NewPDFDoc(src_filename)
20srcPage := src_doc.GetPage(1)
21s.StampPage(doc, srcPage, ps)
1PDFDoc doc = new PDFDoc(filename);
2Stamper s = new Stamper(Stamper.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.e_horizontal_right, Stamper.e_vertical_bottom);
9s.setAlignment(Stamper.e_horizontal_center, Stamper.e_vertical_top);
10s.setFont(Font.create(doc, Font.e_courier, true));
11ColorPt red = new ColorPt(1, 0, 0, 0);
12s.setFontColor(red); //set color to red
13s.setTextAlignment(Stamper.e_align_right);
14s.setAsBackground(true); //set text stamp as background
15PageSet ps = new PageSet(1, 2);
16s.stampText(doc, "This is a title!", ps);
17
18Image img = Image.create(doc, imagename);
19s.setAsBackground(false); // set image stamp as foreground
20PageSet first_page_ps = new PageSet(1);
21s.stampImage(doc, img, first_page_ps);
22
23PDFDoc src_doc = new PDFDoc(src_filename);
24Page src_page = src_doc.getPage(1);
25s.stampPage(doc, src_page, first_page_ps);
1async function main() {
2 const doc = await PDFNet.PDFDoc.createFromURL(filename);
3 const stamper = await PDFNet.Stamper.create(
4 PDFNet.Stamper.SizeType.e_relative_scale,
5 0.5,
6 0.5
7 );
8
9 // Specifies if the stamp is to be stamped as an annotation.
10 // note that stamps created with this setting do not work with SetAsBackground, HasStamps, and DeleteStamps, if annotation is true.
11 //stamper.setAsAnnotation(true);
12
13 await stamper.setAlignment(
14 PDFNet.Stamper.HorizontalAlignment.e_horizontal_right,
15 PDFNet.Stamper.VerticalAlignment.e_vertical_bottom
16 );
17 await stamper.setAlignment(
18 PDFNet.Stamper.HorizontalAlignment.e_horizontal_center,
19 PDFNet.Stamper.VerticalAlignment.e_vertical_top
20 );
21 const font = await PDFNet.Font.create(
22 doc,
23 PDFNet.Font.StandardType1Font.e_courier
24 );
25 await stamper.setFont(font);
26 const redColorPt = await PDFNet.ColorPt.init(1, 0, 0, 0);
27 await stamper.setFontColor(redColorPt);
28 await stamper.setTextAlignment(PDFNet.Stamper.TextAlignment.e_align_right);
29 await stamper.setAsBackground(true);
30 const pgSet = await PDFNet.PageSet.createRange(1, 2);
31 await stamper.stampText(doc, "This is a title!", pgSet);
32
33 const img = await PDFNet.Image.createFromURL(doc, imagename);
34 await stamper.setAsBackground(false);
35 const pgSetImage = await PDFNet.PageSet.createRange(1, 1);
36 await stamper.stampImage(doc, img, pgSetImage);
37
38 const srcDoc = await PDFNet.PDFDoc.createFromURL(src_filename);
39 const srcPage = await srcDoc.getPage(1);
40 await stamper.stampPage(doc, srcPage, pgSet);
41}
42PDFNet.runWithCleanup(main);
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];
1$doc = new PDFDoc($filename);
2$s = new Stamper(Stamper::e_relative_scale, 0.05, 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(true);
7
8$s->SetAlignment(Stamper::e_horizontal_right, Stamper::e_vertical_bottom);
9$s->SetAlignment(Stamper::e_horizontal_center, Stamper::e_vertical_top);
10$s->SetFont(Font::Create($doc->GetSDFDoc(), Font::e_courier, true));
11$red = new ColorPt(1.0, 0.0, 0.0, 0.0);
12$s->SetFontColor($red); //set color to red
13$s->SetTextAlignment(Stamper::e_align_right);
14$s->SetAsBackground(true); //set text stamp as background
15$ps = new PageSet(1, 2);
16$s->StampText($doc, "This is a title!", $ps);
17
18$img = Image::Create($doc->GetSDFDoc(), $imagename);
19$s->SetAsBackground(false); // set image stamp as foreground
20$first_page_ps = new PageSet(1);
21$s->StampImage($doc, $img, $first_page_ps);
22
23$src_doc = new PDFDoc($src_filename);
24$src_page = $src_doc->GetPage(1);
25$s->StampPage($doc, $src_page, $ps);
1doc = PDFDoc(filename)
2s = Stamper(Stamper.e_relative_scale, 0.05, 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(true)
7
8s.SetAlignment(Stamper.e_horizontal_right, Stamper.e_vertical_bottom)
9s.SetAlignment(Stamper.e_horizontal_center, Stamper.e_vertical_top)
10s.SetFont(Font.Create(doc.GetSDFDoc(), Font.e_courier, True))
11red = ColorPt(1, 0, 0)
12s.SetFontColor(red) # set text color to red
13s.SetTextAlignment(Stamper.e_align_right)
14s.SetAsBackground(True) # set text stamp as background
15ps = PageSet(1, 2)
16s.StampText(doc, "This is a title!", ps)
17
18img = Image.Create(doc.GetSDFDoc(), imagename)
19s.SetAsBackground(False) # set image stamp as foreground
20first_page_ps = PageSet(1)
21s.StampImage(doc, img, first_page_ps)
22
23src_doc = PDFDoc(src_filename)
24src_page = src_doc.GetPage(1)
25s.StampPage(doc, src_page, ps)
1doc = PDFDoc.new(filename)
2s = Stamper.new(Stamper::E_relative_scale, 0.05, 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(true)
7
8s.SetAlignment(Stamper::E_horizontal_right, Stamper::E_vertical_bottom)
9s.SetAlignment(Stamper::E_horizontal_center, Stamper::E_vertical_top)
10s.SetFont(Font.Create(doc.GetSDFDoc, Font::E_courier, true))
11red = ColorPt.new(1, 0, 0)
12s.SetFontColor(red) # set text color to red
13s.SetTextAlignment(Stamper::E_align_right)
14s.SetAsBackground(true) # set text stamp as background
15ps = PageSet.new(1, 2)
16s.StampText(doc, "This is a title!", ps)
17
18img = Image.Create(doc.GetSDFDoc, imagename)
19s.SetAsBackground(false) # set image stamp as foreground
20first_page_ps = PageSet.new(1)
21s.StampImage(doc, img, first_page_ps)
22
23src_doc = PDFDoc.new(src_filename)
24src_page = src_doc.GetPage(1)
25s.StampPage(doc, src_page, ps)
1Dim doc As PDFDoc = New PDFDoc(filename)
2Dim s As Stamper = New Stamper(Stamper.SizeType.e_relative_scale, 0.05, 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(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
16Dim img As Image = Image.Create(doc.GetSDFDoc(), imagename)
17s.SetAsBackground(False) ' set image stamp as foreground
18s.StampImage(doc, img, New PageSet(1))
19
20Dim src_doc As PDFDoc = New PDFDoc(src_filename)
21Dim src_page As Page = src_doc.GetPage(1)
22s.StampPage(doc, src_page, New PageSet(1, 2))
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 .
Did you find this helpful?
Trial setup questions?
Ask experts on DiscordNeed other help?
Contact SupportPricing or product questions?
Contact Sales