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
Modifier and TypeClassDescriptionstatic enum
Signature rendering modes. -
Constructor Summary
ModifierConstructorDescriptionprotected
PdfSignatureAppearance
(PdfDocument document, Rectangle pageRect, int pageNumber) Creates a PdfSignatureAppearance. -
Method Summary
Modifier and TypeMethodDescriptionprotected PdfFormXObject
Constructs appearance (top-level) for a signature.Get the signing certificate.Returns the signing contact.getImage()
Gets the background image for the layer 2.float
Gets the scaling to be applied to the background image.Get Layer 0 of the appearance.Get Layer 2 of the appearance.Gets the n2 and n4 layer font.Gets the n2 and n4 layer font color.float
Gets the n2 and n4 layer font size.Gets the signature text identifying the signer if set by setLayer2Text().Returns the signing location.int
Provides the page number of the signature field which this signature appearance is associated with.Provides the rectangle that represent the position and dimension of the signature field in the page.Returns the signing reason.Gets the rendering mode for this signature.Returns the signature creator.Gets the Image object to render.protected Calendar
Returns the signature date.boolean
Gets the visibility status of the signature.setCertificate
(Certificate signCertificate) Sets the certificate used to provide the text in the appearance.setContact
(String contact) Sets the signing contact.protected PdfSignatureAppearance
setFieldName
(String fieldName) Set the field name of the appearance.Sets the background image for the layer 2.setImageScale
(float imageScale) Sets the scaling to be applied to the background image.setLayer2Font
(PdfFont layer2Font) Sets the n2 and n4 layer font.setLayer2FontColor
(Color color) Sets the n2 and n4 layer font color.setLayer2FontSize
(float fontSize) Sets the n2 and n4 layer font size.setLayer2Text
(String text) Sets the signature text identifying the signer.setLocation
(String location) Sets the signing location.setLocationCaption
(String locationCaption) Sets the caption for the signing location.setPageNumber
(int pageNumber) Sets the page number of the signature field which this signature appearance is associated with.setPageRect
(Rectangle pageRect) Sets the rectangle that represent the position and dimension of the signature field in the page.Sets the signing reason.setReasonCaption
(String reasonCaption) Sets the caption for the signing reason.setRenderingMode
(PdfSignatureAppearance.RenderingMode renderingMode) Sets the rendering mode for this signature.setReuseAppearance
(boolean reuseAppearance) Indicates that the existing appearances needs to be reused as layer 0.setSignatureCreator
(String signatureCreator) Sets the name of the application used to create the signature.setSignatureGraphic
(ImageData signatureGraphic) Sets the Image object to render when Render is set to RenderingMode.GRAPHIC or RenderingMode.GRAPHIC_AND_DESCRIPTION.protected PdfSignatureAppearance
setSignDate
(Calendar signDate) Sets the signature date.
-
Constructor Details
-
PdfSignatureAppearance
Creates a PdfSignatureAppearance.- Parameters:
-
document
- PdfDocument -
pageRect
- Rectangle of the appearance -
pageNumber
- Number of the page the appearance should be on
-
-
Method Details
-
getPageNumber
public int getPageNumber()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
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
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
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
Get Layer 0 of the appearance.The size of the layer is determined by the rectangle set via
setPageRect(Rectangle)
- Returns:
- layer 0
-
getLayer2
Get Layer 2 of the appearance.The size of the layer is determined by the rectangle set via
setPageRect(Rectangle)
- Returns:
- layer 2
-
getRenderingMode
Gets the rendering mode for this signature.- Returns:
- the rendering mode for this signature
-
setRenderingMode
Sets the rendering mode for this signature.- Parameters:
-
renderingMode
- the rendering mode - Returns:
- this instance to support fluent interface
-
getReason
Returns the signing reason.- Returns:
- reason for signing
-
setReason
Sets the signing reason.- Parameters:
-
reason
- signing reason. - Returns:
- this instance to support fluent interface
-
setReasonCaption
Sets the caption for the signing reason.- Parameters:
-
reasonCaption
- A new signing reason caption - Returns:
- this instance to support fluent interface
-
getLocation
Returns the signing location.- Returns:
- signing location
-
setLocation
Sets the signing location.- Parameters:
-
location
- A new signing location - Returns:
- this instance to support fluent interface
-
setLocationCaption
Sets the caption for the signing location.- Parameters:
-
locationCaption
- A new signing location caption - Returns:
- this instance to support fluent interface
-
getSignatureCreator
Returns the signature creator.- Returns:
- The signature creator
-
setSignatureCreator
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
Returns the signing contact.- Returns:
- The signing contact
-
setContact
Sets the signing contact.- Parameters:
-
contact
- A new signing contact - Returns:
- this instance to support fluent interface
-
setCertificate
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
Get the signing certificate.- Returns:
- the signing certificate
-
getSignatureGraphic
Gets the Image object to render.- Returns:
- the image
-
setSignatureGraphic
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
Indicates that the existing appearances needs to be reused as layer 0.- Parameters:
-
reuseAppearance
- is an appearances reusing flag value to set - Returns:
- this instance to support fluent interface
-
getImage
Gets the background image for the layer 2.- Returns:
- the background image for the layer 2
-
setImage
Sets the background image for the layer 2.- Parameters:
-
image
- the background image for the layer 2 - Returns:
- this instance to support fluent interface
-
getImageScale
public float getImageScale()Gets the scaling to be applied to the background image.- Returns:
- the scaling to be applied to the background image
-
setImageScale
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
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
Gets the signature text identifying the signer if set by setLayer2Text().- Returns:
- the signature text identifying the signer
-
getLayer2Font
Gets the n2 and n4 layer font.- Returns:
- the n2 and n4 layer font
-
setLayer2Font
Sets the n2 and n4 layer font. If the font size is zero, auto-fit will be used.- Parameters:
-
layer2Font
- the n2 and n4 font - Returns:
- this instance to support fluent interface
-
setLayer2FontSize
Sets the n2 and n4 layer font size.- Parameters:
-
fontSize
- font size - Returns:
- this instance to support fluent interface
-
getLayer2FontSize
public float getLayer2FontSize()Gets the n2 and n4 layer font size.- Returns:
- the n2 and n4 layer font size
-
setLayer2FontColor
Sets the n2 and n4 layer font color.- Parameters:
-
color
- font color - Returns:
- this instance to support fluent interface
-
getLayer2FontColor
Gets the n2 and n4 layer font color.- Returns:
- the n2 and n4 layer font color
-
isInvisible
public boolean isInvisible()Gets the visibility status of the signature.- Returns:
- the visibility status of the signature
-
getAppearance
Constructs appearance (top-level) for a signature.- Returns:
- a top-level signature appearance
- Throws:
-
IOException
- if font cannot be created - See Also:
-
getSignDate
Returns the signature date.- Returns:
- the signature date
-
setSignDate
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.- Parameters:
-
fieldName
- name of the field - Returns:
- this instance to support fluent interface
-