- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Static Public Member Functions | List of all members
pdftron::PDF::Stamper Class Reference

`#include <Stamper.h>`

## Public Types
enum | SizeType { e_relative_scale = 1, e_absolute_size = 2, e_font_size = 3 }
enum | HorizontalAlignment { e_horizontal_left = -1, e_horizontal_center = 0, e_horizontal_right = 1 }
enum | VerticalAlignment { e_vertical_bottom = -1, e_vertical_center = 0, e_vertical_top = 1 }
enum | TextAlignment { e_align_left = -1, e_align_center = 0, e_align_right = 1 }

## Public Member Functions
| Stamper (SizeType size_type, double a, double b)
| ~Stamper ()
void | StampImage (PDFDoc &dest_doc, Image src_img, const PageSet &dest_pages)
void | StampPage (PDFDoc &dest_doc, Page src_page, const PageSet &dest_pages)
void | StampText (PDFDoc &dest_doc, const UString &src_txt, const PageSet &dest_pages)
void | SetFont (Font font)
void | SetFontColor (const ColorPt &color)
void | SetOpacity (double opacity)
void | SetRotation (double rotation)
void | SetAsBackground (bool background)
void | SetAsAnnotation (bool annotation)
void | ShowsOnScreen (bool on_screen)
void | ShowsOnPrint (bool on_print)
void | SetPosition (double horizontal_distance, double vertical_distance, bool use_percentage=false)
void | SetAlignment (HorizontalAlignment horizontal_alignment, VerticalAlignment vertical_alignment)
void | SetTextAlignment (TextAlignment text_alignment)
void | SetSize (SizeType size_type, double a, double b)
void | Destroy ()

## Static Public Member Functions
static void | DeleteStamps (PDFDoc &doc, const PageSet &page_set)
static bool | HasStamps (PDFDoc &doc, const PageSet &page_set)

## Detailed Description

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.

Definition at line 30 of file Stamper.h.

## Member Enumeration Documentation

enum pdftron::PDF::Stamper::HorizontalAlignment

Enumerator
e_horizontal_left |
e_horizontal_center |
e_horizontal_right |

Definition at line 41 of file Stamper.h.

enum pdftron::PDF::Stamper::SizeType

Enumerator
e_relative_scale |
e_absolute_size |
e_font_size |

Definition at line 34 of file Stamper.h.

enum pdftron::PDF::Stamper::TextAlignment

Enumerator
e_align_left |
e_align_center |
e_align_right |

Definition at line 55 of file Stamper.h.

enum pdftron::PDF::Stamper::VerticalAlignment

Enumerator
e_vertical_bottom |
e_vertical_center |
e_vertical_top |

Definition at line 48 of file Stamper.h.

## Constructor & Destructor Documentation

pdftron::PDF::Stamper::Stamper | ( | SizeType | size_type,
|  | double | a,
|  | double | b
| ) |  |

Stamper constructor

Parameters

  size_type | 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.

Parameters

  a |

See Also
  size_type

Parameters

  b |

See Also
  size_type

pdftron::PDF::Stamper::~Stamper | ( |  | ) |

Stamper default destructor

## Member Function Documentation

static void pdftron::PDF::Stamper::DeleteStamps | ( | PDFDoc & | doc,
|  | const PageSet & | page_set
| ) |  |
| static

Deletes PDFTron stamps from document at given page numbers

Parameters

  doc | The document to delete stamps from
  page_set | The set of pages to delete stamps from

void pdftron::PDF::Stamper::Destroy | ( |  | ) |

Frees the native memory of the object.

static bool pdftron::PDF::Stamper::HasStamps | ( | PDFDoc & | doc,
|  | const PageSet & | page_set
| ) |  |
| static

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

Parameters

  doc | The document that's being checked
  page_set | The set of page that's being checked

void pdftron::PDF::Stamper::SetAlignment | ( | HorizontalAlignment | horizontal_alignment,
|  | VerticalAlignment | vertical_alignment
| ) |  |

Sets the alignment for the x and y variables.

See Also
  SetPosition

Parameters

  horizontal_alignment | 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 | 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

void pdftron::PDF::Stamper::SetAsAnnotation | ( | bool | annotation | ) |

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

Parameters

  annotation | A flag specifying if the stamp should be added as an annotation or not

Note
  Stamps created with this setting do not work with SetAsBackground, HasStamps, and DeleteStamps, if annotation is true.

void pdftron::PDF::Stamper::SetAsBackground | ( | bool | background | ) |

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

Parameters

  background | A flag specifying if the stamp should be added as a background layer to the destination page

void pdftron::PDF::Stamper::SetFont | ( | Font | font | ) |

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

Parameters

  font | The font of the text stamp

void pdftron::PDF::Stamper::SetFontColor | ( | const ColorPt & | color | ) |

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

Parameters

  font_color | The color of the font

void pdftron::PDF::Stamper::SetOpacity | ( | double | opacity | ) |

Sets the opacity value for the stamp

Parameters

  opacity | The opacity value of the stamp

void pdftron::PDF::Stamper::SetPosition | ( | double | horizontal_distance,
|  | double | vertical_distance,
|  | bool | use_percentage = `false`
| ) |  |

Sets the horizontal and vertical position of the stamp.

See Also
  SetAlignment

Parameters

  horizontal_distance | Horizontal distance from left, right or center of crop box
  vertical_distance | Vertical distance from top, bottom or center of crop box
  use_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.

void pdftron::PDF::Stamper::SetRotation | ( | double | rotation | ) |

Rotates the stamp by the given number of degrees

Parameters

  rotation | Rotation in degrees

void pdftron::PDF::Stamper::SetSize | ( | SizeType | size_type,
|  | double | a,
|  | double | b
| ) |  |

Sets the size of the stamp

Parameters

  size_type | 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.

Parameters

  a | Generally the horizontal component of the size. See size_type for more details.
  b | Generally the vertical component of the size. See size_type for more details.

void pdftron::PDF::Stamper::SetTextAlignment | ( | TextAlignment | text_alignment | ) |

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

Parameters

  text_alignment | Enumerator for text alignment (e_left, e_center, e_right)

void pdftron::PDF::Stamper::ShowsOnPrint | ( | bool | on_print | ) |

Parameters

  on_print | Specifies if the watermark will be displayed when printed

void pdftron::PDF::Stamper::ShowsOnScreen | ( | bool | on_screen | ) |

Parameters

  on_screen | Specifies if the watermark will be displayed on screen

void pdftron::PDF::Stamper::StampImage | ( | PDFDoc & | dest_doc,
|  | Image | src_img,
|  | const PageSet & | dest_pages
| ) |  |

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

Parameters

  dest_doc | The document being stamped
  src_img | The image that is being stamped to the document
  dest_pages | The set of pages in the document being stamped

void pdftron::PDF::Stamper::StampPage | ( | PDFDoc & | dest_doc,
|  | Page | src_page,
|  | const PageSet & | dest_pages
| ) |  |

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

Parameters

  dest_doc | The document being stamped
  src_page | The page that is being stamped to the document
  dest_pages | The set of pages in the document being stamped

void pdftron::PDF::Stamper::StampText | ( | PDFDoc & | dest_doc,
|  | const UString & | src_txt,
|  | const PageSet & | dest_pages
| ) |  |

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

Parameters

  dest_doc | The document being stamped
  src_txt | The image that is being stamped to the document
  dest_pages | The set of pages in the document being stamped

The documentation for this class was generated from the following file:

- PDF/Stamper.h