Class 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.
Implements
Inherited Members
Namespace: pdftron.PDF
Assembly: PDFNet.dll
Syntax
public class Stamper : IDisposable
Constructors
Stamper(SizeType, double, double)
Stamper constructor.
Declaration
public Stamper(Stamper.SizeType size_type, double a, double b)
Parameters
Type | Name | Description |
---|---|---|
Stamper.SizeType | size_type |
|
double | a | Generally the horizontal component of the size. See size_type for more details. |
double | b | Generally the vertical component of the size. See size_type for more details. |
Methods
DeleteStamps(PDFDoc, PageSet)
Declaration
public static void DeleteStamps(PDFDoc doc, PageSet page_set)
Parameters
Type | Name | Description |
---|---|---|
PDFDoc | doc | |
PageSet | page_set |
Dispose()
Releases all resources used by the Stamper
Declaration
public override sealed void Dispose()
Dispose(bool)
Declaration
[HandleProcessCorruptedStateExceptions]
protected virtual void Dispose(bool A_0)
Parameters
Type | Name | Description |
---|---|---|
bool | A_0 |
~Stamper()
Declaration
protected ~Stamper()
HasStamps(PDFDoc, PageSet)
Declaration
public static bool HasStamps(PDFDoc doc, PageSet page_set)
Parameters
Type | Name | Description |
---|---|---|
PDFDoc | doc | |
PageSet | page_set |
Returns
Type | Description |
---|---|
bool |
SetAlignment(HorizontalAlignment, VerticalAlignment)
Sets the alignment for the x and y variables.
Declaration
public void SetAlignment(Stamper.HorizontalAlignment horizontal_alignment, Stamper.VerticalAlignment vertical_alignment)
Parameters
Type | Name | Description |
---|---|---|
Stamper.HorizontalAlignment | horizontal_alignment | the horizontal alignment |
Stamper.VerticalAlignment | vertical_alignment | the vertical alignment |
See Also
SetAsAnnotation(bool)
Specifies if the stamp is to be stamped as annotation or not.
Declaration
public void SetAsAnnotation(bool annotation)
Parameters
Type | Name | Description |
---|---|---|
bool | annotation | A flag specifying if the stamp should be added as an annotation to the destination page |
Remarks
SetAsBackground, HasStamps and DeleteStamps methods will not work on stamps created with this as true.
SetAsBackground(bool)
Specifies if the stamp is to be stamped in the background or the foreground.
Declaration
public void SetAsBackground(bool background)
Parameters
Type | Name | Description |
---|---|---|
bool | background | A flag specifying if the stamp should be added as a background layer to the destination page |
SetFont(Font)
Declaration
public void SetFont(Font font)
Parameters
Type | Name | Description |
---|---|---|
Font | font |
SetFontColor(ColorPt)
Declaration
public void SetFontColor(ColorPt font_color)
Parameters
Type | Name | Description |
---|---|---|
ColorPt | font_color |
SetOpacity(double)
Sets the opacity value for the stamp.
Declaration
public void SetOpacity(double opacity)
Parameters
Type | Name | Description |
---|---|---|
double | opacity | The opacity value of the stamp |
SetPosition(double, double)
Sets the horizontal and vertical position of the stamp.
Declaration
public void SetPosition(double horizontal_distance, double vertical_distance)
Parameters
Type | Name | Description |
---|---|---|
double | horizontal_distance | Horizontal distance from left, right or center of crop box; in points |
double | vertical_distance | the vertical_distance |
See Also
SetPosition(double, double, bool)
Sets the horizontal and vertical position of the stamp.
Declaration
public void SetPosition(double horizontal_distance, double vertical_distance, bool percentage)
Parameters
Type | Name | Description |
---|---|---|
double | horizontal_distance | Horizontal distance from left, right or center of crop box |
double | vertical_distance | the vertical_distance |
bool | 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 Also
SetRotation(double)
Rotates the stamp by the given number of degrees.
Declaration
public void SetRotation(double rotation)
Parameters
Type | Name | Description |
---|---|---|
double | rotation | Rotation in degrees |
SetSize(SizeType, double, double)
Sets the size of the stamp.
Declaration
public void SetSize(Stamper.SizeType size_type, double a, double b)
Parameters
Type | Name | Description |
---|---|---|
Stamper.SizeType | size_type | Specifies how the stamp will be sized |
double | a | the a |
double | b | the b |
SetTextAlignment(TextAlignment)
Sets the text alignment (note: this only applies to text watermarks).
Declaration
public void SetTextAlignment(Stamper.TextAlignment text_alignment)
Parameters
Type | Name | Description |
---|---|---|
Stamper.TextAlignment | text_alignment | Enumerator for text alignment (e_left, e_center, e_right) |
ShowsOnPrint(bool)
Shows on print.
Declaration
public void ShowsOnPrint(bool on_print)
Parameters
Type | Name | Description |
---|---|---|
bool | on_print | Specifies if the watermark will be displayed when printed |
ShowsOnScreen(bool)
Shows on screen.
Declaration
public void ShowsOnScreen(bool on_screen)
Parameters
Type | Name | Description |
---|---|---|
bool | on_screen | Specifies if the watermark will be displayed on screen |
StampImage(PDFDoc, Image, PageSet)
Declaration
public void StampImage(PDFDoc dest_doc, Image src_img, PageSet dest_pages)
Parameters
Type | Name | Description |
---|---|---|
PDFDoc | dest_doc | |
Image | src_img | |
PageSet | dest_pages |
StampPage(PDFDoc, Page, PageSet)
Declaration
public void StampPage(PDFDoc dest_doc, Page src_page, PageSet dest_pages)
Parameters
Type | Name | Description |
---|---|---|
PDFDoc | dest_doc | |
Page | src_page | |
PageSet | dest_pages |
StampText(PDFDoc, string, PageSet)
Declaration
public void StampText(PDFDoc dest_doc, string txt, PageSet dest_pages)
Parameters
Type | Name | Description |
---|---|---|
PDFDoc | dest_doc | |
string | txt | |
PageSet | dest_pages |