Class AbstractITextSignatureDrawer

java.lang.Object
eu.europa.esig.dss.pdf.openpdf.visible.AbstractITextSignatureDrawer
All Implemented Interfaces:
ITextSignatureDrawer, SignatureDrawer, SignatureFieldBoxBuilder
Direct Known Subclasses:
ImageOnlySignatureDrawer, TextOnlySignatureDrawer

public abstract class AbstractITextSignatureDrawer extends Object implements ITextSignatureDrawer, SignatureFieldBoxBuilder
The abstract implementation of an IText (OpenPDF) signature drawer
  • Field Details

    • parameters

      protected SignatureImageParameters parameters
      Visual signature parameters
    • appearance

      protected com.lowagie.text.pdf.PdfSignatureAppearance appearance
      The visual signature appearance
  • Constructor Details

    • AbstractITextSignatureDrawer

      protected AbstractITextSignatureDrawer()
      Default constructor instantiating object with null values
  • Method Details

    • init

      public void init(SignatureImageParameters parameters, com.lowagie.text.pdf.PdfReader reader, com.lowagie.text.pdf.PdfSignatureAppearance appearance)
      Description copied from interface: ITextSignatureDrawer
      Initializes the drawer
      Specified by:
      init in interface ITextSignatureDrawer
      Parameters:
      parameters - SignatureImageParameters
      reader - PdfReader
      appearance - PdfSignatureAppearance
    • buildSignatureFieldBox

      public SignatureFieldDimensionAndPosition buildSignatureFieldBox()
      Builds a signature field dimension and position object
      Specified by:
      buildSignatureFieldBox in interface SignatureFieldBoxBuilder
      Returns:
      SignatureFieldDimensionAndPosition
    • getDSSFontMetrics

      protected abstract DSSFontMetrics getDSSFontMetrics()
      Returns the associated with the drawer font metrics
      Returns:
      DSSFontMetrics
    • getPageAnnotationBox

      protected AnnotationBox getPageAnnotationBox()
      Returns the page's box
      Returns:
      AnnotationBox
    • getPageRotation

      protected int getPageRotation()
      Returns the page's rotation where the signature field will be placed in
      Returns:
      rotation degree
    • toAnnotationBox

      protected AnnotationBox toAnnotationBox(SignatureFieldDimensionAndPosition dimensionAndPosition)
      Transforms the given dimensionAndPosition to a AnnotationBox according to the given page size
      Parameters:
      dimensionAndPosition - SignatureFieldDimensionAndPosition
      Returns:
      AnnotationBox
    • checkColorSpace

      protected void checkColorSpace(com.lowagie.text.pdf.PdfReader reader)
      Method to check if the target image's color space is present in the document's catalog
      Parameters:
      reader - PdfReader to check color profiles in
    • getExpectedColorSpaceName

      protected abstract com.lowagie.text.pdf.PdfName getExpectedColorSpaceName()
      Returns color space name for the provided image
      Returns:
      PdfName color space name
    • addColorSpace

      protected void addColorSpace(com.lowagie.text.pdf.PdfDictionary catalog, com.lowagie.text.pdf.PdfName colorSpaceName)
      This method is used to add a new required color space to a document
      Parameters:
      catalog - PdfDictionary from a PDF document to add a new color space into
      colorSpaceName - PdfName a color space name to add
    • getRotatedAnnotationRelativelyPageRotation

      protected AnnotationBox getRotatedAnnotationRelativelyPageRotation(AnnotationBox annotationBox)
      As OpenPDF does not automatically rotate the provided signature field relatively to the page's rotation, we need to rotate it manually
      Parameters:
      annotationBox - AnnotationBox to be rotated
      Returns:
      AnnotationBox
    • toITextRectangle

      protected com.lowagie.text.Rectangle toITextRectangle(AnnotationBox annotationBox)
      Transforms AnnotationBox to the com.lowagie.text.Rectangle
      Parameters:
      annotationBox - AnnotationBox
      Returns:
      Rectangle
    • getFinalRotation

      protected int getFinalRotation(int globalRotation, int pageRotation)
      Because OpenPDF does not rotate signature field automatically accordingly the page's rotation, we need to rotate manually
      Parameters:
      globalRotation - calculated global rotation
      pageRotation - page's rotation
      Returns:
      final rotation value