Class PdfSignatureAppearance

java.lang.Object
com.itextpdf.signatures.PdfSignatureAppearance

public class PdfSignatureAppearance extends Object
Provides convenient methods to make a signature appearance. Use it in conjunction with PdfSigner.
  • Constructor Details

    • PdfSignatureAppearance

      protected PdfSignatureAppearance (PdfDocument document, Rectangle pageRect, int pageNumber)
      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

      public PdfSignatureAppearance setPageNumber (int pageNumber)
      Sets the page number of the signature field which this signature appearance is associated with. Implicitly calls setPageRect(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

      public Rectangle 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

      public PdfSignatureAppearance setPageRect (Rectangle pageRect)
      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

      public PdfFormXObject 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

      public PdfFormXObject 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

      public PdfSignatureAppearance.RenderingMode getRenderingMode()
      Gets the rendering mode for this signature.
      Returns:
      the rendering mode for this signature
    • setRenderingMode

      public PdfSignatureAppearance setRenderingMode (PdfSignatureAppearance.RenderingMode renderingMode)
      Sets the rendering mode for this signature.
      Parameters:
      renderingMode - the rendering mode
      Returns:
      this instance to support fluent interface
    • getReason

      public String getReason()
      Returns the signing reason.
      Returns:
      reason for signing
    • setReason

      public PdfSignatureAppearance setReason (String reason)
      Sets the signing reason.
      Parameters:
      reason - signing reason.
      Returns:
      this instance to support fluent interface
    • setReasonCaption

      public PdfSignatureAppearance setReasonCaption (String reasonCaption)
      Sets the caption for the signing reason.
      Parameters:
      reasonCaption - A new signing reason caption
      Returns:
      this instance to support fluent interface
    • getLocation

      public String getLocation()
      Returns the signing location.
      Returns:
      signing location
    • setLocation

      public PdfSignatureAppearance setLocation (String location)
      Sets the signing location.
      Parameters:
      location - A new signing location
      Returns:
      this instance to support fluent interface
    • setLocationCaption

      public PdfSignatureAppearance setLocationCaption (String locationCaption)
      Sets the caption for the signing location.
      Parameters:
      locationCaption - A new signing location caption
      Returns:
      this instance to support fluent interface
    • getSignatureCreator

      public String getSignatureCreator()
      Returns the signature creator.
      Returns:
      The signature creator
    • setSignatureCreator

      public PdfSignatureAppearance setSignatureCreator (String signatureCreator)
      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

      public String getContact()
      Returns the signing contact.
      Returns:
      The signing contact
    • setContact

      public PdfSignatureAppearance setContact (String contact)
      Sets the signing contact.
      Parameters:
      contact - A new signing contact
      Returns:
      this instance to support fluent interface
    • setCertificate

      public PdfSignatureAppearance setCertificate (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
      Returns:
      this instance to support fluent interface
    • getCertificate

      public Certificate getCertificate()
      Get the signing certificate.
      Returns:
      the signing certificate
    • getSignatureGraphic

      public ImageData getSignatureGraphic()
      Gets the Image object to render.
      Returns:
      the image
    • setSignatureGraphic

      public PdfSignatureAppearance setSignatureGraphic (ImageData signatureGraphic)
      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

      public PdfSignatureAppearance setReuseAppearance (boolean reuseAppearance)
      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

      public ImageData getImage()
      Gets the background image for the layer 2.
      Returns:
      the background image for the layer 2
    • setImage

      public PdfSignatureAppearance setImage (ImageData image)
      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

      public PdfSignatureAppearance 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
      Returns:
      this instance to support fluent interface
    • setLayer2Text

      public PdfSignatureAppearance setLayer2Text (String text)
      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

      public String getLayer2Text()
      Gets the signature text identifying the signer if set by setLayer2Text().
      Returns:
      the signature text identifying the signer
    • getLayer2Font

      public PdfFont getLayer2Font()
      Gets the n2 and n4 layer font.
      Returns:
      the n2 and n4 layer font
    • setLayer2Font

      public PdfSignatureAppearance setLayer2Font (PdfFont 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
      Returns:
      this instance to support fluent interface
    • setLayer2FontSize

      public PdfSignatureAppearance setLayer2FontSize (float fontSize)
      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

      public PdfSignatureAppearance setLayer2FontColor (Color color)
      Sets the n2 and n4 layer font color.
      Parameters:
      color - font color
      Returns:
      this instance to support fluent interface
    • getLayer2FontColor

      public Color 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

      protected PdfFormXObject getAppearance() throws IOException
      Constructs appearance (top-level) for a signature.
      Returns:
      a top-level signature appearance
      Throws:
      IOException - if font cannot be created
      See Also:
    • getSignDate

      protected Calendar getSignDate()
      Returns the signature date.
      Returns:
      the signature date
    • setSignDate

      protected PdfSignatureAppearance setSignDate (Calendar signDate)
      Sets the signature date.
      Parameters:
      signDate - A new signature date
      Returns:
      this instance to support fluent interface
    • setFieldName

      protected PdfSignatureAppearance setFieldName (String fieldName)
      Set the field name of the appearance.
      Parameters:
      fieldName - name of the field
      Returns:
      this instance to support fluent interface