Class PdfSignatureAppearance


  • public class PdfSignatureAppearance
    extends java.lang.Object
    Provides convenient methods to make a signature appearance. Use it in conjunction with PdfSigner.
    • Field Detail

      • document

        private final PdfDocument document
        The document to be signed.
      • 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.
      • reason

        private java.lang.String reason
        The reason for signing.
      • reasonCaption

        private java.lang.String reasonCaption
        The caption for the reason for signing.
      • location

        private java.lang.String location
        Holds value of property location.
      • locationCaption

        private java.lang.String locationCaption
        The caption for the location of signing.
      • 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.
      • signDate

        private java.util.Calendar signDate
        Holds value of property signDate.
      • signCertificate

        private java.security.cert.Certificate signCertificate
        The signing certificate.
      • signatureGraphic

        private ImageData signatureGraphic
        The image that needs to be used for a visible signature.
      • image

        private ImageData image
        A background image for the text in layer 2.
      • imageScale

        private float imageScale
        The scaling to be applied to the background image.
      • description

        private java.lang.String description
        The text that goes in Layer 2 of the signature appearance.
      • font

        private PdfFont font
        Font for the text in Layer 2.
      • fontProvider

        private FontProvider fontProvider
        Font provider for the text.
      • fontFamilyNames

        private java.lang.String[] fontFamilyNames
        Font family for the text.
      • fontSize

        private float fontSize
        Font size for the font of Layer 2.
      • fontColor

        private Color fontColor
        Font color for the font of Layer 2.
      • n0

        private PdfFormXObject n0
        Zero level of the signature appearance.
      • n2

        private PdfFormXObject n2
        Second level of the signature appearance.
      • fieldName

        private java.lang.String fieldName
        Indicates the field to be signed.
      • reuseAppearance

        private boolean reuseAppearance
        Indicates if we need to reuse the existing appearance as layer 0.
      • reuseAppearanceSet

        private boolean reuseAppearanceSet
    • Constructor Detail

      • 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 Detail

      • getPageNumber

        @Deprecated
        public int getPageNumber()
        Deprecated.
        won't be public in the next major release. Use PdfSigner.getPageNumber() instead.
        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

        @Deprecated
        public PdfSignatureAppearance setPageNumber​(int pageNumber)
        Deprecated.
        won't be public in the next major release. Use PdfSigner.setPageNumber(int) instead.
        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

        @Deprecated
        public Rectangle getPageRect()
        Deprecated.
        won't be public in the next major release. Use PdfSigner.getPageRect() instead.
        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

        @Deprecated
        public PdfSignatureAppearance setPageRect​(Rectangle pageRect)
        Deprecated.
        won't be public in the next major release. Use PdfSigner.setPageRect(Rectangle) instead.
        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.
      • getRenderingMode

        @Deprecated
        public PdfSignatureAppearance.RenderingMode getRenderingMode()
        Deprecated.
        in favour of SignatureFieldAppearance, rendering mode will be detected depending on specified setContent method parameters.
        Gets the rendering mode for this signature.
        Returns:
        the rendering mode for this signature.
      • setRenderingMode

        @Deprecated
        public PdfSignatureAppearance setRenderingMode​(PdfSignatureAppearance.RenderingMode renderingMode)
        Deprecated.
        in favour of SignatureFieldAppearance, rendering mode will be detected depending on specified setContent method parameters.
        Sets the rendering mode for this signature.
        Parameters:
        renderingMode - the rendering mode.
        Returns:
        this instance to support fluent interface.
      • getReason

        @Deprecated
        public java.lang.String getReason()
        Deprecated.
        won't be public in the next major release. Use PdfSigner.getReason() instead.
        Returns the signing reason.
        Returns:
        reason for signing.
      • setReason

        @Deprecated
        public PdfSignatureAppearance setReason​(java.lang.String reason)
        Deprecated.
        won't be public in the next major release. Use PdfSigner.setReason(java.lang.String) instead.
        Sets the signing reason.
        Parameters:
        reason - signing reason.
        Returns:
        this instance to support fluent interface.
      • setReasonCaption

        @Deprecated
        public PdfSignatureAppearance setReasonCaption​(java.lang.String reasonCaption)
        Deprecated.
        in favour of SignedAppearanceText that should be used for SignatureFieldAppearance.
        Sets the caption for the signing reason.
        Parameters:
        reasonCaption - A new signing reason caption.
        Returns:
        this instance to support fluent interface.
      • getLocation

        @Deprecated
        public java.lang.String getLocation()
        Deprecated.
        won't be public in the next major release. Use PdfSigner.getLocation() instead.
        Returns the signing location.
        Returns:
        signing location.
      • setLocation

        @Deprecated
        public PdfSignatureAppearance setLocation​(java.lang.String location)
        Deprecated.
        won't be public in the next major release. Use PdfSigner.setLocation(java.lang.String) instead.
        Sets the signing location.
        Parameters:
        location - A new signing location.
        Returns:
        this instance to support fluent interface.
      • setLocationCaption

        @Deprecated
        public PdfSignatureAppearance setLocationCaption​(java.lang.String locationCaption)
        Deprecated.
        in favour of SignedAppearanceText that should be used for SignatureFieldAppearance.
        Sets the caption for the signing location.
        Parameters:
        locationCaption - A new signing location caption.
        Returns:
        this instance to support fluent interface.
      • getSignatureCreator

        @Deprecated
        public java.lang.String getSignatureCreator()
        Deprecated.
        Returns the signature creator.
        Returns:
        The signature creator.
      • setSignatureCreator

        @Deprecated
        public PdfSignatureAppearance setSignatureCreator​(java.lang.String signatureCreator)
        Deprecated.
        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

        @Deprecated
        public java.lang.String getContact()
        Deprecated.
        Returns the signing contact.
        Returns:
        The signing contact.
      • setContact

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

        @Deprecated
        public PdfSignatureAppearance setCertificate​(java.security.cert.Certificate signCertificate)
        Deprecated.
        in favour of SignedAppearanceText that should be used for SignatureFieldAppearance. Specified certificate provides signer name.
        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

        @Deprecated
        public java.security.cert.Certificate getCertificate()
        Deprecated.
        in favour of SignedAppearanceText that should be used for SignatureFieldAppearance.
        Get the signing certificate.
        Returns:
        the signing certificate.
      • getSignatureGraphic

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

        @Deprecated
        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

        @Deprecated
        public PdfSignatureAppearance setLayer2Text​(java.lang.String text)
        Deprecated.
        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

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

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

        @Deprecated
        public float getLayer2FontSize()
        Deprecated.
        Gets the n2 and n4 layer font size.
        Returns:
        the n2 and n4 layer font size.
      • getLayer2FontColor

        @Deprecated
        public Color getLayer2FontColor()
        Deprecated.
        Gets the n2 layer font color.
        Returns:
        the n2 layer font color.
      • getSignatureAppearance

        public SignatureFieldAppearance getSignatureAppearance()
        Gets the signature layout element.
        Returns:
        the signature layout element.
      • setFontFamily

        @Deprecated
        public PdfSignatureAppearance setFontFamily​(java.lang.String... fontFamilyNames)
        Sets the preferable font families for the signature content. Note that FontProvider shall be set as well.
        Parameters:
        fontFamilyNames - defines an ordered list of preferable font families for the signature element.
        Returns:
        this instance to support fluent interface.
      • isInvisible

        @Deprecated
        public boolean isInvisible()
        Deprecated.
        won't be public in the next major release.
        Gets the visibility status of the signature.
        Returns:
        the visibility status of the signature.
      • getSignDate

        @Deprecated
        protected java.util.Calendar getSignDate()
        Deprecated.
        Returns the signature date.
        Returns:
        the signature date.
      • setSignDate

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

        protected PdfSignatureAppearance setFieldName​(java.lang.String fieldName)
        Set the field name of the appearance. Field name indicates the field to be signed if it is already presented in the document (signing existing field). Required for reuseAppearance option.
        Parameters:
        fieldName - name of the field
        Returns:
        this instance to support fluent interface
      • isReuseAppearance

        boolean isReuseAppearance()
        Returns reuseAppearance value which indicates that the existing appearances needs to be reused as a background layer.
        Returns:
        an appearances reusing flag value.
      • isReuseAppearanceSet

        boolean isReuseAppearanceSet()
        Checks if reuseAppearance value was set using {@link this#setReuseAppearance(boolean)}. Used for backward compatibility.
        Returns:
        boolean value.
      • getBackgroundLayer

        PdfFormXObject getBackgroundLayer()
        Gets the background layer that is present when creating the signature field if it was set.
        Returns:
        n0 layer xObject.
      • getSignatureAppearanceLayer

        PdfFormXObject getSignatureAppearanceLayer()
        Gets the signature appearance layer that contains information about the signature if it was set.
        Returns:
        n2 layer xObject.
      • applyBackgroundImage

        void applyBackgroundImage()
      • setFontRelatedProperties

        private void setFontRelatedProperties()
      • setContent

        private void setContent()
      • populateExistingModelElement

        private void populateExistingModelElement()
      • getSignerName

        private java.lang.String getSignerName()