com.qoppa.pdf
Class SignatureAppearance

java.lang.Object
  extended by com.qoppa.pdf.SignatureAppearance

public class SignatureAppearance
extends Object

This class provides functionality to customize the appearance of a visible signature when a document is signed. The default signature appearance uses the distinguished name properties of the signing certificate and displays it as:

 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
 \               Digitally signed by  \
 \               Your Name            \
 \   Your        common name, org unit\
 \   Name        org name, locality   \ 
 \               state, country, email\
 \               Date                 \
 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
 
Each of these attributes can be visible or hidden. See setVisibleName(boolean), setVisibleCommonName(boolean), setVisibleOrgUnit(boolean), setVisibleOrgName(boolean), setVisibleLocal(boolean), setVisibleState(boolean), setVisibleCountry(boolean), setVisibleEmail(boolean), setVisibleDate(boolean) . The orientation can also be reversed with setTextOrientation(int).

Custom text content can also be used instead of the distinguished name of the signing certificate. See setTextLeft(java.lang.String), setTextRight(java.lang.String)

Additionally, an image can be used to create the signature appearance setImage(java.awt.image.BufferedImage). The image can be placed in the center, left or right side of the field with setImagePosition(int).

Author:
Qoppa Software

Constructor Summary
SignatureAppearance()
          Default constructor
SignatureAppearance(String xmlString)
          This constructor creates a SignatureAppearance from a properly formatted XML string.
 
Method Summary
 String getDisplayName()
          This name is not used to generate the appearance stream.
 long getID()
          This unique identifier is not used to generate the appearance stream.
 BufferedImage getImage()
          Returns the buffered image to use when creating the signature appearance.
 int getImagePosition()
          Returns the horizontal position of the image.
 float getImageTransparency()
          Returns the image transparency value to use when drawing the image on the SignatureField.
 String getTextLeft()
          Returns the text to display on the left side of the signature appearance.
 int getTextOrientation()
          Returns the orientation of the text.
 String getTextRight()
          Returns the text to display on the right side of the signature appearance.
 boolean isVisibleCommonName()
          Returns whether or not the common name should be used when creating the signature appearance.
 boolean isVisibleCountry()
          Returns whether or not the country should be used when creating the signature appearance.
 boolean isVisibleDate()
          Returns whether or not the date should be used when creating the signature appearance.
 boolean isVisibleDigitallySigned()
          Returns whether or not the "Digitally signed by..." label should be used when creating the signature appearance.
 boolean isVisibleEmail()
          Returns whether or not the email address should be used when creating the signature appearance.
 boolean isVisibleLocal()
          Returns whether or not the locality should be used when creating the signature appearance.
 boolean isVisibleName()
          Returns whether or not the name should be used when creating the signature appearance.
 boolean isVisibleOrgName()
          Returns whether or not the organization name should be used when creating the signature appearance.
 boolean isVisibleOrgUnit()
          Returns whether or not the organizational unit should be used when creating the signature appearance.
 boolean isVisibleState()
          Returns whether or not the state should be used when creating the signature appearance.
 void setDisplayName(String displayName)
          This name is not used to generate the appearance stream.
 void setImage(BufferedImage bufferedImage)
          Sets a buffered image to use then creating the signature appearance.
 void setImageFile(String fileName)
          If the image file name is set, this SignatureAppearance will attempt to load a BufferedImage from the file.
 void setImagePosition(int imagePosition)
          Sets the horizontal position of the image.
 void setImageTransparency(float alpha)
          Sets the image transparency value to use when drawing the image on the SignatureField.
 void setTextLeft(String text)
          Sets the left text property to use when creating the signature appearance.
 void setTextOrientation(int orientation)
          Sets the orientation of the text.
 void setTextRight(String text)
          Sets the right text property to use when creating the signature appearance.
 void setVisibleCommonName(boolean visible)
          If the distinguished name of the signing certificate contains a common name, this sets whether or not the common name should be used when creating the signature appearance.
 void setVisibleCountry(boolean visible)
          If the distinguished name of the signing certificate contains a country code, this sets whether or not the country code should be used when creating the signature appearance.
 void setVisibleDate(boolean visible)
          This sets whether or not the date should be used when creating the signature appearance.
 void setVisibleDigitallySigned(boolean visible)
          Sets whether or not the "Digitally signed by..." label should be used when creating the signature appearance.
 void setVisibleEmail(boolean visible)
          If the distinguished name of the signing certificate contains an email address, this sets whether or not the email address should be used when creating the signature appearance.
 void setVisibleLocal(boolean visible)
          If the distinguished name of the signing certificate contains a locality, this sets whether or not the locality should be used when creating the signature appearance.
 void setVisibleName(boolean visible)
          If the distinguished name of the signing certificate contains a common name, this sets whether or not the name should be used when creating the signature appearance.
 void setVisibleOrgName(boolean visible)
          If the distinguished name of the signing certificate contains an organization name, this sets whether or not the organization name should be used when creating the signature appearance.
 void setVisibleOrgUnit(boolean visible)
          If the distinguished name of the signing certificate contains an organizational unit, this sets whether or not the organizational unit should be used when creating the signature appearance.
 void setVisibleState(boolean visible)
          If the distinguished name of the signing certificate contains a state, this sets whether or not the state should be used when creating the signature appearance.
 void showCertificateDN(boolean visible)
          This is a convenience method set the visibility of all of the distinguished name properties of the signing certificate.
 String toString()
           
 String toXMLString()
          This method creates a String that contains an XML element of the Tool default properties.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SignatureAppearance

