Class PDFNet.Stamper
PDFNet.Stamper
Constructor Attributes | Constructor Name and Description |
---|---|
PDFNet.Stamper(id)
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.
|
Method Attributes | Method Name and Description |
---|---|
<static> |
PDFNet.Stamper.create(size_type, a, b)
Stamper constructor
|
<static> |
PDFNet.Stamper.deleteStamps(doc, page_set)
Deletes PDFTron stamps from document at given page numbers
|
destroy()
Frees the native memory of the object.
|
|
<static> |
PDFNet.Stamper.hasStamps(doc, page_set)
Returns true if the given set of pages has at least one stamp
|
setAlignment(horizontal_alignment, vertical_alignment)
Sets the alignment for the x and y variables.
|
|
setAsAnnotation(annotation)
Specifies if the stamp is to be stamped as an annotation.
|
|
setAsBackground(background)
Specifies if the stamp is to be stamped in the background or the foreground.
|
|
setFont(font)
Defines the font of the stamp.
|
|
setFontColor(font_color)
Sets the font color (This only effects text-based stamps)
|
|
setOpacity(opacity)
Sets the opacity value for the stamp
|
|
setPosition(horizontal_distance, vert_dist, use_percentage)
Sets the horizontal and vertical position of the stamp.
|
|
setRotation(rotation)
Rotates the stamp by the given number of degrees
|
|
setSize(size_type, a, b)
sets the size of the stamp
|
|
setTextAlignment(text_alignment)
Sets the text alignment (note: this only applies to text watermarks)
|
|
showsOnPrint(on_print)
|
|
showsOnScreen(on_screen)
|
|
stampImage(dest_doc, img, dest_pages)
Stamps an image to the given destination document at the set of page numbers
|
|
stampPage(dest_doc, page, dest_pages)
Stamps a PDF page to the given destination document at the set of page numbers
|
|
stampText(dest_doc, txt, dest_pages)
Stamps text to the given destination document at the set of page numbers
|
Class Detail
PDFNet.Stamper(id)
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.
- Parameters:
- id
Method Detail
<static>
{Stamper}
PDFNet.Stamper.create(size_type, a, b)
Stamper constructor
- Parameters:
- {number} 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.
- {number} a
- @see size_type
- {number} b
- @see size_type
- Returns:
- {Stamper} A promise that resolves to an object of type: "Stamper" (generated documentation)
<static>
PDFNet.Stamper.deleteStamps(doc, page_set)
Deletes PDFTron stamps from document at given page numbers
- Parameters:
- {PDFDoc} doc
- The document to delete stamps from
- {PageSet} page_set
- The set of pages to delete stamps from
destroy()
Frees the native memory of the object.
<static>
{[ERROR]}
PDFNet.Stamper.hasStamps(doc, page_set)
Returns true if the given set of pages has at least one stamp
- Parameters:
- {PDFDoc} doc
- The document that's being checked
- {PageSet} page_set
- The set of page that's being checked
- Returns:
- {[ERROR]} A promise that resolves to an unknown type (generated documentation)
setAlignment(horizontal_alignment, vertical_alignment)
Sets the alignment for the x and y variables.
- Parameters:
- {number} 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
- {number} 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
- See:
- SetPosition
setAsAnnotation(annotation)
Specifies if the stamp is to be stamped as an annotation.
- Parameters:
- {boolean} annotation
- A flag specifying if the stamp should be added as an annotation or not
setAsBackground(background)
Specifies if the stamp is to be stamped in the background or the foreground.
- Parameters:
- {boolean} background
- A flag specifying if the stamp should be added as a background layer to the destination page
setFont(font)
Defines the font of the stamp. (This only applies to text-based stamps)
- Parameters:
- {Font} font
- The font of the text stamp
setFontColor(font_color)
Sets the font color (This only effects text-based stamps)
- Parameters:
- {colorpt} font_color
- The color of the font
setOpacity(opacity)
Sets the opacity value for the stamp
- Parameters:
- {number} opacity
- The opacity value of the stamp
setPosition(horizontal_distance, vert_dist, use_percentage)
Sets the horizontal and vertical position of the stamp.
- Parameters:
- {number [Y]} horizontal_distance
- Horizontal distance from left, right or center of crop box
- {number [Y]} vert_dist
- Vertical distance from top, bottom or center of crop box
- {boolean} 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.
- See:
- SetAlignment
setRotation(rotation)
Rotates the stamp by the given number of degrees
- Parameters:
- {number} rotation
- Rotation in degrees
setSize(size_type, a, b)
sets the size of the stamp
- Parameters:
- {number} 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.
- {number} a
- (generated documentation)
- {number} b
- (generated documentation)
setTextAlignment(text_alignment)
Sets the text alignment (note: this only applies to text watermarks)
- Parameters:
- {number} text_alignment
- Enumerator for text alignment (e_left, e_center, e_right)
showsOnPrint(on_print)
- Parameters:
- {boolean} on_print
- Specifies if the watermark will be displayed when printed
showsOnScreen(on_screen)
- Parameters:
- {boolean} on_screen
- Specifies if the watermark will be displayed on screen
stampImage(dest_doc, img, dest_pages)
Stamps an image to the given destination document at the set of page numbers
- Parameters:
- {PDFDoc} dest_doc
- The document being stamped
- {Image} img
- The image that is being stamped to the document
- {PageSet} dest_pages
- The set of pages in the document being stamped
stampPage(dest_doc, page, dest_pages)
Stamps a PDF page to the given destination document at the set of page numbers
- Parameters:
- {PDFDoc} dest_doc
- The document being stamped
- {Page} page
- The page that is being stamped to the document
- {PageSet} dest_pages
- The set of pages in the document being stamped
stampText(dest_doc, txt, dest_pages)
Stamps text to the given destination document at the set of page numbers
- Parameters:
- {PDFDoc} dest_doc
- The document being stamped
- {string} txt
- The image that is being stamped to the document
- {PageSet} dest_pages
- The set of pages in the document being stamped