PTStamper
@interface PTStamper : NSObject
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.
-
Stamper constructor
Declaration
Objective-C
- (instancetype)initWithSize_type:(PTSizeType)size_type a:(double)a b:(double)b;Swift
init!(size_type: PTSizeType, a: Double, b: Double)Parameters
size_typeSpecifies 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- see: size_type
b- see: size_type
-
Stamps an image to the given destination document at the set of page numbers
Declaration
Parameters
dest_docThe document being stamped
src_imgThe image that is being stamped to the document
dest_pagesThe set of pages in the document being stamped
-
Stamps a PDF page to the given destination document at the set of page numbers
Declaration
Parameters
dest_docThe document being stamped
src_pageThe page that is being stamped to the document
dest_pagesThe set of pages in the document being stamped
-
Stamps text to the given destination document at the set of page numbers
Declaration
Parameters
dest_docThe document being stamped
src_txtThe image that is being stamped to the document
dest_pagesThe set of pages in the document being stamped
-
Sets the opacity value for the stamp
Declaration
Objective-C
- (void)SetOpacity:(double)opacity;Swift
func setOpacity(_ opacity: Double)Parameters
opacityThe opacity value of the stamp
-
Rotates the stamp by the given number of degrees
Declaration
Objective-C
- (void)SetRotation:(double)rotation;Swift
func setRotation(_ rotation: Double)Parameters
rotationRotation in degrees
-
Specifies if the stamp is to be stamped in the background or the foreground.
Declaration
Objective-C
- (void)SetAsBackground:(BOOL)background;Swift
func setAsBackground(_ background: Bool)Parameters
backgroundA flag specifying if the stamp should be added as a background layer to the destination page
-
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.
Declaration
Objective-C
- (void)SetAsAnnotation:(BOOL)annotation;Swift
func setAsAnnotation(_ annotation: Bool)Parameters
annotationA flag specifying if the stamp should be added as an annotation or not
-
Declaration
Objective-C
- (void)ShowsOnScreen:(BOOL)on_screen;Swift
func shows(onScreen on_screen: Bool)Parameters
on_screenSpecifies if the watermark will be displayed on screen
-
Declaration
Objective-C
- (void)ShowsOnPrint:(BOOL)on_print;Swift
func shows(onPrint on_print: Bool)Parameters
on_printSpecifies if the watermark will be displayed when printed
-
Sets the horizontal and vertical position of the stamp.
See
SetAlignment
Declaration
Objective-C
- (void)SetPosition:(double)horizontal_distance vertical_distance:(double)vertical_distance use_percentage:(BOOL)use_percentage;Swift
func setPosition(_ horizontal_distance: Double, vertical_distance: Double, use_percentage: Bool)Parameters
horizontal_distanceHorizontal distance from left, right or center of crop box
vertical_distanceVertical distance from top, bottom or center of crop box
use_percentageIf 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.
-
Sets the alignment for the x and y variables.
See
SetPosition
Declaration
Objective-C
- (void)SetAlignment:(PTHorizontalAlignment)horizontal_alignment vertical_alignment:(PTVerticalAlignment)vertical_alignment;Swift
func setAlignment(_ horizontal_alignment: PTHorizontalAlignment, vertical_alignment: PTVerticalAlignment)Parameters
horizontal_alignmentCan 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_alignmentCan 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
-
Sets the text alignment (note: this only applies to text watermarks)
Declaration
Objective-C
- (void)SetTextAlignment:(PTTextAlignment)text_alignment;Swift
func setTextAlignment(_ text_alignment: PTTextAlignment)Parameters
text_alignmentEnumerator for text alignment (e_left, e_center, e_right)
-
Sets the size of the stamp
Declaration
Objective-C
- (void)SetSize:(PTSizeType)size_type a:(double)a b:(double)b;Swift
func setSize(_ size_type: PTSizeType, a: Double, b: Double)Parameters
size_typeSpecifies 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.aGenerally the horizontal component of the size. See size_type for more details.
bGenerally the vertical component of the size. See size_type for more details.
-
Deletes PDFTron stamps from document at given page numbers
Declaration
Parameters
docThe document to delete stamps from
page_setThe set of pages to delete stamps from
-
Returns true if the given set of pages has at least one stamp
Declaration
Parameters
docThe document that’s being checked
page_setThe set of page that’s being checked
PTStamper Class Reference