> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/core/annotation/stamp-annotation.md).

# Add a stamp annotation to a PDF on Server/Desktop

Stamp PDF Pages: Learn how to add text, images, or other PDF pages to your documents with Apryse SDK. Explore the benefits of stamping and embedding content easily. Full code sample available for seam

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.

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
PDFDoc doc = new PDFDoc(filename);
Stamper s = new Stamper(Stamper.SizeType.e_relative_scale, .05, .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.HorizontalAlignment.e_horizontal_right, Stamper.VerticalAlignment.e_vertical_bottom);
s.SetAlignment(Stamper.HorizontalAlignment.e_horizontal_center, Stamper.VerticalAlignment.e_vertical_top);
s.SetFont(Font.Create(doc, Font.StandardType1Font.e_courier, true));
s.SetFontColor(new ColorPt(1, 0, 0, 0)); //set color to red
s.SetTextAlignment(Stamper.TextAlignment.e_align_right);
s.SetAsBackground(true); //set text stamp as background
s.StampText(doc, "This is a title!", new PageSet(1, 2));

Image img = Image.Create(doc, imagename);
s.SetAsBackground(false); // set image stamp as foreground
s.StampImage(doc, img, new PageSet(1));

PDFDoc src_doc = new PDFDoc(src_filename);
Page src_page = src_doc.GetPage(1);
s.StampPage(doc, src_page, new PageSet(1));
```

{% endcode %}
{% endtab %}

{% tab title="C++" %}
{% code lineNumbers="true" %}

```cpp
PDFDoc doc(filename);
Stamper s(Stamper::e_relative_scale, .05, .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, Font::e_courier, true));
ColorPt red(1, 0, 0, 0);
s.SetFontColor(red); //set color to red
s.SetTextAlignment(Stamper::e_align_right);
s.SetAsBackground(true); //set text stamp as background
PageSet ps(1, 2);
s.StampText(doc, "This is a title!", ps);

Image img = Image::Create(doc, imagename);
s.SetAsBackground(false); // set image stamp as foreground
PageSet first_page_ps(1);
s.StampImage(doc, img, first_page_ps);

PDFDoc src_doc(src_filename);
Page src_page = src_doc.GetPage(1);
s.StampPage(doc, src_page, first_page_ps);
```

{% endcode %}
{% endtab %}

{% tab title="Go" %}
{% code lineNumbers="true" %}

```go
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.SetAsAnnotation(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.SetFontColor(red)
s.StampText(doc, "This is a title!", NewPageSet(1, doc.GetPageCount()))

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

src_doc := NewPDFDoc(src_filename)
srcPage := src_doc.GetPage(1)
s.StampPage(doc, srcPage, ps)
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
PDFDoc doc = new PDFDoc(filename);
Stamper s = new Stamper(Stamper.e_relative_scale, .05, .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, Font.e_courier, true));
ColorPt red = new ColorPt(1, 0, 0, 0);
s.setFontColor(red); //set color to red
s.setTextAlignment(Stamper.e_align_right);
s.setAsBackground(true); //set text stamp as background
PageSet ps = new PageSet(1, 2);
s.stampText(doc, "This is a title!", ps);

Image img = Image.create(doc, imagename);
s.setAsBackground(false); // set image stamp as foreground
PageSet first_page_ps = new PageSet(1);
s.stampImage(doc, img, first_page_ps);