public SignatureAppearance()
Default constructor


SignatureAppearance

public SignatureAppearance(String xmlString)
This constructor creates a SignatureAppearance from a properly formatted XML string.

Parameters:
xmlString -
See Also:
toXMLString()
Method Detail

showCertificateDN

public void showCertificateDN(boolean visible)
This is a convenience method set the visibility of all of the distinguished name properties of the signing certificate.

Parameters:
visible -
See Also:
setVisibleCommonName(boolean), setVisibleCountry(boolean), setVisibleEmail(boolean), setVisibleLocal(boolean), setVisibleOrgName(boolean), setVisibleOrgUnit(boolean), setVisibleState(boolean)

isVisibleName

public boolean isVisibleName()
Returns whether or not the name should be used when creating the signature appearance. The name appears in large text on the left in left-to-right layout.

Returns:
visibleName flag indicating if the name should be visible

setVisibleName

public void setVisibleName(boolean visible)
If the distinguished name of the signing certificate contains a common name, this sets whether or not the name should be used when creating the signature appearance. This namne appears in large text on the left in left-to-right layout.

Parameters:
visible - flag indicating if the name should be visible

isVisibleDigitallySigned

public boolean isVisibleDigitallySigned()
Returns whether or not the "Digitally signed by..." label should be used when creating the signature appearance.

Returns:
visibleName flag indicating if the "Digitally signed by..." label should be visible

setVisibleDigitallySigned

public void setVisibleDigitallySigned(boolean visible)
Sets whether or not the "Digitally signed by..." label should be used when creating the signature appearance.

Parameters:
visible - flag indicating if the "Digitally signed by..." label should be visible

isVisibleCommonName

public boolean isVisibleCommonName()
Returns whether or not the common name should be used when creating the signature appearance.

Returns:
visibleCommonName flag indicating if the common name should be visible

setVisibleCommonName

public void setVisibleCommonName(boolean visible)
If the distinguished name of the signing certificate contains a common name, this sets whether or not the common name should be used when creating the signature appearance.

Parameters:
visible - flag indicating if the common name should be visible

isVisibleOrgUnit

public boolean isVisibleOrgUnit()
Returns whether or not the organizational unit should be used when creating the signature appearance.

Returns:
visibleOrgUnit flag indicating if the organizational unit should be visible

setVisibleOrgUnit

public void setVisibleOrgUnit(boolean visible)
If the distinguished name of the signing certificate contains an organizational unit, this sets whether or not the organizational unit should be used when creating the signature appearance.

Parameters:
visible - flag indicating if the organizational unit should be visible

isVisibleOrgName

public boolean isVisibleOrgName()
Returns whether or not the organization name should be used when creating the signature appearance.

Returns:
visibleOrgName flag indicating if the organization name should be visible

setVisibleOrgName

public void setVisibleOrgName(boolean visible)
If the distinguished name of the signing certificate contains an organization name, this sets whether or not the organization name should be used when creating the signature appearance.

Parameters:
visible - flag indicating if the organization name should be visible

isVisibleLocal

public boolean isVisibleLocal()
Returns whether or not the locality should be used when creating the signature appearance.

Returns:
visibleLocal flag indicating if the locality should be visible

setVisibleLocal

public void setVisibleLocal(boolean visible)
If the distinguished name of the signing certificate contains a locality, this sets whether or not the locality should be used when creating the signature appearance.

Parameters:
visible - flag indicating if the locality should be visible

isVisibleState

public boolean isVisibleState()
Returns whether or not the state should be used when creating the signature appearance.

Returns:
visibleState flag indicating if the state should be visible

setVisibleState

public void setVisibleState(boolean visible)
If the distinguished name of the signing certificate contains a state, this sets whether or not the state should be used when creating the signature appearance.

Parameters:
visible - flag indicating if the state should be visible

isVisibleCountry

public boolean isVisibleCountry()
Returns whether or not the country should be used when creating the signature appearance.

Returns:
visibleCountry flag indicating if the country should be visible

setVisibleCountry

