org.apache.pdfbox.pdmodel.interactive.digitalsignature.visible

## Class PDVisibleSigBuilder

- java.lang.Object
- - org.apache.pdfbox.pdmodel.interactive.digitalsignature.visible.PDVisibleSigBuilder

All Implemented Interfaces:
  PDFTemplateBuilder

    public class PDVisibleSigBuilder
    extends 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.

Author:
  Vakhtang Koroghlishvili

### Constructor Summary

Constructors
Constructor and Description
`PDVisibleSigBuilder()` Constructor, creates PDF template structure.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `appendRawCommands(OutputStream os, String commands)`
`void` `closeTemplate(PDDocument template)` Closes template
`void` `createAcroForm(PDDocument template)` Creates Acro forms in the template.
`void` `createAcroFormDictionary(PDAcroForm acroForm, PDSignatureField signatureField)` Create AcroForm Dictionary.
`void` `createAffineTransform(AffineTransform affineTransform)` In order to create Affine Transform, using parameters.
`void` `createAppearanceDictionary(PDFormXObject holderForm, PDSignatureField signatureField)` Creates appearance dictionary
`void` `createBackgroundLayerForm(PDResources innerFormResource, PDRectangle bbox)` Creates the background layer form (n0).
`void` `createFormatterRectangle(int[] params)` 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.
`void` `createHolderForm(PDResources holderFormResources, PDStream holderFormStream, PDRectangle bbox)` Creates Form
`void` `createHolderFormResources()` Creates resources of form
`void` `createHolderFormStream(PDDocument template)` Create a holder for the form stream.
`void` `createImageForm(PDResources imageFormResources, PDResources innerFormResource, PDStream imageFormStream, PDRectangle bbox, AffineTransform at, PDImageXObject img)` Creates Image form
`void` `createImageFormResources()` Create resource of image form
`void` `createImageFormStream(PDDocument template)` Create image form stream.
`void` `createInnerForm(PDResources innerFormResources, PDStream innerFormStream, PDRectangle bbox)` Creates InnerForm.
`void` `createInnerFormResource()` Creates InnerForm
`void` `createInnerFormStream(PDDocument template)` Create a holder for the inner form stream.
`void` `createPage(PDVisibleSignDesigner properties)` Creates specified size page.
`void` `createProcSetArray()` Creates procSetArray of PDF,Text,ImageB,ImageC,ImageI.
`void` `createSignature(PDSignatureField pdSignatureField, PDPage page, String signerName)` Creates the signature with the given name and assign it to the signature field parameter and assign the page parameter to the widget.
`void` `createSignatureField(PDAcroForm acroForm)` Creates signature fields.
`void` `createSignatureImage(PDDocument template, BufferedImage image)` Creates signature image.
`void` `createSignatureRectangle(PDSignatureField signatureField, PDVisibleSignDesigner properties)` Creates SignatureRectangle.
`void` `createTemplate(PDPage page)` Creates a PDDocument and adds the page parameter to it and keeps this as a template in the PDF template Structure.
`void` `createVisualSignature(PDDocument template)` just to create visible signature
`void` `createWidgetDictionary(PDSignatureField signatureField, PDResources holderFormResources)` adds Widget Dictionary
`PDFTemplateStructure` `getStructure()` Returns the PDF template Structure
`void` `injectAppearanceStreams(PDStream holderFormStream, PDStream innerFormStream, PDStream imageFormStream, COSName imageFormName, COSName imageName, COSName innerFormName, PDVisibleSignDesigner properties)` injects appearance streams
`void` `injectProcSetArray(PDFormXObject innerForm, PDPage page, PDResources innerFormResources, PDResources imageFormResources, PDResources holderFormResources, COSArray procSet)` Inject procSetArray
`void` `insertInnerFormToHolderResources(PDFormXObject innerForm, PDResources holderFormResources)` Insert given from as inner form.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### PDVisibleSigBuilder

    public PDVisibleSigBuilder()

Constructor, creates PDF template structure.

### Method Detail

#### createPage

    public void createPage(PDVisibleSignDesigner properties)

Description copied from interface: `PDFTemplateBuilder`
Creates specified size page.

Specified by:
  `createPage` in interface `PDFTemplateBuilder`
Parameters:
  `properties` - page properties

#### createTemplate

    public void createTemplate(PDPage page)
                        throws 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:
  `IOException` - if the document could not be created

#### createAcroForm

    public void createAcroForm(PDDocument template)

Description copied from interface: `PDFTemplateBuilder`
Creates Acro forms in the template.

Specified by:
  `createAcroForm` in interface `PDFTemplateBuilder`
Parameters:
  `template` - the document the acroform is added to

#### getStructure

    public PDFTemplateStructure getStructure()

Description copied from interface: `PDFTemplateBuilder`
Returns the PDF template Structure

Specified by:
  `getStructure` in interface `PDFTemplateBuilder`