PDFDoc src_doc = new PDFDoc(src_filename);
Page src_page = src_doc.getPage(1);
s.stampPage(doc, src_page, first_page_ps);
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
async function main() {
  const doc = await PDFNet.PDFDoc.createFromURL(filename);
  const stamper = await PDFNet.Stamper.create(
    PDFNet.Stamper.SizeType.e_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.
  //stamper.setAsAnnotation(true);

  await stamper.setAlignment(
    PDFNet.Stamper.HorizontalAlignment.e_horizontal_right,
    PDFNet.Stamper.VerticalAlignment.e_vertical_bottom
  );
  await stamper.setAlignment(
    PDFNet.Stamper.HorizontalAlignment.e_horizontal_center,
    PDFNet.Stamper.VerticalAlignment.e_vertical_top
  );
  const font = await PDFNet.Font.create(
    doc,
    PDFNet.Font.StandardType1Font.e_courier
  );
  await stamper.setFont(font);
  const redColorPt = await PDFNet.ColorPt.init(1, 0, 0, 0);
  await stamper.setFontColor(redColorPt);
  await stamper.setTextAlignment(PDFNet.Stamper.TextAlignment.e_align_right);
  await stamper.setAsBackground(true);
  const pgSet = await PDFNet.PageSet.createRange(1, 2);
  await stamper.stampText(doc, "This is a title!", pgSet);

  const img = await PDFNet.Image.createFromURL(doc, imagename);
  await stamper.setAsBackground(false);
  const pgSetImage = await PDFNet.PageSet.createRange(1, 1);
  await stamper.stampImage(doc, img, pgSetImage);

  const srcDoc = await PDFNet.PDFDoc.createFromURL(src_filename);
  const srcPage = await srcDoc.getPage(1);
  await stamper.stampPage(doc, srcPage, pgSet);
}
PDFNet.runWithCleanup(main);
```

{% endcode %}
{% endtab %}

{% tab title="Kotlin" %}
{% code lineNumbers="true" %}

```kotlin
val doc = PDFDoc(filename)
val s = Stamper(Stamper.e_relative_scale, .05, .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, Font.e_courier, true))
val red = ColorPt(1.0, 0.0, 0.0, 0.0)
s.setFontColor(red) //set color to red
s.setTextAlignment(Stamper.e_align_right)
s.setAsBackground(true) //set text stamp as background
val ps = PageSet(1, 2)
s.stampText(doc, "This is a title!", ps)

val img = Image.create(doc, imagename)
s.setAsBackground(false) // set image stamp as foreground
val first_page_ps = PageSet(1)
s.stampImage(doc, img, first_page_ps)

val src_doc = PDFDoc(src_filename)
val src_page = src.getPage(1)
s.stampPage(doc, src_page, ps)
```

{% endcode %}
{% endtab %}

{% tab title="Obj-C" %}
{% code lineNumbers="true" %}

```objc
PTPDFDoc *doc = [[PTPDFDoc alloc] initWithFilepath: filename];
PTStamper *s = [[PTStamper alloc] initWithSize_type: e_ptrelative_scale a: 0.05 b: 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: YES];

[s SetAlignment: e_pthorizontal_right vertical_alignment: e_ptvertical_bottom];
[s SetAlignment: e_pthorizontal_center vertical_alignment: e_ptvertical_top];
[s SetFont: [PTFont Create: [doc GetSDFDoc] type: e_ptcourier embed: YES]];
PTColorPt *red = [[PTColorPt alloc] initWithX: 1 y: 0 z: 0 w: 0];
[s SetFontColor: red]; //set color to red
[s SetTextAlignment: e_ptalign_right];
[s SetAsBackground: YES]; //set text stamp as background
PTPageSet *ps = [[PTPageSet alloc] initWithRange_start: 1 range_end: 2 filter: e_ptall];
[s StampText: doc src_txt: @"This is a title!" dest_pages: ps];

PTImage *img = [PTImage Create: [doc GetSDFDoc] filename: imagename];
[s SetAsBackground: NO]; // set image stamp as foreground
PTPageSet *first_page_ps = [[PTPageSet alloc] initWithOne_page: 1];
[s StampImage: doc src_img: img dest_pages: first_page_ps];

