Package com.itextpdf.signatures
Class PdfSignatureAppearance
java.lang.Object
com.itextpdf.signatures.PdfSignatureAppearance
Provides convenient methods to make a signature appearance. Use it in conjunction with
PdfSigner
.-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate String
The contact name of the signer.private String
The text that goes in Layer 2 of the signature appearance.private final PdfDocument
The document to be signed.private String
Indicates the field to be signed.private PdfFont
Font for the text in Layer 2.private Color
Font color for the font of Layer 2.private String[]
Font family for the text.private FontProvider
Font provider for the text.private float
Font size for the font of Layer 2.private ImageData
A background image for the text in layer 2.private float
The scaling to be applied to the background image.private String
Holds value of property location.private String
The caption for the location of signing.private SignatureFieldAppearance
Signature model element.private PdfFormXObject
Zero level of the signature appearance.private PdfFormXObject
Second level of the signature appearance.private int
The page where the signature will appear.private Rectangle
Rectangle that represent the position and dimension of the signature in the page.private String
The reason for signing.private String
The caption for the reason for signing.private Rectangle
The coordinates of the rectangle for a visible signature, or a zero-width, zero-height rectangle for an invisible signature.The rendering mode chosen for visible signatures.private boolean
Indicates if we need to reuse the existing appearance as layer 0.private boolean
private String
Holds value of the application that creates the signature.private ImageData
The image that needs to be used for a visible signature.private Certificate
The signing certificate.private Calendar
Holds value of property signDate. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
PdfSignatureAppearance
(PdfDocument document, Rectangle pageRect, int pageNumber) Creates a PdfSignatureAppearance. -
Method Summary
Modifier and TypeMethodDescription(package private) void
(package private) SignedAppearanceText
protected PdfFormXObject
Deprecated.(package private) PdfFormXObject
Gets the background layer that is present when creating the signature field if it was set.Deprecated.in favour ofSignedAppearanceText
that should be used forSignatureFieldAppearance
.Deprecated.UsePdfSigner.getContact()
instead.getImage()
Deprecated.float
Deprecated.Deprecated.will be deleted in the next major release.Deprecated.will be deleted in the next major release.Deprecated.in favour ofSignatureFieldAppearance
.Deprecated.in favour ofSignatureFieldAppearance
.float
Deprecated.in favour ofSignatureFieldAppearance
.Deprecated.in favour ofSignatureFieldAppearance
.Deprecated.won't be public in the next major release.int
Deprecated.won't be public in the next major release.Deprecated.won't be public in the next major release.Deprecated.won't be public in the next major release.Deprecated.in favour ofSignatureFieldAppearance
, rendering mode will be detected depending on specifiedsetContent
method parameters.Gets the signature layout element.(package private) PdfFormXObject
Gets the signature appearance layer that contains information about the signature if it was set.Deprecated.UsePdfSigner.getSignatureCreator()
instead.Deprecated.in favour ofSignatureFieldAppearance
.protected Calendar
Deprecated.usePdfSigner.getSignDate()
instead.private String
boolean
Deprecated.won't be public in the next major release.(package private) boolean
Returns reuseAppearance value which indicates that the existing appearances needs to be reused as a background layer.(package private) boolean
Checks if reuseAppearance value was set usinginvalid @link
{@link this#setReuseAppearance(boolean)
private void
setCertificate
(Certificate signCertificate) Deprecated.in favour ofSignedAppearanceText
that should be used forSignatureFieldAppearance
.setContact
(String contact) Deprecated.UsePdfSigner.setContact(String)
instead.private void
protected PdfSignatureAppearance
setFieldName
(String fieldName) Set the field name of the appearance.setFontFamily
(String... fontFamilyNames) Deprecated.in favour ofElementPropertyContainer.setFontFamily(String...)
.setFontProvider
(FontProvider fontProvider) Deprecated.in favour ofElementPropertyContainer.setProperty(int, Object)
.private void
Deprecated.setImageScale
(float imageScale) Deprecated.setLayer2Font
(PdfFont font) Deprecated.in favour ofElementPropertyContainer.setFont(PdfFont)
.setLayer2FontColor
(Color color) Deprecated.in favour ofElementPropertyContainer.setFontColor(Color)
.setLayer2FontSize
(float fontSize) Deprecated.in favour ofElementPropertyContainer.setFontSize(float)
.setLayer2Text
(String text) Deprecated.in favour ofSignatureFieldAppearance
.setLocation
(String location) Deprecated.won't be public in the next major release.setLocationCaption
(String locationCaption) Deprecated.in favour ofSignedAppearanceText
that should be used forSignatureFieldAppearance
.setPageNumber
(int pageNumber) Deprecated.won't be public in the next major release.setPageRect
(Rectangle pageRect) Deprecated.won't be public in the next major release.Deprecated.won't be public in the next major release.setReasonCaption
(String reasonCaption) Deprecated.in favour ofSignedAppearanceText
that should be used forSignatureFieldAppearance
.setRenderingMode
(PdfSignatureAppearance.RenderingMode renderingMode) Deprecated.in favour ofSignatureFieldAppearance
, rendering mode will be detected depending on specifiedsetContent
method parameters.setReuseAppearance
(boolean reuseAppearance) Deprecated.in favour ofPdfSignatureFormField.setReuseAppearance(boolean)
.setSignatureAppearance
(SignatureFieldAppearance modelElement) Deprecated.setSignatureCreator
(String signatureCreator) Deprecated.UsePdfSigner.setSignatureCreator(String)
instead.setSignatureGraphic
(ImageData signatureGraphic) Deprecated.protected PdfSignatureAppearance
setSignDate
(Calendar signDate) Deprecated.usePdfSigner.setSignDate(Calendar)
instead.
-
Field Details
-
document
The document to be signed. -
modelElement
Signature model element. -
page
private int pageThe page where the signature will appear. -
rect
The coordinates of the rectangle for a visible signature, or a zero-width, zero-height rectangle for an invisible signature. -
pageRect
Rectangle that represent the position and dimension of the signature in the page. -
renderingMode
The rendering mode chosen for visible signatures. -
reason
The reason for signing. -
reasonCaption
The caption for the reason for signing. -
location
Holds value of property location. -
locationCaption
The caption for the location of signing. -
signatureCreator
Holds value of the application that creates the signature. -
contact
The contact name of the signer. -
signDate
Holds value of property signDate. -
signCertificate
The signing certificate. -
signatureGraphic
The image that needs to be used for a visible signature. -
image
A background image for the text in layer 2. -
imageScale
private float imageScaleThe scaling to be applied to the background image. -
description
The text that goes in Layer 2 of the signature appearance. -
font
Font for the text in Layer 2. -
fontProvider
Font provider for the text. -
fontFamilyNames
Font family for the text. -
fontSize
private float fontSizeFont size for the font of Layer 2. -
fontColor
Font color for the font of Layer 2. -
n0
Zero level of the signature appearance. -
n2
Second level of the signature appearance. -
fieldName
Indicates the field to be signed. -
reuseAppearance
private boolean reuseAppearanceIndicates if we need to reuse the existing appearance as layer 0. -
reuseAppearanceSet
private boolean reuseAppearanceSet
-
-
Constructor Details
-
PdfSignatureAppearance
Creates a PdfSignatureAppearance.- Parameters:
document
- PdfDocumentpageRect
- Rectangle of the appearancepageNumber
- Number of the page the appearance should be on
-
-
Method Details
-
getPageNumber
Deprecated.won't be public in the next major release. UsePdfSigner.getPageNumber()
instead.Provides the page number of the signature field which this signature appearance is associated with.- Returns:
- The page number of the signature field which this signature appearance is associated with.
-
setPageNumber
Deprecated.won't be public in the next major release. UsePdfSigner.setPageNumber(int)
instead.Sets the page number of the signature field which this signature appearance is associated with. Implicitly callssetPageRect(com.itextpdf.kernel.geom.Rectangle)
which considers page number to process the rectangle correctly.- Parameters:
pageNumber
- The page number of the signature field which this signature appearance is associated with.- Returns:
- this instance to support fluent interface.
-
getPageRect
Deprecated.won't be public in the next major release. UsePdfSigner.getPageRect()
instead.Provides the rectangle that represent the position and dimension of the signature field in the page.- Returns:
- the rectangle that represent the position and dimension of the signature field in the page.
-
setPageRect
Deprecated.won't be public in the next major release. UsePdfSigner.setPageRect(Rectangle)
instead.Sets the rectangle that represent the position and dimension of the signature field in the page.- Parameters:
pageRect
- The rectangle that represents the position and dimension of the signature field in the page.- Returns:
- this instance to support fluent interface.
-
getLayer0
Deprecated.will be deleted in the next major release. SeePdfSignatureFormField.setBackgroundLayer(PdfFormXObject)
. Note that it should be called for the field retrieved withPdfSigner.getSignatureField()
method.Get Layer 0 of the appearance.The size of the layer is determined by the rectangle set via
setPageRect(Rectangle)
- Returns:
- layer 0.
-
getLayer2
Deprecated.will be deleted in the next major release. SeePdfSignatureFormField.setSignatureAppearanceLayer(PdfFormXObject)
. Note that it should be called for the field retrieved withPdfSigner.getSignatureField()
method.Get Layer 2 of the appearance.The size of the layer is determined by the rectangle set via
setPageRect(Rectangle)
- Returns:
- layer 2.
-
getRenderingMode
Deprecated.in favour ofSignatureFieldAppearance
, rendering mode will be detected depending on specifiedsetContent
method parameters.Gets the rendering mode for this signature.- Returns:
- the rendering mode for this signature.
-
setRenderingMode
@Deprecated public PdfSignatureAppearance setRenderingMode(PdfSignatureAppearance.RenderingMode renderingMode) Deprecated.in favour ofSignatureFieldAppearance
, rendering mode will be detected depending on specifiedsetContent
method parameters.Sets the rendering mode for this signature.- Parameters:
renderingMode
- the rendering mode.- Returns:
- this instance to support fluent interface.
-
getReason
Deprecated.won't be public in the next major release. UsePdfSigner.getReason()
instead.Returns the signing reason.- Returns:
- reason for signing.
-
setReason
Deprecated.won't be public in the next major release. UsePdfSigner.setReason(java.lang.String)
instead.Sets the signing reason.- Parameters:
reason
- signing reason.- Returns:
- this instance to support fluent interface.
-
setReasonCaption
Deprecated.in favour ofSignedAppearanceText
that should be used forSignatureFieldAppearance
.Sets the caption for the signing reason.- Parameters:
reasonCaption
- A new signing reason caption.- Returns:
- this instance to support fluent interface.
-
getLocation
Deprecated.won't be public in the next major release. UsePdfSigner.getLocation()
instead.Returns the signing location.- Returns:
- signing location.
-
setLocation
Deprecated.won't be public in the next major release. UsePdfSigner.setLocation(java.lang.String)
instead.Sets the signing location.- Parameters:
location
- A new signing location.- Returns:
- this instance to support fluent interface.
-
setLocationCaption
Deprecated.in favour ofSignedAppearanceText
that should be used forSignatureFieldAppearance
.Sets the caption for the signing location.- Parameters:
locationCaption
- A new signing location caption.- Returns:
- this instance to support fluent interface.
-
getSignatureCreator
Deprecated.UsePdfSigner.getSignatureCreator()
instead.Returns the signature creator.- Returns:
- The signature creator.
-
setSignatureCreator
Deprecated.UsePdfSigner.setSignatureCreator(String)
instead.Sets the name of the application used to create the signature.- Parameters:
signatureCreator
- A new name of the application signing a document.- Returns:
- this instance to support fluent interface.
-
getContact
Deprecated.UsePdfSigner.getContact()
instead.Returns the signing contact.- Returns:
- The signing contact.
-
setContact
Deprecated.UsePdfSigner.setContact(String)
instead.Sets the signing contact.- Parameters:
contact
- A new signing contact.- Returns:
- this instance to support fluent interface.
-
setCertificate
Deprecated.in favour ofSignedAppearanceText
that should be used forSignatureFieldAppearance
. Specified certificate provides signer name.Sets the certificate used to provide the text in the appearance. This certificate doesn't take part in the actual signing process.- Parameters:
signCertificate
- the certificate.- Returns:
- this instance to support fluent interface.
-
getCertificate
Deprecated.in favour ofSignedAppearanceText
that should be used forSignatureFieldAppearance
.Get the signing certificate.- Returns:
- the signing certificate.
-
getSignatureGraphic
Deprecated.in favour ofSignatureFieldAppearance
.Gets the Image object to render.- Returns:
- the image.
-
setSignatureGraphic
Deprecated.Sets the Image object to render when Render is set to RenderingMode.GRAPHIC or RenderingMode.GRAPHIC_AND_DESCRIPTION.- Parameters:
signatureGraphic
- image rendered. If null the mode is defaulted to RenderingMode.DESCRIPTION- Returns:
- this instance to support fluent interface.
-
setReuseAppearance
Deprecated.in favour ofPdfSignatureFormField.setReuseAppearance(boolean)
. Note that it should be called for the field retrieved withPdfSigner.getSignatureField()
method.Indicates that the existing appearances needs to be reused as a background layer.- Parameters:
reuseAppearance
- is an appearances reusing flag value to set.- Returns:
- this instance to support fluent interface.
-
getImage
Deprecated.Gets the background image for the layer 2.- Returns:
- the background image for the layer 2.
-
setImage
Deprecated.Sets the background image for the text in the layer 2.- Parameters:
image
- the background image for the layer 2.- Returns:
- this instance to support fluent interface.
-
getImageScale
Deprecated.Gets the scaling to be applied to the background image.- Returns:
- the scaling to be applied to the background image.
-
setImageScale
Deprecated.Sets the scaling to be applied to the background image. If it's zero the image will fully fill the rectangle. If it's less than zero the image will fill the rectangle but will keep the proportions. If it's greater than zero that scaling will be applied. In any of the cases the image will always be centered. It's zero by default.- Parameters:
imageScale
- the scaling to be applied to the background image.- Returns:
- this instance to support fluent interface.
-
setLayer2Text
Deprecated.in favour ofSignatureFieldAppearance
.Sets the signature text identifying the signer.- Parameters:
text
- the signature text identifying the signer. If null or not set a standard description will be used.- Returns:
- this instance to support fluent interface.
-
getLayer2Text
Deprecated.in favour ofSignatureFieldAppearance
.Gets the signature text identifying the signer if set by setLayer2Text().- Returns:
- the signature text identifying the signer.
-
getLayer2Font
Deprecated.in favour ofSignatureFieldAppearance
.Gets the n2 and n4 layer font.- Returns:
- the n2 and n4 layer font.
-
setLayer2Font
Deprecated.in favour ofElementPropertyContainer.setFont(PdfFont)
.Sets the n2 layer font. If the font size is zero, auto-fit will be used.- Parameters:
font
- the n2 font.- Returns:
- this instance to support fluent interface.
-
setLayer2FontSize
Deprecated.in favour ofElementPropertyContainer.setFontSize(float)
.Sets the n2 and n4 layer font size.- Parameters:
fontSize
- font size.- Returns:
- this instance to support fluent interface.
-
getLayer2FontSize
Deprecated.in favour ofSignatureFieldAppearance
.Gets the n2 and n4 layer font size.- Returns:
- the n2 and n4 layer font size.
-
setLayer2FontColor
Deprecated.in favour ofElementPropertyContainer.setFontColor(Color)
.Sets the n2 and n4 layer font color.- Parameters:
color
- font color.- Returns:
- this instance to support fluent interface.
-
getLayer2FontColor
Deprecated.in favour ofSignatureFieldAppearance
.Gets the n2 layer font color.- Returns:
- the n2 layer font color.
-
getSignatureAppearance
Gets the signature layout element.- Returns:
- the signature layout element.
-
setSignatureAppearance
@Deprecated public PdfSignatureAppearance setSignatureAppearance(SignatureFieldAppearance modelElement) Deprecated.Sets the signature layout element.- Parameters:
modelElement
- the signature layout element.- Returns:
- this instance to support fluent interface.
-
setFontProvider
Deprecated.in favour ofElementPropertyContainer.setProperty(int, Object)
.SetsFontProvider
. Note, font provider is inherited property.- Parameters:
fontProvider
- the instance ofFontProvider
.- Returns:
- this instance to support fluent interface.
-
setFontFamily
Deprecated.in favour ofElementPropertyContainer.setFontFamily(String...)
.Sets the preferable font families for the signature content. Note thatFontProvider
shall be set as well.- Parameters:
fontFamilyNames
- defines an ordered list of preferable font families for the signature element.- Returns:
- this instance to support fluent interface.
-
isInvisible
Deprecated.won't be public in the next major release.Gets the visibility status of the signature.- Returns:
- the visibility status of the signature.
-
getAppearance
Deprecated.in favour ofSignatureFieldAppearance
. Shouldn't be used.Constructs appearance (top-level) for a signature.- Returns:
- a top-level signature appearance.
- Throws:
IOException
- if font cannot be created.- See Also:
-
getSignDate
Deprecated.usePdfSigner.getSignDate()
instead.Returns the signature date.- Returns:
- the signature date.
-
setSignDate
Deprecated.usePdfSigner.setSignDate(Calendar)
instead.Sets the signature date.- Parameters:
signDate
- A new signature date.- Returns:
- this instance to support fluent interface.
-
setFieldName
Set the field name of the appearance. Field name indicates the field to be signed if it is already presented in the document (signing existing field). Required for reuseAppearance option.- Parameters:
fieldName
- name of the field- Returns:
- this instance to support fluent interface
-
isReuseAppearance
boolean isReuseAppearance()Returns reuseAppearance value which indicates that the existing appearances needs to be reused as a background layer.- Returns:
- an appearances reusing flag value.
-
isReuseAppearanceSet
boolean isReuseAppearanceSet()Checks if reuseAppearance value was set usinginvalid @link
{@link this#setReuseAppearance(boolean)
- Returns:
- boolean value.
-
getBackgroundLayer
PdfFormXObject getBackgroundLayer()Gets the background layer that is present when creating the signature field if it was set.- Returns:
- n0 layer xObject.
-
getSignatureAppearanceLayer
PdfFormXObject getSignatureAppearanceLayer()Gets the signature appearance layer that contains information about the signature if it was set.- Returns:
- n2 layer xObject.
-
applyBackgroundImage
void applyBackgroundImage() -
generateSignatureText
SignedAppearanceText generateSignatureText() -
setFontRelatedProperties
private void setFontRelatedProperties() -
setContent
private void setContent() -
populateExistingModelElement
private void populateExistingModelElement() -
getSignerName
-
SignatureFieldAppearance
.