java.lang.Object | |
↳ | com.pdftron.pdf.Stamper |
Stamper is a utility class that can be used to 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.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | e_absolute_size | The Constant e_absolute_size. | |||||||||
int | e_align_center | The Constant e_align_center. | |||||||||
int | e_align_left | The Constant e_align_left. | |||||||||
int | e_align_right | The Constant e_align_right. | |||||||||
int | e_font_size | The Constant e_font_size. | |||||||||
int | e_horizontal_center | The Constant e_horizontal_center. | |||||||||
int | e_horizontal_left | The Constant e_horizontal_left. | |||||||||
int | e_horizontal_right | The Constant e_horizontal_right. | |||||||||
int | e_relative_scale | The Constant e_relative_scale. | |||||||||
int | e_vertical_bottom | The Constant e_vertical_bottom. | |||||||||
int | e_vertical_center | The Constant e_vertical_center. | |||||||||
int | e_vertical_top | The Constant e_vertical_top. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Stamper(int size_type, double a, double b)
Stamper constructor.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void |
close()
Frees the native memory of the object.
| ||||||||||
static void |
deleteStamps(PDFDoc doc, PageSet page_set)
Deletes PDFTron stamps from document at given page numbers.
| ||||||||||
void |
destroy()
Frees the native memory of the object.
| ||||||||||
static boolean |
hasStamps(PDFDoc doc, PageSet page_set)
Returns true if the given set of pages has at least one stamp.
| ||||||||||
void |
setAlignment(int horizontal_alignment, int vertical_alignment)
Set the alignment for the x and y variables.
| ||||||||||
void |
setAsAnnotation(boolean annotation)
Specifies if the stamp is to be stamped as an annotation.
| ||||||||||
void |
setAsBackground(boolean background)
Specifies if the stamp is to be stamped in the background or the
foreground.
| ||||||||||
void |
setFont(Font font)
Defines the font of the stamp.
| ||||||||||
void |
setFontColor(ColorPt color)
Set the font color (This only effects text-based stamps).
| ||||||||||
void |
setOpacity(double opacity)
Set the opacity value for the stamp.
| ||||||||||
void |
setPosition(double horizontal_distance, double vertical_distance)
Set the horizontal and vertical position of the stamp.
| ||||||||||
void |
setPosition(double horizontal_distance, double vertical_distance, boolean percentage)
Set the horizontal and vertical position of the stamp.
| ||||||||||
void |
setRotation(double rotation)
Rotates the stamp by the given number of degrees.
| ||||||||||
void |
setSize(int size_type, double a, double b)
Set the size of the stamp.
| ||||||||||
void |
setTextAlignment(int text_alignment)
Set the text alignment (note: this only applies to text watermarks).
| ||||||||||
void |
showsOnPrint(boolean on_print)
Shows on print.
| ||||||||||
void |
showsOnScreen(boolean on_screen)
Shows on screen.
| ||||||||||
void |
stampImage(PDFDoc dest_doc, Image src_img, PageSet dest_pages)
Stamps an image to the given destination document at the set of page
numbers.
| ||||||||||
void |
stampPage(PDFDoc dest_doc, Page src_page, PageSet dest_pages)
Stamps a PDF page to the given destination document at the set of page
numbers.
| ||||||||||
void |
stampText(PDFDoc dest_doc, String src_txt, PageSet dest_pages)
Stamps text to the given destination document at the set of page numbers.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
java.lang.AutoCloseable
|
The Constant e_absolute_size.
The Constant e_align_center.
The Constant e_align_left.
The Constant e_align_right.
The Constant e_font_size.
The Constant e_horizontal_center.
The Constant e_horizontal_left.
The Constant e_horizontal_right.
The Constant e_relative_scale.
The Constant e_vertical_bottom.
The Constant e_vertical_center.
The Constant e_vertical_top.
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 | width of the stamp bounding box |
b | height of the stamp bounding box |
Frees the native memory of the object. This can be explicity called to control the deallocation of native memory and avoid situations where the garbage collector does not free the object in a timely manner.
PDFNetException |
---|
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 |
Frees the native memory of the object. This can be explicity called to control the deallocation of native memory and avoid situations where the garbage collector does not free the object in a timely manner.
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 |
Set 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 | the vertical_alignment |
Specifies if the stamp is to be stamped as an annotation.
Note: Stamps created with this setting do not work with SetAsBackground, HasStamps, and DeleteStamps, if annotation is true.
annotation | A flag specifying if the stamp should be added as an annotation or not |
---|
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 |
---|
Defines the font of the stamp. (This only applies to text-based stamps)
font | The font of the text stamp |
---|
Set the font color (This only effects text-based stamps).
color | the new font color |
---|
Set the opacity value for the stamp.
opacity | The opacity value of the stamp |
---|
Set the horizontal and vertical position of the stamp.
horizontal_distance | Horizontal distance from left, right or center of crop box; in points |
---|---|
vertical_distance | the vertical_distance |
Set the horizontal and vertical position of the stamp.
horizontal_distance | Horizontal distance from left, right or center of crop box |
---|---|
vertical_distance | the vertical_distance |
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. |
Rotates the stamp by the given number of degrees.
rotation | Rotation in degrees |
---|
Set 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 | width of the bounding box |
b | height of the bounding box |
Set the text alignment (note: this only applies to text watermarks).
text_alignment | Enumerator for text alignment (e_left, e_center, e_right) |
---|
Shows on print.
on_print | Specifies if the watermark will be displayed when printed |
---|
Shows on screen.
on_screen | Specifies if the watermark will be displayed on screen |
---|
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 |
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 |
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 |