PTPDFDoc *src_doc = [[PTPDFDoc alloc ] initWithFilepath: src_filename];
PTPage *src_page = [src_doc GetPage: 1];
[s StampPage: doc src_page: src_page dest_pages: ps];
```

{% endcode %}
{% endtab %}

{% tab title="Swift" %}
{% code lineNumbers="true" %}

```swift
let doc: PTPDFDoc = PTPDFDoc(filepath: filename)
let s: PTStamper = PTStamper(size_type: e_ptrelative_scale, a: 0.05, b: 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(e_pthorizontal_right, vertical_alignment: e_ptvertical_bottom)
s.setAlignment(e_pthorizontal_center, vertical_alignment: e_ptvertical_top)
s.setFont(PTFont.create(doc.getSDFDoc(), type: e_ptcourier, embed: true))
let red = PTColorPt(x: 1, y: 0, z: 0, w: 0)
s.setFontColor(red) //set color to red
s.setTextAlignment(e_ptalign_right)
s.setAsBackground(true) //set text stamp as background
let ps = PTPageSet(range_start: 1, range_end: 2, filter: e_ptall)
s.stampText(doc, src_txt: "This is a title!", dest_pages: ps)

let img = PTImage.create(doc.getSDFDoc(), filename: imagename)
s.setAsBackground(false)    // set image stamp as foreground
let first_page_ps = PTPageSet(one_page: 1)
s.stampImage(doc, src_img: img, dest_pages: first_page_ps)

let src_doc: PTPDFDoc = PTPDFDoc(filepath: src_filename)
let src_page: PTPage = src_doc.getPage(1)
s.stampPage(doc, src_page: src_page, dest_pages: ps)
```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}
{% code lineNumbers="true" %}

```php
$doc = new PDFDoc($filename);
$s = new 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 = new ColorPt(1.0, 0.0, 0.0, 0.0);
$s->SetFontColor($red); //set color to red
$s->SetTextAlignment(Stamper::e_align_right);
$s->SetAsBackground(true); //set text stamp as background
$ps = new 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 = new PageSet(1);
$s->StampImage($doc, $img, $first_page_ps);

$src_doc = new PDFDoc($src_filename);
$src_page = $src_doc->GetPage(1);
$s->StampPage($doc, $src_page, $ps);
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
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)
```

{% endcode %}
{% endtab %}

{% tab title="Ruby" %}
{% code lineNumbers="true" %}

```ruby
doc = PDFDoc.new(filename)
s = Stamper.new(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.new(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.new(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.new(1)
s.StampImage(doc, img, first_page_ps)

src_doc = PDFDoc.new(src_filename)
src_page = src_doc.GetPage(1)
s.StampPage(doc, src_page, ps)
```

{% endcode %}
{% endtab %}

{% tab title="VB" %}
{% code lineNumbers="true" %}

```vb
Dim doc As PDFDoc = New PDFDoc(filename)
Dim s As Stamper = New Stamper(Stamper.SizeType.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.HorizontalAlignment.e_horizontal_right, Stamper.VerticalAlignment.e_vertical_bottom)
s.SetAlignment(Stamper.HorizontalAlignment.e_horizontal_center, Stamper.VerticalAlignment.e_vertical_top)
s.SetFont(Font.Create(doc, Font.StandardType1Font.e_courier, True))
s.SetFontColor(New ColorPt(1, 0, 0, 0))	'set color to red
s.SetTextAlignment(Stamper.TextAlignment.e_align_right)
s.SetAsBackground(True)	'set text stamp as background
s.StampText(doc, "This is a title!", New PageSet(1, 2))

Dim img As Image = Image.Create(doc.GetSDFDoc(), imagename)
s.SetAsBackground(False) ' set image stamp as foreground
s.StampImage(doc, img, New PageSet(1))

Dim src_doc As PDFDoc = New PDFDoc(src_filename)
Dim src_page As Page = src_doc.GetPage(1)
s.StampPage(doc, src_page, New PageSet(1, 2))
```

{% endcode %}
{% endtab %}
{% endtabs %}

[Stamp a PDF File - Full Sample](/core/get-started/samples/stampertest.md) 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). Code sample is available in C++, C#, Java, Python, Go, PHP, Ruby & VB.

## 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 ](/core/get-started/samples/elementbuildertest.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/core/annotation/stamp-annotation.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
