public class PdfSignatureAppearance extends Object
Modifier and Type | Class and Description |
---|---|
static class |
PdfSignatureAppearance.RenderingMode
Signature rendering modes
|
static interface |
PdfSignatureAppearance.SignatureEvent
An interface to retrieve the signature dictionary for modification.
|
Modifier and Type | Field and Description |
---|---|
static int |
CERTIFIED_FORM_FILLING
Author signature, form filling allowed
|
static int |
CERTIFIED_FORM_FILLING_AND_ANNOTATIONS
Author signature, form filling and annotations allowed
|
static int |
CERTIFIED_NO_CHANGES_ALLOWED
Author signature, no changes allowed
|
static int |
NOT_CERTIFIED
Approval signature
|
static String |
questionMark
An appearance that can be used for layer 1 (if acro6Layers is false).
|
Modifier and Type | Method and Description |
---|---|
void |
addDeveloperExtension(PdfDeveloperExtension de)
Adds the appropriate developer extension.
|
void |
close(PdfDictionary update)
This is the last method to be called when using external signatures.
|
PdfTemplate |
getAppearance()
Gets the main appearance layer.
|
Certificate |
getCertificate() |
int |
getCertificationLevel()
Gets the certified status of this document.
|
String |
getContact()
Gets the signing contact.
|
PdfDictionary |
getCryptoDictionary()
Gets the user made signature dictionary.
|
PdfSigLockDictionary |
getFieldLockDict()
Getter for the field lock dictionary.
|
String |
getFieldName()
Gets the field name.
|
Image |
getImage()
Gets the background image for the layer 2.
|
float |
getImageScale()
Gets the scaling to be applied to the background image.
|
PdfTemplate |
getLayer(int layer)
Gets a template layer to create a signature appearance.
|
Font |
getLayer2Font()
Gets the n2 and n4 layer font.
|
String |
getLayer2Text()
Gets the signature text identifying the signer if set by setLayer2Text().
|
String |
getLayer4Text()
Gets the text identifying the signature status if set by setLayer4Text().
|
String |
getLocation()
Gets the signing location.
|
String |
getNewSigName()
Gets a new signature field name that doesn't clash with any existing name.
|
int |
getPage()
Gets the page number of the field.
|
Rectangle |
getPageRect()
Gets the rectangle that represent the position and dimension of the signature in the page.
|
InputStream |
getRangeStream()
Gets the document bytes that are hashable when using external signatures.
|
String |
getReason()
Gets the signing reason.
|
Rectangle |
getRect()
Gets the rectangle representing the signature dimensions.
|
PdfSignatureAppearance.RenderingMode |
getRenderingMode()
Gets the rendering mode for this signature.
|
int |
getRunDirection()
Gets the run direction.
|
String |
getSignatureCreator()
Gets the signature creator.
|
PdfSignatureAppearance.SignatureEvent |
getSignatureEvent()
Getter for property signatureEvent.
|
Image |
getSignatureGraphic()
Gets the Image object to render.
|
Calendar |
getSignDate()
Gets the signature date.
|
PdfStamper |
getStamper()
Gets the PdfStamper associated with this instance.
|
File |
getTempFile()
Gets the temporary file.
|
PdfTemplate |
getTopLayer()
Gets the template that aggregates all appearance layers.
|
boolean |
isAcro6Layers()
Gets the Acrobat 6.0 layer mode.
|
boolean |
isInvisible()
Gets the visibility status of the signature.
|
boolean |
isPreClosed()
Checks if the document is in the process of closing.
|
void |
preClose(HashMap<PdfName,Integer> exclusionSizes)
This is the first method to be called when using external signatures.
|
void |
setAcro6Layers(boolean acro6Layers)
Deprecated.
Adobe no longer supports Adobe Acrobat / Reader versions older than 9
|
void |
setCertificate(Certificate signCertificate)
Sets the certificate used to provide the text in the appearance.
|
void |
setCertificationLevel(int certificationLevel)
Sets the document type to certified instead of simply signed.
|
void |
setContact(String contact)
Sets the signing contact.
|
void |
setCryptoDictionary(PdfDictionary cryptoDictionary)
Sets a user made signature dictionary.
|
void |
setFieldLockDict(PdfSigLockDictionary fieldLock)
Setter for the field lock dictionary.
|
void |
setImage(Image image)
Sets the background image for the layer 2.
|
void |
setImageScale(float imageScale)
Sets the scaling to be applied to the background image.
|
void |
setLayer2Font(Font layer2Font)
Sets the n2 and n4 layer font.
|
void |
setLayer2Text(String text)
Sets the signature text identifying the signer.
|
void |
setLayer4Text(String text)
Sets the text identifying the signature status.
|
void |
setLocation(String location)
Sets the signing location.
|
void |
setLocationCaption(String locationCaption)
Sets the caption for the signing location.
|
void |
setReason(String reason)
Sets the signing reason.
|
void |
setReasonCaption(String reasonCaption)
Sets the caption for signing reason.
|
void |
setRenderingMode(PdfSignatureAppearance.RenderingMode renderingMode)
Sets the rendering mode for this signature.
|
void |
setReuseAppearance(boolean reuseAppearance)
Indicates that the existing appearances needs to be reused as layer 0.
|
void |
setRunDirection(int runDirection)
Sets the run direction in the n2 and n4 layer.
|
void |
setSignatureCreator(String signatureCreator)
Sets the name of the application used to create the signature.
|
void |
setSignatureEvent(PdfSignatureAppearance.SignatureEvent signatureEvent)
Sets the signature event to allow modification of the signature dictionary.
|
void |
setSignatureGraphic(Image signatureGraphic)
Sets the Image object to render when Render is set to RenderingMode.GRAPHIC or RenderingMode.GRAPHIC_AND_DESCRIPTION .
|
void |
setSignDate(Calendar signDate)
Sets the signature date.
|
void |
setVisibleSignature(Rectangle pageRect, int page, String fieldName)
Sets the signature to be visible.
|
void |
setVisibleSignature(String fieldName)
Sets the signature to be visible.
|
public static final int NOT_CERTIFIED
public static final int CERTIFIED_NO_CHANGES_ALLOWED
public static final int CERTIFIED_FORM_FILLING
public static final int CERTIFIED_FORM_FILLING_AND_ANNOTATIONS
public static final String questionMark
public void setCertificationLevel(int certificationLevel)
certificationLevel
- the values can be: NOT_CERTIFIED
, CERTIFIED_NO_CHANGES_ALLOWED
, CERTIFIED_FORM_FILLING
and CERTIFIED_FORM_FILLING_AND_ANNOTATIONS
public int getCertificationLevel()
public String getReason()
public void setReason(String reason)
reason
- the signing reason
public void setReasonCaption(String reasonCaption)
reasonCaption
- the signing reason caption
public String getLocation()
public void setLocation(String location)
location
- the signing location
public void setLocationCaption(String locationCaption)
locationCaption
- the signing location caption
public String getSignatureCreator()
public void setSignatureCreator(String signatureCreator)
signatureCreator
- the name of the signature creating application
public String getContact()
public void setContact(String contact)
contact
- the signing contact
public Calendar getSignDate()
public void setSignDate(Calendar signDate)
signDate
- the signature date
public InputStream getRangeStream() throws IOException
IOException
public void addDeveloperExtension(PdfDeveloperExtension de)
public PdfDictionary getCryptoDictionary()
public void setCryptoDictionary(PdfDictionary cryptoDictionary)
cryptoDictionary
- a user made signature dictionary
public void setCertificate(Certificate signCertificate)
signCertificate
- the certificate
public Certificate getCertificate()
public PdfSignatureAppearance.SignatureEvent getSignatureEvent()
public void setSignatureEvent(PdfSignatureAppearance.SignatureEvent signatureEvent)
signatureEvent
- the signature event
public String getFieldName()
public String getNewSigName()
public int getPage()
public Rectangle getRect()
null
or have zero width or height for invisible signatures
public Rectangle getPageRect()
public boolean isInvisible()
public void setVisibleSignature(Rectangle pageRect, int page, String fieldName)
pageRect
- the position and dimension of the field in the page
page
- the page to place the field. The fist page is 1
fieldName
- the field name or null
to generate automatically a new field name
public void setVisibleSignature(String fieldName)
fieldName
- the existing empty signature field name
public PdfSignatureAppearance.RenderingMode getRenderingMode()
public void setRenderingMode(PdfSignatureAppearance.RenderingMode renderingMode)
renderingMode
- the rendering mode
public Image getSignatureGraphic()
public void setSignatureGraphic(Image signatureGraphic)
RenderingMode.GRAPHIC
or RenderingMode.GRAPHIC_AND_DESCRIPTION
.
signatureGraphic
- image rendered. If null
the mode is defaulted to RenderingMode.DESCRIPTION
public boolean isAcro6Layers()
public void setAcro6Layers(boolean acro6Layers)
false
if you want to ignore this recommendation.
acro6Layers
- if true
only the layers n0 and n2 will be present
public PdfTemplate getLayer(int layer)
Consult PPKAppearances.pdf for further details.
layer
- the layer
public void setReuseAppearance(boolean reuseAppearance)
public Image getImage()
public void setImage(Image image)
image
- the background image for the layer 2
public float getImageScale()
public void setImageScale(float imageScale)
imageScale
- the scaling to be applied to the background image
public void setLayer2Text(String text)
text
- the signature text identifying the signer. If null
or not set a standard description will be used
public String getLayer2Text()
public Font getLayer2Font()
public void setLayer2Font(Font layer2Font)
layer2Font
- the n2 and n4 font
public void setRunDirection(int runDirection)
runDirection
- the run direction
public int getRunDirection()
public void setLayer4Text(String text)
text
- the text identifying the signature status. If null
or not set the description "Signature Not Verified" will be used
public String getLayer4Text()
public PdfTemplate getTopLayer()
Consult PPKAppearances.pdf for further details.
public PdfTemplate getAppearance() throws DocumentException
Consult PPKAppearances.pdf for further details.
DocumentException
- on error
public PdfStamper getStamper()
PdfStamper
associated with this instance.
PdfStamper
associated with this instance
public File getTempFile()
null
is the document is created in memory
public PdfSigLockDictionary getFieldLockDict()
public void setFieldLockDict(PdfSigLockDictionary fieldLock)
Be aware: if a signature is created on an existing signature field, then its /Lock dictionary takes the precedence (if it exists).
fieldLock
- Field lock dictionary.
public boolean isPreClosed()
true
if the document is in the process of closing, false
otherwise
public void preClose(HashMap<PdfName,Integer> exclusionSizes) throws IOException, DocumentException
If calling preClose() dont't call PdfStamper.close().
exclusionSizes
must contain at least the PdfName.CONTENTS
key with the size that it will take in the document. Note that due to the hex string coding this size should be byte_size*2+2.
exclusionSizes
- a HashMap
with names and sizes to be excluded in the signature calculation. The key is a PdfName
and the value an Integer
. At least the PdfName.CONTENTS
must be present
IOException
- on error
DocumentException
- on error
public void close(PdfDictionary update) throws IOException, DocumentException
update
is a PdfDictionary
that must have exactly the same keys as the ones provided in preClose(HashMap)
.
update
- a PdfDictionary
with the key/value that will fill the holes defined in preClose(HashMap)
DocumentException
- on error
IOException
- on error
Copyright © 1998–2018. All rights reserved.