public void setVisibleCountry(boolean visible)
If the distinguished name of the signing certificate contains a country code, this sets whether or not the country code should be used when creating the signature appearance.

Parameters:
visible - flag indicating if the country code should be visible

isVisibleEmail

public boolean isVisibleEmail()
Returns whether or not the email address should be used when creating the signature appearance.

Returns:
visibleEmail flag indicating if the email address should be visible

setVisibleEmail

public void setVisibleEmail(boolean visible)
If the distinguished name of the signing certificate contains an email address, this sets whether or not the email address should be used when creating the signature appearance.

Parameters:
visible - flag indicating if the email address should be visible

isVisibleDate

public boolean isVisibleDate()
Returns whether or not the date should be used when creating the signature appearance.

Returns:
visibleDate flag indicating if the date should be visible

setVisibleDate

public void setVisibleDate(boolean visible)
This sets whether or not the date should be used when creating the signature appearance.

Parameters:
visible - flag indicating if the date should be visible

getImage

public BufferedImage getImage()
                       throws IOException
Returns the buffered image to use when creating the signature appearance. If the image file name is set with setImageFile(String) and the BufferedImage is null, this method will attempt to read the a BufferedImage from the image file name.

Returns:
the buffered image to use when creating the signature appearance.
Throws:
IOException

setImage

public void setImage(BufferedImage bufferedImage)
Sets a buffered image to use then creating the signature appearance.

Parameters:
bufferedImage - the buffered image to use when creating the signature appearance

getImageTransparency

public float getImageTransparency()
Returns the image transparency value to use when drawing the image on the SignatureField.

Returns:
the imageTransparency property

setImageTransparency

public void setImageTransparency(float alpha)
Sets the image transparency value to use when drawing the image on the SignatureField. The value must be between 0.0 and 1.0 inclusive.

Parameters:
alpha - the image transparency to set
Throws:
IllegalArgumentException

getImagePosition

public int getImagePosition()
Returns the horizontal position of the image.

Returns:
One of the following constants defined in SwingConstants: LEFT, CENTER, RIGHT, LEADING or TRAILING.
See Also:
SwingConstants

setImagePosition

public void setImagePosition(int imagePosition)
Sets the horizontal position of the image.

Parameters:
imagePosition - One of the following constants defined in SwingConstants: LEFT, CENTER (the default), RIGHT, LEADING, or TRAILING.

getTextLeft

public String getTextLeft()
Returns the text to display on the left side of the signature appearance.

Returns:
the text to display on the left side of the signature appearance

setTextLeft

public void setTextLeft(String text)
Sets the left text property to use when creating the signature appearance.

Parameters:
text - the text on the left side of the signature field

getTextRight

public String getTextRight()
Returns the text to display on the right side of the signature appearance.

Returns:
the text to display on the right side of the signature appearance

setTextRight

public void setTextRight(String text)
Sets the right text property to use when creating the signature appearance.

Parameters:
text - the text on the right side of the signature field

setTextOrientation

public void setTextOrientation(int orientation)
Sets the orientation of the text.

Parameters:
orientation - One of the following constants defined in SwingConstants: LEFT, RIGHT, LEADING (the default) or TRAILING.

getTextOrientation

public int getTextOrientation()
Returns the orientation of the text.

Returns:
The value of the textOrientation property, one of the following constants defined in SwingConstants: LEFT, RIGHT, LEADING or TRAILING.
See Also:
setTextOrientation(int), SwingConstants

setImageFile

public void setImageFile(String fileName)
If the image file name is set, this SignatureAppearance will attempt to load a BufferedImage from the file.

Parameters:
fileName -

getID

public long getID()
This unique identifier is not used to generate the appearance stream. It is only used in saving the SignatureAppearance as an XML string, or when creating a SignatureAppearance from an XML string.

Returns:
the ID of the signature appearance
See Also:
toXMLString(), SignatureAppearance(String)

setDisplayName

public void setDisplayName(String displayName)
This name is not used to generate the appearance stream. It is only used as a label for the SignatureAppearance. It is also used in saving the SignatureAppearance as an XML string, or when creating a SignatureAppearance from an XML string.

Parameters:
displayName - the displayName to set
See Also:
toXMLString(), SignatureAppearance(String)

getDisplayName

public String getDisplayName()
This name is not used to generate the appearance stream. It is only used as a label for the SignatureAppearance. It is also used in saving the SignatureAppearance as an XML string, or when creating a SignatureAppearance from an XML string.

Returns:
the displayName
See Also:
toXMLString(), SignatureAppearance(String)

toString

public String toString()
Overrides:
toString in class Object

toXMLString

public String toXMLString()
This method creates a String that contains an XML element of the Tool default properties. This String can be stored and used to set the SignatureAppearance.

Returns:
A String containing an XML element of the SignatureAppearance properties
See Also:
SignatureAppearance(String)