public class Stamper
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
e_absolute_size
The Constant e_absolute_size.
|
static int |
e_align_center
The Constant e_align_center.
|
static int |
e_align_left
The Constant e_align_left.
|
static int |
e_align_right
The Constant e_align_right.
|
static int |
e_font_size
The Constant e_font_size.
|
static int |
e_horizontal_center
The Constant e_horizontal_center.
|
static int |
e_horizontal_left
The Constant e_horizontal_left.
|
static int |
e_horizontal_right
The Constant e_horizontal_right.
|
static int |
e_relative_scale
The Constant e_relative_scale.
|
static int |
e_vertical_bottom
The Constant e_vertical_bottom.
|
static int |
e_vertical_center
The Constant e_vertical_center.
|
static int |
e_vertical_top
The Constant e_vertical_top.
|
Constructor and Description |
---|
Stamper(int size_type,
double a,
double b)
Stamper constructor.
|
Modifier and Type | Method and Description |
---|---|
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,
java.lang.String src_txt,
PageSet dest_pages)
Stamps text to the given destination document at the set of page numbers.
|
public static final int e_relative_scale
public static final int e_absolute_size
public static final int e_font_size
public static final int e_horizontal_left
public static final int e_horizontal_center
public static final int e_horizontal_right
public static final int e_vertical_bottom
public static final int e_vertical_center
public static final int e_vertical_top
public static final int e_align_left
public static final int e_align_center
public static final int e_align_right
public Stamper(int size_type, double a, double b)
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 boxb
- height of the stamp bounding boxpublic void destroy()
public void stampImage(PDFDoc dest_doc, Image src_img, PageSet dest_pages)
dest_doc
- The document being stampedsrc_img
- The image that is being stamped to the documentdest_pages
- The set of pages in the document being stampedpublic void stampPage(PDFDoc dest_doc, Page src_page, PageSet dest_pages)
dest_doc
- The document being stampedsrc_page
- The page that is being stamped to the documentdest_pages
- The set of pages in the document being stampedpublic void stampText(PDFDoc dest_doc, java.lang.String src_txt, PageSet dest_pages)
dest_doc
- The document being stampedsrc_txt
- The image that is being stamped to the documentdest_pages
- The set of pages in the document being stampedpublic void setFont(Font font)
font
- The font of the text stamppublic void setFontColor(ColorPt color)
color
- the new font colorpublic void setOpacity(double opacity)
opacity
- The opacity value of the stamppublic void setRotation(double rotation)
rotation
- Rotation in degreespublic void setAsBackground(boolean background)
background
- A flag specifying if the stamp should be added as a background
layer to the destination pagepublic void setAsAnnotation(boolean 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 notpublic void showsOnScreen(boolean on_screen)
on_screen
- Specifies if the watermark will be displayed on screenpublic void showsOnPrint(boolean on_print)
on_print
- Specifies if the watermark will be displayed when printedpublic void setPosition(double horizontal_distance, double vertical_distance)
horizontal_distance
- Horizontal distance from left, right or center of crop box; in
pointsvertical_distance
- the vertical_distancesetAlignment(int, int)
public void setPosition(double horizontal_distance, double vertical_distance, boolean percentage)
horizontal_distance
- Horizontal distance from left, right or center of crop boxvertical_distance
- the vertical_distancepercentage
- 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.setAlignment(int, int)
public void setAlignment(int horizontal_alignment, int vertical_alignment)
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 boxvertical_alignment
- the vertical_alignmentsetPosition(double, double)
public void setTextAlignment(int text_alignment)
text_alignment
- Enumerator for text alignment (e_left, e_center, e_right)public void setSize(int size_type, double a, double b)
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 boxb
- height of the bounding boxpublic static void deleteStamps(PDFDoc doc, PageSet page_set)
doc
- The document to delete stamps frompage_set
- The set of pages to delete stamps from