new Stamper()
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.
Extends
Members
-
<static> HorizontalAlignment
-
Properties:
Name Type Description e_horizontal_leftnumber e_horizontal_centernumber e_horizontal_rightnumber -
<static> SizeType
-
Properties:
Name Type Description e_relative_scalenumber e_absolute_sizenumber e_font_sizenumber -
<static> TextAlignment
-
Properties:
Name Type Description e_align_leftnumber e_align_centernumber e_align_rightnumber -
<static> VerticalAlignment
-
Properties:
Name Type Description e_vertical_bottomnumber e_vertical_centernumber e_vertical_topnumber
Methods
-
<static> create(size_type, a, b)
-
Stamper constructor
Parameters:
Name Type Description size_typenumber PDFNet.Stamper.SizeType = { e_relative_scale : 1 e_absolute_size : 2 e_font_size : 3 }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.anumber @see size_type bnumber @see size_type Returns:
A promise that resolves to an object of type: "PDFNet.Stamper"- Type
- Promise.<PDFNet.Stamper>
-
<static> deleteStamps(doc, page_set)
-
Deletes PDFTron stamps from document at given page numbers
Parameters:
Name Type Description docPDFNet.PDFDoc | PDFNet.SDFDoc | PDFNet.FDFDoc The document to delete stamps from page_setPDFNet.PageSet The set of pages to delete stamps from Returns:
- Type
- Promise.<void>
-
<static> hasStamps(doc, page_set)
-
Returns true if the given set of pages has at least one stamp
Parameters:
Name Type Description docPDFNet.PDFDoc | PDFNet.SDFDoc | PDFNet.FDFDoc The document that's being checked page_setPDFNet.PageSet The set of page that's being checked Returns:
A promise that resolves to an object of type: "boolean"- Type
- Promise.<boolean>
-
destroy()
-
Destructor
- Inherited From:
Returns:
- Type
- Promise.<void>
-
setAlignment(horizontal_alignment, vertical_alignment)
-
Sets the alignment for the x and y variables.
Parameters:
Name Type Description horizontal_alignmentnumber PDFNet.Stamper.HorizontalAlignment = { e_horizontal_left : -1 e_horizontal_center : 0 e_horizontal_right : 1 }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_alignmentnumber PDFNet.Stamper.VerticalAlignment = { e_vertical_bottom : -1 e_vertical_center : 0 e_vertical_top : 1 }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
Returns:
- Type
- Promise.<void>
-
setAsAnnotation(annotation)
-
Specifies if the stamp is to be stamped as an annotation.
Parameters:
Name Type Description annotationboolean A flag specifying if the stamp should be added as an annotation or not Returns:
- Type
- Promise.<void>
-
setAsBackground(background)
-
Specifies if the stamp is to be stamped in the background or the foreground.
Parameters:
Name Type Description backgroundboolean A flag specifying if the stamp should be added as a background layer to the destination page Returns:
- Type
- Promise.<void>
-
setFont(font)
-
Defines the font of the stamp. (This only applies to text-based stamps)
Parameters:
Name Type Description fontPDFNet.Font The font of the text stamp Returns:
- Type
- Promise.<void>
-
setFontColor(font_color)
-
Sets the font color (This only effects text-based stamps)
Parameters:
Name Type Description font_colorPDFNet.ColorPt The color of the font Returns:
- Type
- Promise.<void>
-
setOpacity(opacity)
-
Sets the opacity value for the stamp
Parameters:
Name Type Description opacitynumber The opacity value of the stamp Returns:
- Type
- Promise.<void>
-
setPosition(x, y [, use_percentage])
-
Parameters:
Name Type Argument Description xnumber ynumber use_percentageboolean <optional>
Returns:
- Type
- Promise.<void>
-
setRotation(rotation)
-
Rotates the stamp by the given number of degrees
Parameters:
Name Type Description rotationnumber Rotation in degrees Returns:
- Type
- Promise.<void>
-
setSize(size_type, a, b)
-
sets the size of the stamp
Parameters:
Name Type Description size_typenumber PDFNet.Stamper.SizeType = { e_relative_scale : 1 e_absolute_size : 2 e_font_size : 3 }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.anumber Generally the horizontal component of the size. See size_type for more details. bnumber Generally the vertical component of the size. See size_type for more details. Returns:
- Type
- Promise.<void>
-
setTextAlignment(text_alignment)
-
Sets the text alignment (note: this only applies to text watermarks)
Parameters:
Name Type Description text_alignmentnumber PDFNet.Stamper.TextAlignment = { e_align_left : -1 e_align_center : 0 e_align_right : 1 }Enumerator for text alignment (e_left, e_center, e_right)Returns:
- Type
- Promise.<void>
-
showsOnPrint(on_print)
-
Parameters:
Name Type Description on_printboolean Specifies if the watermark will be displayed when printed Returns:
- Type
- Promise.<void>
-
showsOnScreen(on_screen)
-
Parameters:
Name Type Description on_screenboolean Specifies if the watermark will be displayed on screen Returns:
- Type
- Promise.<void>
-
stampImage(dest_doc, img, dest_pages)
-
Stamps an image to the given destination document at the set of page numbers
Parameters:
Name Type Description dest_docPDFNet.PDFDoc | PDFNet.SDFDoc | PDFNet.FDFDoc The document being stamped imgPDFNet.Image The image that is being stamped to the document dest_pagesPDFNet.PageSet The set of pages in the document being stamped Returns:
- Type
- Promise.<void>
-
stampPage(dest_doc, page, dest_pages)
-
Stamps a PDF page to the given destination document at the set of page numbers
Parameters:
Name Type Description dest_docPDFNet.PDFDoc | PDFNet.SDFDoc | PDFNet.FDFDoc The document being stamped pagePDFNet.Page The page that is being stamped to the document dest_pagesPDFNet.PageSet The set of pages in the document being stamped Returns:
- Type
- Promise.<void>
-
stampText(dest_doc, txt, dest_pages)
-
Stamps text to the given destination document at the set of page numbers
Parameters:
Name Type Description dest_docPDFNet.PDFDoc | PDFNet.SDFDoc | PDFNet.FDFDoc The document being stamped txtstring The image that is being stamped to the document dest_pagesPDFNet.PageSet The set of pages in the document being stamped Returns:
- Type
- Promise.<void>
-
takeOwnership()
-
Take the ownership of this object, so that PDFNet.runWithCleanup won't destroy this object.
- Inherited From:
Returns:
- Type
- void