Package com.itextpdf.text.pdf
Class PdfSignatureAppearance
- java.lang.Object
-
- com.itextpdf.text.pdf.PdfSignatureAppearance
-
public class PdfSignatureAppearance extends java.lang.Object
Class that takes care of the cryptographic options and appearances that form a signature.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PdfSignatureAppearance.RenderingMode
Signature rendering modesstatic interface
PdfSignatureAppearance.SignatureEvent
An interface to retrieve the signature dictionary for modification.
-
Field Summary
Fields Modifier and Type Field Description private boolean
acro6Layers
Appearance compliant with the recommendations introduced in Acrobat 6?private PdfTemplate[]
app
Layers for a visible signature.private byte[]
bout
The bytes of the file right before the signature is added (if raf is null)private int
boutLen
Length of the output.private int
certificationLevel
The certification levelstatic int
CERTIFIED_FORM_FILLING
Author signature, form filling allowedstatic int
CERTIFIED_FORM_FILLING_AND_ANNOTATIONS
Author signature, form filling and annotations allowedstatic int
CERTIFIED_NO_CHANGES_ALLOWED
Author signature, no changes allowedprivate java.lang.String
contact
The contact name of the signer.private PdfDictionary
cryptoDictionary
The crypto dictionaryprivate java.util.HashMap<PdfName,PdfLiteral>
exclusionLocations
Name and content of keys that can only be added in the close() method.private PdfSigLockDictionary
fieldLock
Signature field lock dictionaryprivate java.lang.String
fieldName
The name of the fieldprivate PdfTemplate
frm
Template containing all layers drawn on top of each other.private Image
image
A background image for the text in layer 2.private float
imageScale
the scaling to be applied to the background image.tprivate Font
layer2Font
Font for the text in Layer 2.private java.lang.String
layer2Text
The text that goes in Layer 2 of the signature appearance.private java.lang.String
layer4Text
The text that goes in Layer 4 of the appearance.private java.lang.String
location
Holds value of property location.private java.lang.String
locationCaption
The caption for the location of signing.private static float
MARGIN
margin for the content inside the signature rectangle.static int
NOT_CERTIFIED
Approval signatureprivate java.io.OutputStream
originalout
OutputStream for the bytes of the stamper.private int
page
The page where the signature will appear.private Rectangle
pageRect
rectangle that represent the position and dimension of the signature in the page.private boolean
preClosed
Indicates if the stamper has already been pre-closed.static java.lang.String
questionMark
An appearance that can be used for layer 1 (if acro6Layers is false).private java.io.RandomAccessFile
raf
The file right before the signature is added (can be null).private long[]
range
Array containing the byte positions of the bytes that need to be hashed.private java.lang.String
reason
The reason for signing.private java.lang.String
reasonCaption
The caption for the reason for signing.private Rectangle
rect
The coordinates of the rectangle for a visible signature, or a zero-width, zero-height rectangle for an invisible signature.private PdfSignatureAppearance.RenderingMode
renderingMode
The rendering mode chosen for visible signaturesprivate boolean
reuseAppearance
Indicates if we need to reuse the existing appearance as layer 0.private int
runDirection
Run direction for the text in layers 2 and 4.private java.lang.String
signatureCreator
Holds value of the application that creates the signatureprivate PdfSignatureAppearance.SignatureEvent
signatureEvent
Holds value of property signatureEvent.private Image
signatureGraphic
The image that needs to be used for a visible signatureprivate java.security.cert.Certificate
signCertificate
The signing certificateprivate java.util.Calendar
signDate
Holds value of property signDate.private ByteBuffer
sigout
A byte buffer containing the bytes of the Stamper.private PdfStamper
stamper
The PdfStamper that creates the signed PDF.private java.io.File
tempFile
Temporary file in case you don't want to sign in memory.private static float
TOP_SECTION
extra space at the top.private PdfStamperImp
writer
The PdfStamperImp object corresponding with the stamper.
-
Constructor Summary
Constructors Constructor Description PdfSignatureAppearance(PdfStamperImp writer)
Constructs a PdfSignatureAppearance object.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addDeveloperExtension(PdfDeveloperExtension de)
Adds the appropriate developer extension.private void
addDocMDP(PdfDictionary crypto)
Adds keys to the signature dictionary that define the certification level and the permissions.private void
addFieldMDP(PdfDictionary crypto, PdfDictionary fieldLock)
Adds keys to the signature dictionary that define the field permissions.void
close(PdfDictionary update)
This is the last method to be called when using external signatures.private void
createBlankN0()
PdfTemplate
getAppearance()
Gets the main appearance layer.java.security.cert.Certificate
getCertificate()
int
getCertificationLevel()
Gets the certified status of this document.java.lang.String
getContact()
Gets the signing contact.PdfDictionary
getCryptoDictionary()
Gets the user made signature dictionary.PdfSigLockDictionary
getFieldLockDict()
Getter for the field lock dictionary.java.lang.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.java.lang.String
getLayer2Text()
Gets the signature text identifying the signer if set by setLayer2Text().java.lang.String
getLayer4Text()
Gets the text identifying the signature status if set by setLayer4Text().java.lang.String
getLocation()
Gets the signing location.java.lang.String
getNewSigName()
Gets a new signature field name that doesn't clash with any existing name.(package private) java.io.OutputStream
getOriginalout()
Getter for the OutputStream.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.java.io.InputStream
getRangeStream()
Gets the document bytes that are hashable when using external signatures.java.lang.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.java.lang.String
getSignatureCreator()
Gets the signature creator.PdfSignatureAppearance.SignatureEvent
getSignatureEvent()
Getter for property signatureEvent.Image
getSignatureGraphic()
Gets the Image object to render.java.util.Calendar
getSignDate()
Gets the signature date.(package private) ByteBuffer
getSigout()
Getter for the byte buffer.PdfStamper
getStamper()
Gets thePdfStamper
associated with this instance.java.io.File
getTempFile()
Gets the temporary file.PdfTemplate
getTopLayer()
Gets the template that aggregates all appearance layers.private RandomAccessSource
getUnderlyingSource()
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(java.util.HashMap<PdfName,java.lang.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 9void
setCertificate(java.security.cert.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(java.lang.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(java.lang.String text)
Sets the signature text identifying the signer.void
setLayer4Text(java.lang.String text)
Sets the text identifying the signature status.void
setLocation(java.lang.String location)
Sets the signing location.void
setLocationCaption(java.lang.String locationCaption)
Sets the caption for the signing location.(package private) void
setOriginalout(java.io.OutputStream originalout)
Setter for the OutputStream.void
setReason(java.lang.String reason)
Sets the signing reason.void
setReasonCaption(java.lang.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(java.lang.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 toRenderingMode.GRAPHIC
orRenderingMode.GRAPHIC_AND_DESCRIPTION
.void
setSignDate(java.util.Calendar signDate)
Sets the signature date.(package private) void
setSigout(ByteBuffer sigout)
Setter for the byte buffer.(package private) void
setStamper(PdfStamper stamper)
Sets the PdfStamper(package private) void
setTempFile(java.io.File tempFile)
Setter for the temporary file.void
setVisibleSignature(Rectangle pageRect, int page, java.lang.String fieldName)
Sets the signature to be visible.void
setVisibleSignature(java.lang.String fieldName)
Sets the signature to be visible.
-
-
-
Field Detail
-
NOT_CERTIFIED
public static final int NOT_CERTIFIED
Approval signature- See Also:
- Constant Field Values
-
CERTIFIED_NO_CHANGES_ALLOWED
public static final int CERTIFIED_NO_CHANGES_ALLOWED
Author signature, no changes allowed- See Also:
- Constant Field Values
-
CERTIFIED_FORM_FILLING
public static final int CERTIFIED_FORM_FILLING
Author signature, form filling allowed- See Also:
- Constant Field Values
-
CERTIFIED_FORM_FILLING_AND_ANNOTATIONS
public static final int CERTIFIED_FORM_FILLING_AND_ANNOTATIONS
Author signature, form filling and annotations allowed- See Also:
- Constant Field Values
-
certificationLevel
private int certificationLevel
The certification level
-
reasonCaption
private java.lang.String reasonCaption
The caption for the reason for signing.
-
locationCaption
private java.lang.String locationCaption
The caption for the location of signing.
-
reason
private java.lang.String reason
The reason for signing.
-
location
private java.lang.String location
Holds value of property location.
-
signDate
private java.util.Calendar signDate
Holds value of property signDate.
-
signatureCreator
private java.lang.String signatureCreator
Holds value of the application that creates the signature
-
contact
private java.lang.String contact
The contact name of the signer.
-
raf
private java.io.RandomAccessFile raf
The file right before the signature is added (can be null).
-
bout
private byte[] bout
The bytes of the file right before the signature is added (if raf is null)
-
range
private long[] range
Array containing the byte positions of the bytes that need to be hashed.
-
signCertificate
private java.security.cert.Certificate signCertificate
The signing certificate
-
cryptoDictionary
private PdfDictionary cryptoDictionary
The crypto dictionary
-
signatureEvent
private PdfSignatureAppearance.SignatureEvent signatureEvent
Holds value of property signatureEvent.
-
fieldName
private java.lang.String fieldName
The name of the field
-
page
private int page
The page where the signature will appear.
-
rect
private Rectangle rect
The coordinates of the rectangle for a visible signature, or a zero-width, zero-height rectangle for an invisible signature.
-
pageRect
private Rectangle pageRect
rectangle that represent the position and dimension of the signature in the page.
-
renderingMode
private PdfSignatureAppearance.RenderingMode renderingMode
The rendering mode chosen for visible signatures
-
signatureGraphic
private Image signatureGraphic
The image that needs to be used for a visible signature
-
acro6Layers
private boolean acro6Layers
Appearance compliant with the recommendations introduced in Acrobat 6?
-
app
private PdfTemplate[] app
Layers for a visible signature.
-
reuseAppearance
private boolean reuseAppearance
Indicates if we need to reuse the existing appearance as layer 0.
-
questionMark
public static final java.lang.String questionMark
An appearance that can be used for layer 1 (if acro6Layers is false).- See Also:
- Constant Field Values
-
image
private Image image
A background image for the text in layer 2.
-
imageScale
private float imageScale
the scaling to be applied to the background image.t
-
layer2Text
private java.lang.String layer2Text
The text that goes in Layer 2 of the signature appearance.
-
layer2Font
private Font layer2Font
Font for the text in Layer 2.
-
runDirection
private int runDirection
Run direction for the text in layers 2 and 4.
-
layer4Text
private java.lang.String layer4Text
The text that goes in Layer 4 of the appearance.
-
frm
private PdfTemplate frm
Template containing all layers drawn on top of each other.
-
TOP_SECTION
private static final float TOP_SECTION
extra space at the top.- See Also:
- Constant Field Values
-
MARGIN
private static final float MARGIN
margin for the content inside the signature rectangle.- See Also:
- Constant Field Values
-
stamper
private PdfStamper stamper
The PdfStamper that creates the signed PDF.
-
writer
private PdfStamperImp writer
The PdfStamperImp object corresponding with the stamper.
-
sigout
private ByteBuffer sigout
A byte buffer containing the bytes of the Stamper.
-
originalout
private java.io.OutputStream originalout
OutputStream for the bytes of the stamper.
-
tempFile
private java.io.File tempFile
Temporary file in case you don't want to sign in memory.
-
exclusionLocations
private java.util.HashMap<PdfName,PdfLiteral> exclusionLocations
Name and content of keys that can only be added in the close() method.
-
boutLen
private int boutLen
Length of the output.
-
preClosed
private boolean preClosed
Indicates if the stamper has already been pre-closed.
-
fieldLock
private PdfSigLockDictionary fieldLock
Signature field lock dictionary
-
-
Constructor Detail
-
PdfSignatureAppearance
PdfSignatureAppearance(PdfStamperImp writer)
Constructs a PdfSignatureAppearance object.- Parameters:
writer
- the writer to which the signature will be written.
-
-
Method Detail
-
setCertificationLevel
public void setCertificationLevel(int certificationLevel)
Sets the document type to certified instead of simply signed.- Parameters:
certificationLevel
- the values can be:NOT_CERTIFIED
,CERTIFIED_NO_CHANGES_ALLOWED
,CERTIFIED_FORM_FILLING
andCERTIFIED_FORM_FILLING_AND_ANNOTATIONS
-
getCertificationLevel
public int getCertificationLevel()
Gets the certified status of this document.- Returns:
- the certified status
-
getReason
public java.lang.String getReason()
Gets the signing reason.- Returns:
- the signing reason
-
setReason
public void setReason(java.lang.String reason)
Sets the signing reason.- Parameters:
reason
- the signing reason
-
setReasonCaption
public void setReasonCaption(java.lang.String reasonCaption)
Sets the caption for signing reason.- Parameters:
reasonCaption
- the signing reason caption
-
getLocation
public java.lang.String getLocation()
Gets the signing location.- Returns:
- the signing location
-
setLocation
public void setLocation(java.lang.String location)
Sets the signing location.- Parameters:
location
- the signing location
-
setLocationCaption
public void setLocationCaption(java.lang.String locationCaption)
Sets the caption for the signing location.- Parameters:
locationCaption
- the signing location caption
-
getSignatureCreator
public java.lang.String getSignatureCreator()
Gets the signature creator.- Returns:
- the signature creator
-
setSignatureCreator
public void setSignatureCreator(java.lang.String signatureCreator)
Sets the name of the application used to create the signature.- Parameters:
signatureCreator
- the name of the signature creating application
-
getContact
public java.lang.String getContact()
Gets the signing contact.- Returns:
- the signing contact
-
setContact
public void setContact(java.lang.String contact)
Sets the signing contact.- Parameters:
contact
- the signing contact
-
getSignDate
public java.util.Calendar getSignDate()
Gets the signature date.- Returns:
- the signature date
-
setSignDate
public void setSignDate(java.util.Calendar signDate)
Sets the signature date.- Parameters:
signDate
- the signature date
-
getRangeStream
public java.io.InputStream getRangeStream() throws java.io.IOException
Gets the document bytes that are hashable when using external signatures. The general sequence is: preClose(), getRangeStream() and close().- Returns:
- the document bytes that are hashable
- Throws:
java.io.IOException
-
getUnderlyingSource
private RandomAccessSource getUnderlyingSource() throws java.io.IOException
- Returns:
- the underlying source
- Throws:
java.io.IOException
-
addDeveloperExtension
public void addDeveloperExtension(PdfDeveloperExtension de)
Adds the appropriate developer extension.
-
getCryptoDictionary
public PdfDictionary getCryptoDictionary()
Gets the user made signature dictionary. This is the dictionary at the /V key.- Returns:
- the user made signature dictionary
-
setCryptoDictionary
public void setCryptoDictionary(PdfDictionary cryptoDictionary)
Sets a user made signature dictionary. This is the dictionary at the /V key.- Parameters:
cryptoDictionary
- a user made signature dictionary
-
setCertificate
public void setCertificate(java.security.cert.Certificate signCertificate)
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
-
getCertificate
public java.security.cert.Certificate getCertificate()
-
getSignatureEvent
public PdfSignatureAppearance.SignatureEvent getSignatureEvent()
Getter for property signatureEvent.- Returns:
- Value of property signatureEvent.
-
setSignatureEvent
public void setSignatureEvent(PdfSignatureAppearance.SignatureEvent signatureEvent)
Sets the signature event to allow modification of the signature dictionary.- Parameters:
signatureEvent
- the signature event
-
getFieldName
public java.lang.String getFieldName()
Gets the field name.- Returns:
- the field name
-
getNewSigName
public java.lang.String getNewSigName()
Gets a new signature field name that doesn't clash with any existing name.- Returns:
- a new signature field name
-
getPage
public int getPage()
Gets the page number of the field.- Returns:
- the page number of the field
-
getRect
public Rectangle getRect()
Gets the rectangle representing the signature dimensions.- Returns:
- the rectangle representing the signature dimensions. It may be
null
or have zero width or height for invisible signatures
-
getPageRect
public Rectangle getPageRect()
Gets the rectangle that represent the position and dimension of the signature in the page.- Returns:
- the rectangle that represent the position and dimension of the signature in the page
-
isInvisible
public boolean isInvisible()
Gets the visibility status of the signature.- Returns:
- the visibility status of the signature
-
setVisibleSignature
public void setVisibleSignature(Rectangle pageRect, int page, java.lang.String fieldName)
Sets the signature to be visible. It creates a new visible signature field.- Parameters:
pageRect
- the position and dimension of the field in the pagepage
- the page to place the field. The fist page is 1fieldName
- the field name ornull
to generate automatically a new field name
-
setVisibleSignature
public void setVisibleSignature(java.lang.String fieldName)
Sets the signature to be visible. An empty signature field with the same name must already exist.- Parameters:
fieldName
- the existing empty signature field name
-
getRenderingMode
public PdfSignatureAppearance.RenderingMode getRenderingMode()
Gets the rendering mode for this signature.- Returns:
- the rendering mode for this signature
- Since:
- 5.0.1
-
setRenderingMode
public void setRenderingMode(PdfSignatureAppearance.RenderingMode renderingMode)
Sets the rendering mode for this signature.- Parameters:
renderingMode
- the rendering mode- Since:
- 5.0.1
-
getSignatureGraphic
public Image getSignatureGraphic()
Gets the Image object to render.- Returns:
- the image
-
setSignatureGraphic
public void setSignatureGraphic(Image signatureGraphic)
Sets the Image object to render when Render is set toRenderingMode.GRAPHIC
orRenderingMode.GRAPHIC_AND_DESCRIPTION
.- Parameters:
signatureGraphic
- image rendered. Ifnull
the mode is defaulted toRenderingMode.DESCRIPTION
-
isAcro6Layers
public boolean isAcro6Layers()
Gets the Acrobat 6.0 layer mode.- Returns:
- the Acrobat 6.0 layer mode
-
setAcro6Layers
public void setAcro6Layers(boolean acro6Layers)
Deprecated.Adobe no longer supports Adobe Acrobat / Reader versions older than 9Acrobat 6.0 and higher recommends that only layer n0 and n2 be present. Use this method with valuefalse
if you want to ignore this recommendation.- Parameters:
acro6Layers
- iftrue
only the layers n0 and n2 will be present
-
getLayer
public PdfTemplate getLayer(int layer)
Gets a template layer to create a signature appearance. The layers can go from 0 to 4, but only layer 0 and 2 will be used if acro6Layers is true.Consult PPKAppearances.pdf for further details.
- Parameters:
layer
- the layer- Returns:
- a template
-
setReuseAppearance
public void setReuseAppearance(boolean reuseAppearance)
Indicates that the existing appearances needs to be reused as layer 0.
-
getImage
public Image getImage()
Gets the background image for the layer 2.- Returns:
- the background image for the layer 2
-
setImage
public void setImage(Image image)
Sets the background image for the layer 2.- Parameters:
image
- the background image for the layer 2
-
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
public void setImageScale(float imageScale)
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
-
setLayer2Text
public void setLayer2Text(java.lang.String text)
Sets the signature text identifying the signer.- Parameters:
text
- the signature text identifying the signer. Ifnull
or not set a standard description will be used
-
getLayer2Text
public java.lang.String getLayer2Text()
Gets the signature text identifying the signer if set by setLayer2Text().- Returns:
- the signature text identifying the signer
-
getLayer2Font
public Font getLayer2Font()
Gets the n2 and n4 layer font.- Returns:
- the n2 and n4 layer font
-
setLayer2Font
public void setLayer2Font(Font layer2Font)
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
-
setRunDirection
public void setRunDirection(int runDirection)
Sets the run direction in the n2 and n4 layer.- Parameters:
runDirection
- the run direction
-
getRunDirection
public int getRunDirection()
Gets the run direction.- Returns:
- the run direction
-
setLayer4Text
public void setLayer4Text(java.lang.String text)
Sets the text identifying the signature status. Will be ignored if acro6Layers is true.- Parameters:
text
- the text identifying the signature status. Ifnull
or not set the description "Signature Not Verified" will be used
-
getLayer4Text
public java.lang.String getLayer4Text()
Gets the text identifying the signature status if set by setLayer4Text().- Returns:
- the text identifying the signature status
-
getTopLayer
public PdfTemplate getTopLayer()
Gets the template that aggregates all appearance layers. This corresponds to the /FRM resource.Consult PPKAppearances.pdf for further details.
- Returns:
- the template that aggregates all appearance layers
-
getAppearance
public PdfTemplate getAppearance() throws DocumentException
Gets the main appearance layer.Consult PPKAppearances.pdf for further details.
- Returns:
- the main appearance layer
- Throws:
DocumentException
- on error
-
createBlankN0
private void createBlankN0()
-
getStamper
public PdfStamper getStamper()
Gets thePdfStamper
associated with this instance.- Returns:
- the
PdfStamper
associated with this instance
-
setStamper
void setStamper(PdfStamper stamper)
Sets the PdfStamper- Parameters:
stamper
- PdfStamper
-
getSigout
ByteBuffer getSigout()
Getter for the byte buffer.
-
setSigout
void setSigout(ByteBuffer sigout)
Setter for the byte buffer.
-
getOriginalout
java.io.OutputStream getOriginalout()
Getter for the OutputStream.
-
setOriginalout
void setOriginalout(java.io.OutputStream originalout)
Setter for the OutputStream.
-
getTempFile
public java.io.File getTempFile()
Gets the temporary file.- Returns:
- the temporary file or
null
is the document is created in memory
-
setTempFile
void setTempFile(java.io.File tempFile)
Setter for the temporary file.- Parameters:
tempFile
-
-
getFieldLockDict
public PdfSigLockDictionary getFieldLockDict()
Getter for the field lock dictionary.- Returns:
- Field lock dictionary.
-
setFieldLockDict
public void setFieldLockDict(PdfSigLockDictionary fieldLock)
Setter for the field lock dictionary.Be aware: if a signature is created on an existing signature field, then its /Lock dictionary takes the precedence (if it exists).
- Parameters:
fieldLock
- Field lock dictionary.
-
isPreClosed
public boolean isPreClosed()
Checks if the document is in the process of closing.- Returns:
true
if the document is in the process of closing,false
otherwise
-
preClose
public void preClose(java.util.HashMap<PdfName,java.lang.Integer> exclusionSizes) throws java.io.IOException, DocumentException
This is the first method to be called when using external signatures. The general sequence is: preClose(), getDocumentBytes() and close().If calling preClose() dont't call PdfStamper.close().
exclusionSizes
must contain at least thePdfName.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.- Parameters:
exclusionSizes
- aHashMap
with names and sizes to be excluded in the signature calculation. The key is aPdfName
and the value anInteger
. At least thePdfName.CONTENTS
must be present- Throws:
java.io.IOException
- on errorDocumentException
- on error
-
addDocMDP
private void addDocMDP(PdfDictionary crypto)
Adds keys to the signature dictionary that define the certification level and the permissions. This method is only used for Certifying signatures.- Parameters:
crypto
- the signature dictionary
-
addFieldMDP
private void addFieldMDP(PdfDictionary crypto, PdfDictionary fieldLock)
Adds keys to the signature dictionary that define the field permissions. This method is only used for signatures that lock fields.- Parameters:
crypto
- the signature dictionary
-
close
public void close(PdfDictionary update) throws java.io.IOException, DocumentException
This is the last method to be called when using external signatures. The general sequence is: preClose(), getDocumentBytes() and close().update
is aPdfDictionary
that must have exactly the same keys as the ones provided inpreClose(HashMap)
.- Parameters:
update
- aPdfDictionary
with the key/value that will fill the holes defined inpreClose(HashMap)
- Throws:
DocumentException
- on errorjava.io.IOException
- on error
-
-