Returns:
  PDF template Structure

#### createSignatureField

    public void createSignatureField(PDAcroForm acroForm)
                              throws 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:
  `IOException` - if the signature could not be created

#### createSignature

    public void createSignature(PDSignatureField pdSignatureField,
                                PDPage page,
                                String signerName)
                         throws 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:
  `IOException` - if the signature could not be created

#### createAcroFormDictionary

    public void createAcroFormDictionary(PDAcroForm acroForm,
                                         PDSignatureField signatureField)
                                  throws 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:
  `IOException` - if the signature field could not be added

#### createSignatureRectangle

    public void createSignatureRectangle(PDSignatureField signatureField,
                                         PDVisibleSignDesigner properties)
                                  throws 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:
  `IOException` - if the rectangle could not be created

#### createAffineTransform

    public void createAffineTransform(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

#### createProcSetArray

    public void createProcSetArray()

Description copied from interface: `PDFTemplateBuilder`
Creates procSetArray of PDF,Text,ImageB,ImageC,ImageI.

Specified by:
  `createProcSetArray` in interface `PDFTemplateBuilder`

#### createSignatureImage

    public void createSignatureImage(PDDocument template,
                                     BufferedImage image)
                              throws 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:
  `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

#### createHolderFormStream

    public void createHolderFormStream(PDDocument template)

Description copied from interface: `PDFTemplateBuilder`
Create a holder for the form stream.

Specified by:
  `createHolderFormStream` in interface `PDFTemplateBuilder`
Parameters:
  `template` - the document to be used to create the new stream

#### createHolderFormResources

    public void createHolderFormResources()

Description copied from interface: `PDFTemplateBuilder`
Creates resources of form

Specified by:
  `createHolderFormResources` in interface `PDFTemplateBuilder`

#### 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 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:
  `IOException` - if the appearance stream could not be created

#### createInnerFormStream

    public void createInnerFormStream(PDDocument template)

Description copied from interface: `PDFTemplateBuilder`
Create a holder for the inner form stream.

Specified by:
  `createInnerFormStream` in interface `PDFTemplateBuilder`
Parameters:
  `template` - the document to be used to create the new stream

#### createInnerFormResource

    public void createInnerFormResource()

Description copied from interface: `PDFTemplateBuilder`
Creates InnerForm

Specified by:
  `createInnerFormResource` in interface `PDFTemplateBuilder`

#### 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

#### insertInnerFormToHolderResources

    public void insertInnerFormToHolderResources(PDFormXObject innerForm,
                                                 PDResources holderFormResources)

Description copied from interface: `PDFTemplateBuilder`
Insert given from as inner form.

Specified by:
  `insertInnerFormToHolderResources` in interface `PDFTemplateBuilder`
Parameters:
  `innerForm` - the form object to be inserted
  `holderFormResources` - resources the form object is added to

#### createImageFormStream

    public void createImageFormStream(PDDocument template)

Description copied from interface: `PDFTemplateBuilder`
Create image form stream.

Specified by:
  `createImageFormStream` in interface `PDFTemplateBuilder`
Parameters:
  `template` - the document to be used to create the new stream

#### createImageFormResources

    public void createImageFormResources()

Description copied from interface: `PDFTemplateBuilder`
Create resource of image form

Specified by:
  `createImageFormResources` in interface `PDFTemplateBuilder`

#### createImageForm

    public void createImageForm(PDResources imageFormResources,
                                PDResources innerFormResource,
                                PDStream imageFormStream,
                                PDRectangle bbox,
                                AffineTransform at,
                                PDImageXObject img)
                         throws 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:
  `IOException` - if the form object could not be created

#### createBackgroundLayerForm

    public void createBackgroundLayerForm(PDResources innerFormResource,
                                          PDRectangle bbox)
                                   throws 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:
  `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 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:
  `IOException` - if the appearance stream could not be created

#### appendRawCommands

    public void appendRawCommands(OutputStream os,
                                  String commands)
                           throws IOException

Throws:
  `IOException`

#### createVisualSignature

    public void createVisualSignature(PDDocument template)

Description copied from interface: `PDFTemplateBuilder`
just to create visible signature

Specified by:
  `createVisualSignature` in interface `PDFTemplateBuilder`
Parameters:
  `template` - the document holding the visible signature

#### createWidgetDictionary

    public void createWidgetDictionary(PDSignatureField signatureField,
                                       PDResources holderFormResources)
                                throws 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:
  `IOException` - if the widget dictionary could not be created

#### closeTemplate

    public void closeTemplate(PDDocument template)
                       throws IOException

Description copied from interface: `PDFTemplateBuilder`
Closes template

Specified by:
  `closeTemplate` in interface `PDFTemplateBuilder`
Parameters:
  `template` - the document to be closed
Throws:
  `IOException` - if the document could not be closed