#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) |
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.
pdftron::PDF::Stamper::Stamper | ( | SizeType | size_type, |
double | a, | ||
double | b | ||
) |
Stamper constructor
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.
a |
b |
pdftron::PDF::Stamper::~Stamper | ( | ) |
Stamper default destructor
Deletes PDFTron stamps from document at given page numbers
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.
Returns true if the given set of pages has at least one stamp
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.
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.
annotation | A flag specifying if the stamp should be added as an annotation or not |
void pdftron::PDF::Stamper::SetAsBackground | ( | bool | background | ) |
Specifies if the stamp is to be stamped in the background or the foreground.
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)
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)
font_color | The color of the font |
void pdftron::PDF::Stamper::SetOpacity | ( | double | opacity | ) |
Sets the opacity value for the stamp
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.
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
rotation | Rotation in degrees |
void pdftron::PDF::Stamper::SetSize | ( | SizeType | size_type, |
double | a, | ||
double | b | ||
) |
Sets the size of the stamp
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.
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)
text_alignment | Enumerator for text alignment (e_left, e_center, e_right) |
void pdftron::PDF::Stamper::ShowsOnPrint | ( | bool | on_print | ) |
on_print | Specifies if the watermark will be displayed when printed |
void pdftron::PDF::Stamper::ShowsOnScreen | ( | bool | on_screen | ) |
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
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
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
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 |