Show / Hide Table of Contents

# Class 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.

##### Inheritance

object
Stamper

##### Implements

IDisposable

##### Inherited Members

object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()

###### Namespace: pdftron.PDF

###### Assembly: PDFTronDotNet.dll

##### Syntax

    public class Stamper : IDisposable

### Constructors

#### Stamper(SizeType, double, double)

Stamper constructor.

##### Declaration

    public Stamper(Stamper.SizeType size_type, double a, double b)

##### Parameters

Type | Name | Description
--- | --- | ---
Stamper.SizeType | size_type | Specifies how the stamp will be sized. See the link Enum Stamper.SizeType on the left for more details.
double | a | Generally the horizontal component of the size. See size_type for more details.
double | b | Generally the vertical component of the size. See size_type for more details.

### Methods

#### DeleteStamps(PDFDoc, PageSet)

Deletes PDFTron stamps from document at given page numbers.

##### Declaration

    public static void DeleteStamps(PDFDoc doc, PageSet page_set)

##### Parameters

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

#### Destroy()

##### Declaration

    public void Destroy()

#### Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

##### Declaration

    public void Dispose()

#### Dispose(bool)

##### Declaration

    protected virtual void Dispose(bool disposing)

##### Parameters

Type | Name | Description
--- | --- | ---
bool | disposing |

#### ~Stamper()

##### Declaration

    protected ~Stamper()

#### HasStamps(PDFDoc, PageSet)

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

##### Declaration

    public static bool HasStamps(PDFDoc doc, PageSet page_set)

##### Parameters

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

##### Returns

Type | Description
--- | ---
bool | true, if successful

#### SetAlignment(HorizontalAlignment, VerticalAlignment)

Sets the alignment for the x and y variables.

##### Declaration

    public void SetAlignment(Stamper.HorizontalAlignment horizontal_alignment, Stamper.VerticalAlignment vertical_alignment)

##### Parameters

Type | Name | Description
--- | --- | ---
Stamper.HorizontalAlignment | horizontal_alignment | the horizontal alignment
Stamper.VerticalAlignment | vertical_alignment | the vertical alignment

##### See Also

SetPosition(double, double, bool)

#### SetAsAnnotation(bool)

Specifies if the stamp is to be stamped as annotation or not.

##### Declaration

    public void SetAsAnnotation(bool annotation)

##### Parameters

Type | Name | Description
--- | --- | ---
bool | annotation | A flag specifying if the stamp should be added as an annotation to the destination page

##### Remarks

SetAsBackground, HasStamps and DeleteStamps methods will not work on stamps created with this as true.

#### SetAsBackground(bool)

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

##### Declaration

    public void SetAsBackground(bool background)

##### Parameters

Type | Name | Description
--- | --- | ---
bool | background | 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)

##### Declaration

    public void SetFont(Font font)

##### Parameters

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

#### SetFontColor(ColorPt)

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

##### Declaration

    public void SetFontColor(ColorPt color)

##### Parameters

Type | Name | Description
--- | --- | ---
ColorPt | color | the new font color

#### SetOpacity(double)

Sets the opacity value for the stamp.

##### Declaration

    public void SetOpacity(double opacity)

##### Parameters

Type | Name | Description
--- | --- | ---
double | opacity | The opacity value of the stamp

#### SetPosition(double, double, bool)

Sets the horizontal and vertical position of the stamp.

##### Declaration

    public void SetPosition(double horizontal_distance, double vertical_distance, bool percentage = false)

##### Parameters

Type | Name | Description
--- | --- | ---
double | horizontal_distance | Horizontal distance from left, right or center of crop box
double | vertical_distance | the vertical_distance
bool | percentage | If true, horizontal_distance is a percentage of the crop box width (e.g.: 0.5 is 50% of the width of the crop box) and vertical_distance is a percentage of the crop box height. If false, horizontal_distance and vertical_distance is measured in points.

##### See Also

SetAlignment(HorizontalAlignment, VerticalAlignment)

#### SetRotation(double)

Rotates the stamp by the given number of degrees.

##### Declaration

    public void SetRotation(double rotation)

##### Parameters

Type | Name | Description
--- | --- | ---
double | rotation | Rotation in degrees

#### SetSize(SizeType, double, double)

Sets the size of the stamp.

##### Declaration

    public void SetSize(Stamper.SizeType size_type, double a, double b)

##### Parameters

Type | Name | Description
--- | --- | ---
Stamper.SizeType | size_type | Specifies how the stamp will be sized
double | a | the a
double | b | the b

#### SetTextAlignment(TextAlignment)

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

##### Declaration

    public void SetTextAlignment(Stamper.TextAlignment text_alignment)

##### Parameters

Type | Name | Description
--- | --- | ---
Stamper.TextAlignment | text_alignment | Enumerator for text alignment (e_left, e_center, e_right)

#### ShowsOnPrint(bool)

Shows on print.

##### Declaration

    public void ShowsOnPrint(bool on_print)

##### Parameters

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

#### ShowsOnScreen(bool)

Shows on screen.

##### Declaration

    public void ShowsOnScreen(bool on_screen)

##### Parameters

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

#### StampImage(PDFDoc, Image, PageSet)

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

##### Declaration

    public void StampImage(PDFDoc dest_doc, Image src_img, PageSet dest_pages)

##### Parameters

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

#### StampPage(PDFDoc, Page, PageSet)

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

##### Declaration

    public void StampPage(PDFDoc dest_doc, Page src_page, PageSet dest_pages)

##### Parameters

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

#### StampText(PDFDoc, string, PageSet)

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

##### Declaration

    public void StampText(PDFDoc dest_doc, string src_txt, PageSet dest_pages)

##### Parameters

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

### Implements

IDisposable