# Class: Stamper

## PDFNet. Stamper

#### new Stamper()

  Stamper is a utility class that can be used to stamp PDF pages with text, images, or vector art (including another PDF page) 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.

### Methods

#### <static> create(size_type, a, b)

  Stamper constructor

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `size_type` | number/enum |
      PDFNet.Stamper.SizeType = {
      	e_relative_scale : 1
      	e_absolute_size : 2
      	e_font_size : 3
      }
  Specifies how the stamp will be sized -e_relative_scale: Stamp size is relative to the size of the crop box of the destination page. 'a' is a percentage of the width of the crop box (e.g.: 0.5 is 50% of the width of the crop box) 'b' is a percentage of the height of the crop box. If 'a' <= 0 then only b will be used. If 'b' <= 0 then only 'a' will be used.
      	-e_absolute_scale: Stamp size is explicitly set. 'a' sets the width of
      	of the stamp's bounding box. 'b' sets the height of the stamp's bounding
      	box. The width and height are constant, regardless of the size of the
      	destination page's bounding box.

      	-e_font_size: This type only applies to text stamps. 'a' sets the font
      	size. 'b' is ignored.
  `a` | number | @see size_type
  `b` | number | @see size_type

  ##### Returns:

  A promise that resolves to an object of type: "Stamper"

  Type
    PDFNet.Stamper

#### <static> deleteStamps(doc, page_set)

  Deletes PDFTron stamps from document at given page numbers

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `doc` | PDFNet.PDFDoc | The document to delete stamps from
  `page_set` | PDFNet.PageSet | The set of pages to delete stamps from

#### <static> hasStamps(doc, page_set)

  Returns true if the given set of pages has at least one stamp

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `doc` | PDFNet.PDFDoc | The document that's being checked
  `page_set` | PDFNet.PageSet | The set of page that's being checked

  ##### Returns:

  A promise that resolves to an unknown type

#### destroy()

  Frees the native memory of the object.

#### setAlignment(horizontal_alignment, vertical_alignment)

  Sets the alignment for the x and y variables.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `horizontal_alignment` | number/enum |
      PDFNet.Stamper.HorizontalAlignment = {
      	e_horizontal_left : -1
      	e_horizontal_center : 0
      	e_horizontal_right : 1
      }
  Can be set to e_left, e_center or e_right e_left: horizontal_distance measures the distance between the left edge of the stamp's bounding box and the left edge of the crop box e_center: horizontal_distance measures the distance between the horizontal bisector of the stamp's bounding box and the horizontal bisector of the crop box e_right: horizontal_distance measures the distance between the right edge of the stamp's bounding box and the right edge of the crop box
  `vertical_alignment` | number/enum |
      PDFNet.Stamper.VerticalAlignment = {
      	e_vertical_bottom : -1
      	e_vertical_center : 0
      	e_vertical_top : 1
      }
  Can be set to e_top, e_center or e_bottom e_bottom: vertical_distance measures the distance between the bottom edge of the stamp's bounding box and the bottom edge of the crop box e_center: vertical_distance measures the distance between the vertical bisector of the stamp's bounding box and the vertical bisector of the crop box e_top: vertical_distance measures the distance between the top edge of the stamp's bounding box and the top edge of the crop box

  See:
    - SetPosition

#### setAsAnnotation(annotation)

  Specifies if the stamp is to be stamped as an annotation.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `annotation` | boolean | A flag specifying if the stamp should be added as an annotation or not

#### setAsBackground(background)

  Specifies if the stamp is to be stamped in the background or the foreground.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `background` | boolean | A flag specifying if the stamp should be added as a background layer to the destination page

#### setFont(font)

  Defines the font of the stamp. (This only applies to text-based stamps)

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `font` | PDFNet.Font | The font of the text stamp

#### setFontColor(font_color)

  Sets the font color (This only effects text-based stamps)

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `font_color` | PDFNet.colorpt | The color of the font

#### setOpacity(opacity)

  Sets the opacity value for the stamp

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `opacity` | number | The opacity value of the stamp

#### setPosition(x, y, use_percentage)

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `x` | number |
  `y` | number |
  `use_percentage` | boolean |

#### setRotation(rotation)

  Rotates the stamp by the given number of degrees

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `rotation` | number | Rotation in degrees

#### setSize(size_type, a, b)

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `size_type` | number/enum |
      PDFNet.Stamper.SizeType = {
      	e_relative_scale : 1
      	e_absolute_size : 2
      	e_font_size : 3
      }
  `a` | number |
  `b` | number |

#### setTextAlignment(text_alignment)

  Sets the text alignment (note: this only applies to text watermarks)

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `text_alignment` | number/enum |
      PDFNet.Stamper.TextAlignment = {
      	e_align_left : -1
      	e_align_center : 0
      	e_align_right : 1
      }
  Enumerator for text alignment (e_left, e_center, e_right)

#### showsOnPrint(on_print)

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `on_print` | boolean | Specifies if the watermark will be displayed when printed

#### showsOnScreen(on_screen)

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `on_screen` | boolean | Specifies if the watermark will be displayed on screen

#### stampImage(dest_doc, img, dest_pages)

  Stamps an image to the given destination document at the set of page numbers

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `dest_doc` | PDFNet.PDFDoc | The document being stamped
  `img` | PDFNet.Image | The image that is being stamped to the document
  `dest_pages` | PDFNet.PageSet | The set of pages in the document being stamped

#### stampPage(dest_doc, page, dest_pages)

  Stamps a PDF page to the given destination document at the set of page numbers

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `dest_doc` | PDFNet.PDFDoc | The document being stamped
  `page` | PDFNet.Page | The page that is being stamped to the document
  `dest_pages` | PDFNet.PageSet | The set of pages in the document being stamped

#### stampText(dest_doc, txt, dest_pages)

  Stamps text to the given destination document at the set of page numbers

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `dest_doc` | PDFNet.PDFDoc | The document being stamped
  `txt` | string | The image that is being stamped to the document
  `dest_pages` | PDFNet.PageSet | The set of pages in the document being stamped

#### Search results