Class PDVisibleSigBuilder

  • All Implemented Interfaces:
    PDFTemplateBuilder

    public class PDVisibleSigBuilder
    extends java.lang.Object
    implements PDFTemplateBuilder
    Implementation of PDFTemplateBuilder. This builds the signature PDF but doesn't keep the elements, these are kept in its PDF template structure.
    • Field Detail

      • LOG

        private static final org.apache.commons.logging.Log LOG
    • Constructor Detail

      • PDVisibleSigBuilder

        public PDVisibleSigBuilder()
        Constructor, creates PDF template structure.
    • Method Detail

      • createTemplate

        public void createTemplate​(PDPage page)
                            throws java.io.IOException
        Creates a PDDocument and adds the page parameter to it and keeps this as a template in the PDF template Structure.
        Specified by:
        createTemplate in interface PDFTemplateBuilder
        Parameters:
        page - the page to be added
        Throws:
        java.io.IOException - if the document could not be created
      • createSignatureField

        public void createSignatureField​(PDAcroForm acroForm)
                                  throws java.io.IOException
        Description copied from interface: PDFTemplateBuilder
        Creates signature fields.
        Specified by:
        createSignatureField in interface PDFTemplateBuilder
        Parameters:
        acroForm - the acroform the signature is added to
        Throws:
        java.io.IOException - if the signature could not be created
      • createSignature

        public void createSignature​(PDSignatureField pdSignatureField,
                                    PDPage page,
                                    java.lang.String signerName)
                             throws java.io.IOException
        Description copied from interface: PDFTemplateBuilder
        Creates the signature with the given name and assign it to the signature field parameter and assign the page parameter to the widget.
        Specified by:
        createSignature in interface PDFTemplateBuilder
        Parameters:
        pdSignatureField - the signature filed the signatur is added to
        page - the page the widgt ist added to
        signerName - the name of the person or authority signing the document. According to the PDF specification, this value should be used only when it is not possible to extract the name from the signature.
        Throws:
        java.io.IOException - if the signature could not be created
      • createAcroFormDictionary

        public void createAcroFormDictionary​(PDAcroForm acroForm,
                                             PDSignatureField signatureField)
                                      throws java.io.IOException
        Description copied from interface: PDFTemplateBuilder
        Create AcroForm Dictionary.
        Specified by:
        createAcroFormDictionary in interface PDFTemplateBuilder
        Parameters:
        acroForm - the acroform the signature field is added to
        signatureField - the signature filed to be added
        Throws:
        java.io.IOException - if the signature field could not be added
      • createSignatureRectangle

        public void createSignatureRectangle​(PDSignatureField signatureField,
                                             PDVisibleSignDesigner properties)
                                      throws java.io.IOException
        Description copied from interface: PDFTemplateBuilder
        Creates SignatureRectangle.
        Specified by:
        createSignatureRectangle in interface PDFTemplateBuilder
        Parameters:
        signatureField - the signature field the rectangle is added to
        properties - the properties used to create the rectangle
        Throws:
        java.io.IOException - if the rectangle could not be created
      • createAffineTransform

        public void createAffineTransform​(java.awt.geom.AffineTransform affineTransform)
        Description copied from interface: PDFTemplateBuilder
        In order to create Affine Transform, using parameters.
        Specified by:
        createAffineTransform in interface PDFTemplateBuilder
        Parameters:
        affineTransform - the affine transformation to be used
      • createSignatureImage

        public void createSignatureImage​(PDDocument template,
                                         java.awt.image.BufferedImage image)
                                  throws java.io.IOException
        Description copied from interface: PDFTemplateBuilder
        Creates signature image.
        Specified by:
        createSignatureImage in interface PDFTemplateBuilder
        Parameters:
        template - the document the image is added to
        image - to imager to be added
        Throws:
        java.io.IOException - if the image could not be added
      • createFormatterRectangle

        public void createFormatterRectangle​(int[] params)
        Description copied from interface: PDFTemplateBuilder
        An array of four numbers in the form coordinate system, giving the coordinates of the left, bottom, right, and top edges, respectively, of the form XObject’s bounding box. These boundaries shall be used to clip the form XObject and to determine its size for caching.
        Specified by:
        createFormatterRectangle in interface PDFTemplateBuilder
        Parameters:
        params - the parameters of the formatter rectangle
      • createHolderForm

        public void createHolderForm​(PDResources holderFormResources,
                                     PDStream holderFormStream,
                                     PDRectangle bbox)
        Description copied from interface: PDFTemplateBuilder
        Creates Form
        Specified by:
        createHolderForm in interface PDFTemplateBuilder
        Parameters:
        holderFormResources - resources to be used for the form object
        holderFormStream - the stream to be used for the form object
        bbox - the bounding box of the form object
      • createAppearanceDictionary

        public void createAppearanceDictionary​(PDFormXObject holderForm,
                                               PDSignatureField signatureField)
                                        throws java.io.IOException
        Description copied from interface: PDFTemplateBuilder
        Creates appearance dictionary
        Specified by:
        createAppearanceDictionary in interface PDFTemplateBuilder
        Parameters:
        holderForm - form object to be used for the appearance stream
        signatureField - the signature field the appearance stream is added to
        Throws:
        java.io.IOException - if the appearance stream could not be created
      • createInnerForm

        public void createInnerForm​(PDResources innerFormResources,
                                    PDStream innerFormStream,
                                    PDRectangle bbox)
        Description copied from interface: PDFTemplateBuilder
        Creates InnerForm.
        Specified by:
        createInnerForm in interface PDFTemplateBuilder
        Parameters:
        innerFormResources - resources to be used for the inner form object
        innerFormStream - the stream to be used for the inner form object
        bbox - the bounding box of the inner form object
      • createImageForm

        public void createImageForm​(PDResources imageFormResources,
                                    PDResources innerFormResource,
                                    PDStream imageFormStream,
                                    PDRectangle bbox,
                                    java.awt.geom.AffineTransform at,
                                    PDImageXObject img)
                             throws java.io.IOException
        Description copied from interface: PDFTemplateBuilder
        Creates Image form
        Specified by:
        createImageForm in interface PDFTemplateBuilder
        Parameters:
        imageFormResources - the resources of the form object
        innerFormResource - the resources the image object is added
        imageFormStream - the stream of the form object
        bbox - the bounding box of the form object
        at - the matrix of the form object
        img - the image object to be used for the form object
        Throws:
        java.io.IOException - if the form object could not be created
      • createBackgroundLayerForm

        public void createBackgroundLayerForm​(PDResources innerFormResource,
                                              PDRectangle bbox)
                                       throws java.io.IOException
        Description copied from interface: PDFTemplateBuilder
        Creates the background layer form (n0).
        Specified by:
        createBackgroundLayerForm in interface PDFTemplateBuilder
        Parameters:
        innerFormResource - resources to be used for the form object
        bbox - the bounding box of the form object
        Throws:
        java.io.IOException - if the form object could not be created
      • injectProcSetArray

        public void injectProcSetArray​(PDFormXObject innerForm,
                                       PDPage page,
                                       PDResources innerFormResources,
                                       PDResources imageFormResources,
                                       PDResources holderFormResources,
                                       COSArray procSet)
        Description copied from interface: PDFTemplateBuilder
        Inject procSetArray
        Specified by:
        injectProcSetArray in interface PDFTemplateBuilder
        Parameters:
        innerForm - form object the given proc set array is added to
        page - page the given proc set array is added to
        innerFormResources - inner form resources the given proc set array is added to
        imageFormResources - inner image resources the given proc set array is added to
        holderFormResources - holder form resources the given proc set array is added to
        procSet - the pro set array to be added
      • injectAppearanceStreams

        public void injectAppearanceStreams​(PDStream holderFormStream,
                                            PDStream innerFormStream,
                                            PDStream imageFormStream,
                                            COSName imageFormName,
                                            COSName imageName,
                                            COSName innerFormName,
                                            PDVisibleSignDesigner properties)
                                     throws java.io.IOException
        Description copied from interface: PDFTemplateBuilder
        injects appearance streams
        Specified by:
        injectAppearanceStreams in interface PDFTemplateBuilder
        Parameters:
        holderFormStream - the holder form stream
        innerFormStream - the inner form stream
        imageFormStream - the image form stream
        imageFormName - the name of the form image to be used
        imageName - the name of the image to be used
        innerFormName - the name of the form object to be used
        properties - properties to be used to create the appearance stream
        Throws:
        java.io.IOException - if the appearance stream could not be created
      • appendRawCommands

        public void appendRawCommands​(java.io.OutputStream os,
                                      java.lang.String commands)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • createWidgetDictionary

        public void createWidgetDictionary​(PDSignatureField signatureField,
                                           PDResources holderFormResources)
                                    throws java.io.IOException
        Description copied from interface: PDFTemplateBuilder
        adds Widget Dictionary
        Specified by:
        createWidgetDictionary in interface PDFTemplateBuilder
        Parameters:
        signatureField - the field to be used as widget dictionary
        holderFormResources - the resources to be added to the widget dictionary
        Throws:
        java.io.IOException - if the widget dictionary could not be created
      • closeTemplate

        public void closeTemplate​(PDDocument template)
                           throws java.io.IOException
        Description copied from interface: PDFTemplateBuilder
        Closes template
        Specified by:
        closeTemplate in interface PDFTemplateBuilder
        Parameters:
        template - the document to be closed
        Throws:
        java.io.IOException - if the document could not be closed