You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ja...@apache.org on 2014/03/13 09:00:13 UTC

svn commit: r1577056 - in /pdfbox/trunk: examples/src/main/java/org/apache/pdfbox/examples/signature/ pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/ pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignatu...

Author: jahewson
Date: Thu Mar 13 08:00:12 2014
New Revision: 1577056

URL: http://svn.apache.org/r1577056
Log:
PDFBOX-1847: enforce PDFBox coding conventions on existing code prior to patch

Modified:
    pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateVisibleSignature.java
    pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/ShowSignature.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDPropBuild.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDPropBuildDataDict.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSeedValue.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSeedValueMDP.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSeedValueTimeStamp.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSignature.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/SignatureInterface.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/SignatureOptions.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateBuilder.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateCreator.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateStructure.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSigBuilder.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSigProperties.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSignDesigner.java

Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateVisibleSignature.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateVisibleSignature.java?rev=1577056&r1=1577055&r2=1577056&view=diff
==============================================================================
--- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateVisibleSignature.java (original)
+++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateVisibleSignature.java Thu Mar 13 08:00:12 2014
@@ -49,8 +49,8 @@ import org.bouncycastle.jce.provider.Bou
 
 /**
  * This is an example for visual signing a pdf with bouncy castle.
- *
- * {@see org.apache.pdfbox.examples.signature.CreateSignature}
+
+ * {@see CreateSignature}
  * @author Vakhtang Koroghlishvili
  */
 public class CreateVisibleSignature implements SignatureInterface

Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/ShowSignature.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/ShowSignature.java?rev=1577056&r1=1577055&r2=1577056&view=diff
==============================================================================
--- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/ShowSignature.java (original)
+++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/ShowSignature.java Thu Mar 13 08:00:12 2014
@@ -19,6 +19,7 @@ package org.apache.pdfbox.examples.signa
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 
+import java.security.cert.CertificateException;
 import java.security.cert.CertificateFactory;
 
 import java.util.Collection;
@@ -29,22 +30,20 @@ import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.cos.COSString;
 
 import org.apache.pdfbox.pdmodel.PDDocument;
+import org.apache.pdfbox.pdmodel.encryption.InvalidPasswordException;
 
 /**
  * This will read a document from the filesystem, decrypt it and do something with the signature.
- *
  * usage: java org.apache.pdfbox.examples.signature.ShowSignature <password> <inputfile>
  *
- *
- * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
- * @version $Revision: 1.9 $
+ * @author Ben Litchfield
  */
 public class ShowSignature
 {
-
     private ShowSignature()
     {
     }
+
     /**
      * This is the entry point for the application.
      *
@@ -52,13 +51,13 @@ public class ShowSignature
      *
      * @throws Exception If there is an error reading the file.
      */
-    public static void main( String[] args ) throws Exception
+    public static void main( String[] args ) throws IOException, CertificateException
     {
         ShowSignature show = new ShowSignature();
         show.showSignature( args );
     }
 
-    private void showSignature( String[] args ) throws Exception
+    private void showSignature( String[] args ) throws IOException, CertificateException
     {
         if( args.length != 2 )
         {
@@ -156,5 +155,4 @@ public class ShowSignature
         System.err.println( "usage: java org.apache.pdfbox.examples.signature.ShowSignature " +
                             "<password> <inputfile>" );
     }
-
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDPropBuild.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDPropBuild.java?rev=1577056&r1=1577055&r2=1577056&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDPropBuild.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDPropBuild.java Thu Mar 13 08:00:12 2014
@@ -22,19 +22,16 @@ import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.pdmodel.common.COSObjectable;
 
 /**
- * <p>This represents a pdf signature build dictionary as specified in
- * <a href="http://partners.adobe.com/public/developer/en/acrobat/Acrobat_Signature_BuildDict.pdf">
- * http://partners.adobe.com/public/developer/en/acrobat/Acrobat_Signature_BuildDict.pdf</a></p>
+ * A signature build dictionary as specified in the PDF Signature Build Dictionary Specification.
+ * {@see http://partners.adobe.com/public/developer/en/acrobat/Acrobat_Signature_BuiladDict.pdf}
  *
- * <p>The signature build properties dictionary provides signature properties for the software
- * application that was used to create the signature.</p>
+ * The signature build properties dictionary provides signature properties for the software
+ * application that was used to create the signature.
  *
  * @author Thomas Chojecki
- * @version $Revision: 1.1 $
  */
 public class PDPropBuild implements COSObjectable
 {
-
     private COSDictionary dictionary;
 
     /**

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDPropBuildDataDict.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDPropBuildDataDict.java?rev=1577056&r1=1577055&r2=1577056&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDPropBuildDataDict.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDPropBuildDataDict.java Thu Mar 13 08:00:12 2014
@@ -22,15 +22,13 @@ import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.pdmodel.common.COSObjectable;
 
 /**
- * <p>This represents the general property dictionaries from the build property dictionary.</p>
+ * The general property dictionaries from the build property dictionary.
  *
  * @see PDPropBuild
  * @author Thomas Chojecki
- * @version $Revision: 1.1 $
  */
 public class PDPropBuildDataDict implements COSObjectable
 {
-
     private COSDictionary dictionary;
 
     /**

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSeedValue.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSeedValue.java?rev=1577056&r1=1577055&r2=1577056&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSeedValue.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSeedValue.java Thu Mar 13 08:00:12 2014
@@ -30,11 +30,9 @@ import org.apache.pdfbox.pdmodel.common.
  * This represents a pdf signature seed value dictionary.
  *
  * @author Thomas Chojecki
- * @version $Revision: 1.1 $
  */
 public class PDSeedValue implements COSObjectable
 {
-
     /**
      * A Ff flag.
      */

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSeedValueMDP.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSeedValueMDP.java?rev=1577056&r1=1577055&r2=1577056&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSeedValueMDP.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSeedValueMDP.java Thu Mar 13 08:00:12 2014
@@ -21,18 +21,13 @@ import org.apache.pdfbox.cos.COSDictiona
 import org.apache.pdfbox.cos.COSName;
 
 /**
- * <p>This MDP dictionary is a part of the seed value dictionary and define
- * if a author signature or a certification signature should be use.</p>
- *
- * <p>For more informations, consider the spare documented chapter in the seed
- * value dictionary in the ISO 32000 specification.</p>
+ * This MDP dictionary is a part of the seed value dictionary and define
+ * if a author signature or a certification signature should be use.
  *
  * @author Thomas Chojecki
- * @version $Revision: 1.1 $
  */
 public class PDSeedValueMDP
 {
-
     private COSDictionary dictionary;
 
     /**

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSeedValueTimeStamp.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSeedValueTimeStamp.java?rev=1577056&r1=1577055&r2=1577056&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSeedValueTimeStamp.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSeedValueTimeStamp.java Thu Mar 13 08:00:12 2014
@@ -21,15 +21,13 @@ import org.apache.pdfbox.cos.COSDictiona
 import org.apache.pdfbox.cos.COSName;
 
 /**
- * If exist, it describe where the signature handler can request a rfc3161
+ * If exist, it describe where the signature handler can request a RFC3161
  * timestamp and if it is a must have for the signature.
  *
  * @author Thomas Chojecki
- * @version $Revision: 1.1 $
  */
 public class PDSeedValueTimeStamp
 {
-
     private COSDictionary dictionary;
 
     /**

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSignature.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSignature.java?rev=1577056&r1=1577055&r2=1577056&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSignature.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSignature.java Thu Mar 13 08:00:12 2014
@@ -32,422 +32,419 @@ import org.apache.pdfbox.pdmodel.common.
 
 /**
  * This represents a digital signature that can be attached to a document.
- * 
- * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
+ *
+ * @author Ben Litchfield
  * @author Thomas Chojecki
- * @version $Revision: 1.2 $
  */
 public class PDSignature implements COSObjectable
 {
+    private COSDictionary dictionary;
 
-  private COSDictionary dictionary;
+    /**
+     * A signature filter value.
+     */
+    public static final COSName FILTER_ADOBE_PPKLITE = COSName.ADOBE_PPKLITE;
+
+    /**
+     * A signature filter value.
+     */
+    public static final COSName FILTER_ENTRUST_PPKEF = COSName.ENTRUST_PPKEF;
+
+    /**
+     * A signature filter value.
+     */
+    public static final COSName FILTER_CICI_SIGNIT = COSName.CICI_SIGNIT;
+
+    /**
+     * A signature filter value.
+     */
+    public static final COSName FILTER_VERISIGN_PPKVS = COSName.VERISIGN_PPKVS;
+
+    /**
+     * A signature subfilter value.
+     */
+    public static final COSName SUBFILTER_ADBE_X509_RSA_SHA1 = COSName.ADBE_X509_RSA_SHA1;
+
+    /**
+     * A signature subfilter value.
+     */
+    public static final COSName SUBFILTER_ADBE_PKCS7_DETACHED = COSName.ADBE_PKCS7_DETACHED;
+
+    /**
+     * A signature subfilter value.
+     */
+    public static final COSName SUBFILTER_ETSI_CADES_DETACHED = COSName.getPDFName("ETSI.CAdES.detached");
+
+    /**
+     * A signature subfilter value.
+     */
+    public static final COSName SUBFILTER_ADBE_PKCS7_SHA1 = COSName.ADBE_PKCS7_SHA1;
+
+    /**
+     * Default constructor.
+     */
+    public PDSignature()
+    {
+        dictionary = new COSDictionary();
+        dictionary.setItem(COSName.TYPE, COSName.SIG);
+    }
 
-  /**
-   * A signature filter value.
-   */
-  public static final COSName FILTER_ADOBE_PPKLITE = COSName.ADOBE_PPKLITE;
-
-  /**
-   * A signature filter value.
-   */
-  public static final COSName FILTER_ENTRUST_PPKEF = COSName.ENTRUST_PPKEF;
-
-  /**
-   * A signature filter value.
-   */
-  public static final COSName FILTER_CICI_SIGNIT = COSName.CICI_SIGNIT;
-
-  /**
-   * A signature filter value.
-   */
-  public static final COSName FILTER_VERISIGN_PPKVS = COSName.VERISIGN_PPKVS;
-
-  /**
-   * A signature subfilter value.
-   */
-  public static final COSName SUBFILTER_ADBE_X509_RSA_SHA1 = COSName.ADBE_X509_RSA_SHA1;
-
-  /**
-   * A signature subfilter value.
-   */
-  public static final COSName SUBFILTER_ADBE_PKCS7_DETACHED = COSName.ADBE_PKCS7_DETACHED;
-
-  /**
-   * A signature subfilter value.
-   */
-  public static final COSName SUBFILTER_ETSI_CADES_DETACHED = COSName.getPDFName("ETSI.CAdES.detached");
-
-  /**
-   * A signature subfilter value.
-   */
-  public static final COSName SUBFILTER_ADBE_PKCS7_SHA1 = COSName.ADBE_PKCS7_SHA1;
-
-  /**
-   * Default constructor.
-   */
-  public PDSignature()
-  {
-    dictionary = new COSDictionary();
-    dictionary.setItem(COSName.TYPE, COSName.SIG);
-  }
-
-  /**
-   * Constructor.
-   * 
-   * @param dict The signature dictionary.
-   */
-  public PDSignature(COSDictionary dict)
-  {
-    dictionary = dict;
-  }
-
-  /**
-   * Convert this standard java object to a COS object.
-   * 
-   * @return The cos object that matches this Java object.
-   */
-  public COSBase getCOSObject()
-  {
-    return getDictionary();
-  }
-
-  /**
-   * Convert this standard java object to a COS dictionary.
-   * 
-   * @return The COS dictionary that matches this Java object.
-   */
-  public COSDictionary getDictionary()
-  {
-    return dictionary;
-  }
-
-  /**
-   * Set the dictionary type.
-   *
-   * @param type is the dictionary type.
-   */
-  public void setType(COSName type)
-  {
-    dictionary.setItem(COSName.TYPE, type);
-  }
-  
-  /**
-   * Set the filter.
-   * 
-   * @param filter the filter to be used
-   */
-  public void setFilter(COSName filter)
-  {
-    dictionary.setItem(COSName.FILTER, filter);
-  }
-
-  /**
-   * Set a subfilter that specify the signature that should be used. 
-   * 
-   * @param subfilter the subfilter that shall be used.
-   */
-  public void setSubFilter(COSName subfilter)
-  {
-    dictionary.setItem(COSName.SUBFILTER, subfilter);
-  }
-
-  /**
-   * Sets the name.
-   * @param name the name to be used
-   */
-  public void setName(String name)
-  {
-    dictionary.setString(COSName.NAME, name);
-  }
-
-  /**
-   * Sets the location.
-   * @param location the location to be used
-   */
-  public void setLocation(String location)
-  {
-    dictionary.setString(COSName.LOCATION, location);
-  }
-
-  /**
-   * Sets the reason.
-   * 
-   * @param reason the reason to be used
-   */
-  public void setReason(String reason)
-  {
-    dictionary.setString(COSName.REASON, reason);
-  }
-
-  /**
-   * Sets the contact info.
-   * 
-   * @param contactInfo the contact info to be used
-   */
-  public void setContactInfo(String contactInfo)
-  {
-    dictionary.setString(COSName.CONTACT_INFO, contactInfo);
-  }
-
-  /**
-   * Set the sign date.
-   * 
-   * @param cal the date to be used as sign date
-   */
-  public void setSignDate(Calendar cal)
-  {
-    dictionary.setDate(COSName.M, cal);
-  }
-
-  /**
-   * Returns the filter.
-   * @return the filter
-   */
-  public String getFilter()
-  {
-    return dictionary.getNameAsString(COSName.FILTER);
-  }
-
-  /**
-   * Returns the subfilter.
-   * 
-   * @return the subfilter
-   */
-  public String getSubFilter()
-  {
-    return dictionary.getNameAsString(COSName.SUBFILTER);
-  }
-
-  /**
-   * Returns the name.
-   * 
-   * @return the name
-   */
-  public String getName()
-  {
-    return dictionary.getString(COSName.NAME);
-  }
-
-  /**
-   * Returns the location.
-   * 
-   * @return the location
-   */
-  public String getLocation()
-  {
-    return dictionary.getString(COSName.LOCATION);
-  }
-
-  /**
-   * Returns the reason.
-   * 
-   * @return the reason
-   */
-  public String getReason()
-  {
-    return dictionary.getString(COSName.REASON);
-  }
-
-  /**
-   * Returns the contact info.
-   * 
-   * @return teh contact info
-   */
-  public String getContactInfo()
-  {
-    return dictionary.getString(COSName.CONTACT_INFO);
-  }
-
-  /**
-   * Returns the sign date.
-   * 
-   * @return the sign date
-   */
-  public Calendar getSignDate()
-  {
-    return dictionary.getDate(COSName.M);
-  }
-
-  /**
-   * Sets the byte range.
-   * 
-   * @param range the byte range to be used
-   */
-  public void setByteRange(int[] range) 
-  {
-    if (range.length!=4)
-    {
-      return;
-    }
-    COSArray ary = new COSArray();
-    for ( int i : range )
-    {
-      ary.add(COSInteger.get(i));
-    }
-    
-    dictionary.setItem(COSName.BYTERANGE, ary);
-  }
-
-  /**
-   * Read out the byterange from the file.
-   * 
-   * @return a integer array with the byterange
-   */
-  public int[] getByteRange()
-  {
-    COSArray byteRange = (COSArray)dictionary.getDictionaryObject(COSName.BYTERANGE);
-    int[] ary = new int[byteRange.size()];
-    for (int i = 0; i<ary.length;++i)
-    {
-      ary[i] = byteRange.getInt(i);
-    }
-    return ary;
-  }
-  
-  /**
-   * Will return the embedded signature between the byterange gap.
-   * 
-   * @param pdfFile The signed pdf file as InputStream
-   * @return a byte array containing the signature
-   * @throws IOException if the pdfFile can't be read
-   */
-  public byte[] getContents(InputStream pdfFile) throws IOException
-  {
-    int[] byteRange = getByteRange();
-    int begin = byteRange[0]+byteRange[1]+1;
-    int end = byteRange[2]-begin;
-    
-    return getContents(new COSFilterInputStream(pdfFile,new int[] {begin,end}));
-  }
-  
-  /**
-   * Will return the embedded signature between the byterange gap.
-   * 
-   * @param pdfFile The signed pdf file as byte array
-   * @return a byte array containing the signature
-   * @throws IOException if the pdfFile can't be read
-   */
-  public byte[] getContents(byte[] pdfFile) throws IOException
-  {
-    int[] byteRange = getByteRange();
-    int begin = byteRange[0]+byteRange[1]+1;
-    int end = byteRange[2]-begin;
-    
-    return getContents(new COSFilterInputStream(pdfFile,new int[] {begin,end}));
-  }
-
-  private byte[] getContents(COSFilterInputStream fis) throws IOException 
-  {
-    ByteArrayOutputStream byteOS = new ByteArrayOutputStream(1024);
-    byte[] buffer = new byte[1024];
-    int c;
-    while ((c = fis.read(buffer)) != -1)
-    {
-      // Filter < and (
-      if(buffer[0]==0x3C || buffer[0]==0x28)
-      {
-        byteOS.write(buffer, 1, c);
-      }
-      // Filter > and )
-      else if(buffer[c-1]==0x3E || buffer[c-1]==0x29)
-      {
-        byteOS.write(buffer, 0, c-1);
-      }
-      else
-      {
-        byteOS.write(buffer, 0, c);
-      }
-    }
-    fis.close();
-    
-    return COSString.createFromHexString(byteOS.toString()).getBytes();
-  }
-  
-  /**
-   * Sets the contents.
-   * 
-   * @param bytes contents to be used
-   */
-  public void setContents(byte[] bytes)
-  {
-    COSString string = new COSString(bytes);
-    string.setForceHexForm(true);
-    dictionary.setItem(COSName.CONTENTS, string);
-  }
-  
-  /**
-   * Will return the signed content of the document.
-   * 
-   * @param pdfFile The signed pdf file as InputStream
-   * @return a byte array containing only the signed part of the content
-   * @throws IOException if the pdfFile can't be read
-   */
-  public byte[] getSignedContent(InputStream pdfFile) throws IOException
-  {
-      COSFilterInputStream fis=null;
-      
-      try 
-      {
-          fis = new COSFilterInputStream(pdfFile,getByteRange());
-          return fis.toByteArray();
-      }
-      finally
-      {
-          if (fis != null)
-          {
-              fis.close();
-          }
-      }
-  }
-  
-  /**
-   * Will return the signed content of the document.
-   * 
-   * @param pdfFile The signed pdf file as byte array
-   * @return a byte array containing only the signed part of the content
-   * @throws IOException if the pdfFile can't be read
-   */
-  public byte[] getSignedContent(byte[] pdfFile) throws IOException
-  {
-      COSFilterInputStream fis=null;
-      try 
-      {
-          fis = new COSFilterInputStream(pdfFile,getByteRange());
-          return fis.toByteArray();
-      } 
-      finally 
-      {
-          if (fis != null)
-          {
-              fis.close();
-          }
-      }
-  }
-
-  /**
-   * PDF signature build dictionary. Provides informations about the signature handler.
-   *
-   * @return the pdf signature build dictionary.
-   */
-  public PDPropBuild getPropBuild()
-  {
-      PDPropBuild propBuild = null;
-      COSDictionary propBuildDic = (COSDictionary)dictionary.getDictionaryObject(COSName.PROP_BUILD);
-      if (propBuildDic != null)
-      {
-          propBuild = new PDPropBuild(propBuildDic);
-      }
-      return propBuild;
-  }
-
-  /**
-   * PDF signature build dictionary. Provides informations about the signature handler.
-   *
-   * @param propBuild the prop build
-   */
-      public void setPropBuild(PDPropBuild propBuild)
-  {
-    dictionary.setItem(COSName.PROP_BUILD, propBuild);
-  }
-}
+    /**
+     * Constructor.
+     *
+     * @param dict The signature dictionary.
+     */
+    public PDSignature(COSDictionary dict)
+    {
+        dictionary = dict;
+    }
+
+    /**
+     * Convert this standard java object to a COS object.
+     *
+     * @return The cos object that matches this Java object.
+     */
+    public COSBase getCOSObject()
+    {
+        return getDictionary();
+    }
+
+    /**
+     * Convert this standard java object to a COS dictionary.
+     *
+     * @return The COS dictionary that matches this Java object.
+     */
+    public COSDictionary getDictionary()
+    {
+        return dictionary;
+    }
+
+    /**
+     * Set the dictionary type.
+     *
+     * @param type is the dictionary type.
+     */
+    public void setType(COSName type)
+    {
+        dictionary.setItem(COSName.TYPE, type);
+    }
+
+    /**
+     * Set the filter.
+     *
+     * @param filter the filter to be used
+     */
+    public void setFilter(COSName filter)
+    {
+        dictionary.setItem(COSName.FILTER, filter);
+    }
+
+    /**
+     * Set a subfilter that specify the signature that should be used.
+     *
+     * @param subfilter the subfilter that shall be used.
+     */
+    public void setSubFilter(COSName subfilter)
+    {
+        dictionary.setItem(COSName.SUBFILTER, subfilter);
+    }
+
+    /**
+     * Sets the name.
+     * @param name the name to be used
+     */
+    public void setName(String name)
+    {
+        dictionary.setString(COSName.NAME, name);
+    }
 
+    /**
+     * Sets the location.
+     * @param location the location to be used
+     */
+    public void setLocation(String location)
+    {
+        dictionary.setString(COSName.LOCATION, location);
+    }
+
+    /**
+     * Sets the reason.
+     *
+     * @param reason the reason to be used
+     */
+    public void setReason(String reason)
+    {
+        dictionary.setString(COSName.REASON, reason);
+    }
+
+    /**
+     * Sets the contact info.
+     *
+     * @param contactInfo the contact info to be used
+     */
+    public void setContactInfo(String contactInfo)
+    {
+        dictionary.setString(COSName.CONTACT_INFO, contactInfo);
+    }
+
+    /**
+     * Set the sign date.
+     *
+     * @param cal the date to be used as sign date
+     */
+    public void setSignDate(Calendar cal)
+    {
+        dictionary.setDate(COSName.M, cal);
+    }
+
+    /**
+     * Returns the filter.
+     * @return the filter
+     */
+    public String getFilter()
+    {
+        return dictionary.getNameAsString(COSName.FILTER);
+    }
+
+    /**
+     * Returns the subfilter.
+     *
+     * @return the subfilter
+     */
+    public String getSubFilter()
+    {
+        return dictionary.getNameAsString(COSName.SUBFILTER);
+    }
+
+    /**
+     * Returns the name.
+     *
+     * @return the name
+     */
+    public String getName()
+    {
+        return dictionary.getString(COSName.NAME);
+    }
+
+    /**
+     * Returns the location.
+     *
+     * @return the location
+     */
+    public String getLocation()
+    {
+        return dictionary.getString(COSName.LOCATION);
+    }
+
+    /**
+     * Returns the reason.
+     *
+     * @return the reason
+     */
+    public String getReason()
+    {
+        return dictionary.getString(COSName.REASON);
+    }
+
+    /**
+     * Returns the contact info.
+     *
+     * @return teh contact info
+     */
+    public String getContactInfo()
+    {
+        return dictionary.getString(COSName.CONTACT_INFO);
+    }
+
+    /**
+     * Returns the sign date.
+     *
+     * @return the sign date
+     */
+    public Calendar getSignDate()
+    {
+        return dictionary.getDate(COSName.M);
+    }
+
+    /**
+     * Sets the byte range.
+     *
+     * @param range the byte range to be used
+     */
+    public void setByteRange(int[] range)
+    {
+        if (range.length!=4)
+        {
+            return;
+        }
+        COSArray ary = new COSArray();
+        for ( int i : range )
+        {
+            ary.add(COSInteger.get(i));
+        }
+
+        dictionary.setItem(COSName.BYTERANGE, ary);
+    }
+
+    /**
+     * Read out the byterange from the file.
+     *
+     * @return a integer array with the byterange
+     */
+    public int[] getByteRange()
+    {
+        COSArray byteRange = (COSArray)dictionary.getDictionaryObject(COSName.BYTERANGE);
+        int[] ary = new int[byteRange.size()];
+        for (int i = 0; i<ary.length;++i)
+        {
+            ary[i] = byteRange.getInt(i);
+        }
+        return ary;
+    }
+
+    /**
+     * Will return the embedded signature between the byterange gap.
+     *
+     * @param pdfFile The signed pdf file as InputStream
+     * @return a byte array containing the signature
+     * @throws IOException if the pdfFile can't be read
+     */
+    public byte[] getContents(InputStream pdfFile) throws IOException
+    {
+        int[] byteRange = getByteRange();
+        int begin = byteRange[0]+byteRange[1]+1;
+        int end = byteRange[2]-begin;
+
+        return getContents(new COSFilterInputStream(pdfFile,new int[] {begin,end}));
+    }
+
+    /**
+     * Will return the embedded signature between the byterange gap.
+     *
+     * @param pdfFile The signed pdf file as byte array
+     * @return a byte array containing the signature
+     * @throws IOException if the pdfFile can't be read
+     */
+    public byte[] getContents(byte[] pdfFile) throws IOException
+    {
+        int[] byteRange = getByteRange();
+        int begin = byteRange[0]+byteRange[1]+1;
+        int end = byteRange[2]-begin;
+
+        return getContents(new COSFilterInputStream(pdfFile,new int[] {begin,end}));
+    }
+
+    private byte[] getContents(COSFilterInputStream fis) throws IOException
+    {
+        ByteArrayOutputStream byteOS = new ByteArrayOutputStream(1024);
+        byte[] buffer = new byte[1024];
+        int c;
+        while ((c = fis.read(buffer)) != -1)
+        {
+            // Filter < and (
+            if(buffer[0]==0x3C || buffer[0]==0x28)
+            {
+                byteOS.write(buffer, 1, c);
+            }
+            // Filter > and )
+            else if(buffer[c-1]==0x3E || buffer[c-1]==0x29)
+            {
+                byteOS.write(buffer, 0, c-1);
+            }
+            else
+            {
+                byteOS.write(buffer, 0, c);
+            }
+        }
+        fis.close();
+
+        return COSString.createFromHexString(byteOS.toString()).getBytes();
+    }
+
+    /**
+     * Sets the contents.
+     *
+     * @param bytes contents to be used
+     */
+    public void setContents(byte[] bytes)
+    {
+        COSString string = new COSString(bytes);
+        string.setForceHexForm(true);
+        dictionary.setItem(COSName.CONTENTS, string);
+    }
+
+    /**
+     * Will return the signed content of the document.
+     *
+     * @param pdfFile The signed pdf file as InputStream
+     * @return a byte array containing only the signed part of the content
+     * @throws IOException if the pdfFile can't be read
+     */
+    public byte[] getSignedContent(InputStream pdfFile) throws IOException
+    {
+        COSFilterInputStream fis=null;
+
+        try
+        {
+            fis = new COSFilterInputStream(pdfFile,getByteRange());
+            return fis.toByteArray();
+        }
+        finally
+        {
+            if (fis != null)
+            {
+                fis.close();
+            }
+        }
+    }
+
+    /**
+     * Will return the signed content of the document.
+     *
+     * @param pdfFile The signed pdf file as byte array
+     * @return a byte array containing only the signed part of the content
+     * @throws IOException if the pdfFile can't be read
+     */
+    public byte[] getSignedContent(byte[] pdfFile) throws IOException
+    {
+        COSFilterInputStream fis=null;
+        try
+        {
+            fis = new COSFilterInputStream(pdfFile,getByteRange());
+            return fis.toByteArray();
+        }
+        finally
+        {
+            if (fis != null)
+            {
+                fis.close();
+            }
+        }
+    }
+
+    /**
+     * PDF signature build dictionary. Provides informations about the signature handler.
+     *
+     * @return the pdf signature build dictionary.
+     */
+    public PDPropBuild getPropBuild()
+    {
+        PDPropBuild propBuild = null;
+        COSDictionary propBuildDic = (COSDictionary)dictionary.getDictionaryObject(COSName.PROP_BUILD);
+        if (propBuildDic != null)
+        {
+            propBuild = new PDPropBuild(propBuildDic);
+        }
+        return propBuild;
+    }
+
+    /**
+     * PDF signature build dictionary. Provides informations about the signature handler.
+     *
+     * @param propBuild the prop build
+     */
+    public void setPropBuild(PDPropBuild propBuild)
+    {
+        dictionary.setItem(COSName.PROP_BUILD, propBuild);
+    }
+}

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/SignatureInterface.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/SignatureInterface.java?rev=1577056&r1=1577055&r2=1577056&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/SignatureInterface.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/SignatureInterface.java Thu Mar 13 08:00:12 2014
@@ -20,18 +20,17 @@ import java.io.IOException;
 import java.io.InputStream;
 
 /**
- * Providing an interface for accessing necessary functions for signing a pdf document.
- * 
- * @author <a href="mailto:mail@thomas-chojecki.de">Thomas Chojecki</a>
+ * Providing an interface for accessing necessary functions for signing a PDF document.
+ *
+ * @author Thomas Chojecki
  */
 public interface SignatureInterface
 {
-  /**
-   * Creates a cms signature for the given content
-   *
-   * @param content is the content as a (Filter)InputStream
-   * @return signature as a byte array
-   */
-  public byte[] sign (InputStream content) throws IOException;
-
+    /**
+     * Creates a cms signature for the given content
+     *
+     * @param content is the content as a (Filter)InputStream
+     * @return signature as a byte array
+     */
+    public byte[] sign (InputStream content) throws IOException;
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/SignatureOptions.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/SignatureOptions.java?rev=1577056&r1=1577055&r2=1577056&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/SignatureOptions.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/SignatureOptions.java Thu Mar 13 08:00:12 2014
@@ -23,20 +23,19 @@ import org.apache.pdfbox.cos.COSDocument
 import org.apache.pdfbox.pdfparser.VisualSignatureParser;
 import org.apache.pdfbox.pdmodel.interactive.digitalsignature.visible.PDVisibleSigProperties;
 
-
+/**
+ * TODO description needed
+ */
 public class SignatureOptions
 {
     private COSDocument visualSignature;
-
     private int preferedSignatureSize;
-    
     private int pageNo;
   
     /**
      * Set the page number.
      * 
      * @param pageNo the page number
-     * 
      */
     public void setPage(int pageNo)
     {
@@ -73,8 +72,6 @@ public class SignatureOptions
      * @param visSignatureProperties the <code>PDVisibleSigProperties</code> object containing the visual signature
      * 
      * @throws IOException when something went wrong during parsing
-     * 
-     * @since 1.8.3
      */
     public void setVisualSignature(PDVisibleSigProperties visSignatureProperties) throws IOException
     { 

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateBuilder.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateBuilder.java?rev=1577056&r1=1577055&r2=1577056&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateBuilder.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateBuilder.java Thu Mar 13 08:00:12 2014
@@ -32,15 +32,13 @@ import org.apache.pdfbox.pdmodel.interac
 import org.apache.pdfbox.pdmodel.interactive.form.PDSignatureField;
 
 /**
- * That class builds visible signature template
- * which will be added in our pdf document
- * @author Vakhtang koroghlishvili (Gogebashvili)
- *
+ * That class builds visible signature template which will be added in our PDF document.
+ * @author Vakhtang Koroghlishvili
  */
-public interface PDFTemplateBuilder {
-
+public interface PDFTemplateBuilder
+{
     /**
-     * In order to create  Affine Transform, using parameters
+     * In order to create Affine Transform, using parameters
      * @param params
      */
 	public void createAffineTransform(byte [] params);
@@ -78,7 +76,8 @@ public interface PDFTemplateBuilder {
 	 * @param signatureName
 	 * @throws IOException
 	 */
-	public void createSignature(PDSignatureField pdSignatureField, PDPage page, String signatureName) throws IOException;
+	public void createSignature(PDSignatureField pdSignatureField, PDPage page,
+                                String signatureName) throws IOException;
 	
 	/**
 	 * Create AcroForm Dictionary
@@ -86,7 +85,8 @@ public interface PDFTemplateBuilder {
 	 * @param signatureField
 	 * @throws IOException
 	 */
-	public void createAcroFormDictionary(PDAcroForm acroForm, PDSignatureField signatureField) throws IOException;
+	public void createAcroFormDictionary(PDAcroForm acroForm,
+                                         PDSignatureField signatureField) throws IOException;
 	
 	/**
 	 * Creates SingatureRectangle
@@ -94,7 +94,8 @@ public interface PDFTemplateBuilder {
 	 * @param properties
 	 * @throws IOException
 	 */
-	public void createSignatureRectangle(PDSignatureField signatureField, PDVisibleSignDesigner properties) throws IOException;
+	public void createSignatureRectangle(PDSignatureField signatureField,
+                                         PDVisibleSignDesigner properties) throws IOException;
 	
 	/**
 	 * Creates procSetArray of PDF,Text,ImageB,ImageC,ImageI    
@@ -132,7 +133,8 @@ public interface PDFTemplateBuilder {
 	 * @param holderFormStream
 	 * @param formrect
 	 */
-	public void createHolderForm(PDResources holderFormResources, PDStream holderFormStream, PDRectangle formrect);
+	public void createHolderForm(PDResources holderFormResources, PDStream holderFormStream,
+                                 PDRectangle formrect);
 	
 	/**
 	 * Creates appearance dictionary
@@ -140,7 +142,8 @@ public interface PDFTemplateBuilder {
 	 * @param signatureField
 	 * @throws IOException
 	 */
-	public void createAppearanceDictionary(PDFormXObject holderForml, PDSignatureField signatureField) throws IOException;
+	public void createAppearanceDictionary(PDFormXObject holderForml,
+                                           PDSignatureField signatureField) throws IOException;
 	
 	/**
 	 * 
@@ -160,15 +163,16 @@ public interface PDFTemplateBuilder {
 	 * @param innerFormStream
 	 * @param formrect
 	 */
-	public void createInnerForm(PDResources innerFormResources, PDStream innerFormStream, PDRectangle formrect);
-	
+	public void createInnerForm(PDResources innerFormResources, PDStream innerFormStream,
+                                PDRectangle formrect);
 	
 	/**
 	 * 
 	 * @param innerForm
 	 * @param holderFormResources
 	 */
-	public void insertInnerFormToHolerResources(PDFormXObject innerForm, PDResources holderFormResources);
+	public void insertInnerFormToHolerResources(PDFormXObject innerForm,
+                                                PDResources holderFormResources);
 	
 	/**
 	 * 
@@ -191,8 +195,10 @@ public interface PDFTemplateBuilder {
 	 * @param img
 	 * @throws IOException
 	 */
-	public void createImageForm(PDResources imageFormResources, PDResources innerFormResource, PDStream imageFormStream, PDRectangle formrect,
-			AffineTransform affineTransform, PDImageXObject img) throws IOException;
+	public void createImageForm(PDResources imageFormResources, PDResources innerFormResource,
+                                PDStream imageFormStream, PDRectangle formrect,
+                                AffineTransform affineTransform, PDImageXObject img)
+                                throws IOException;
 	
 	/**
 	 * Inject procSetArray 
@@ -203,8 +209,9 @@ public interface PDFTemplateBuilder {
 	 * @param holderFormResources
 	 * @param procSet
 	 */
-	public void injectProcSetArray(PDFormXObject innerForm, PDPage page, PDResources innerFormResources, PDResources imageFormResources,
-			PDResources holderFormResources, COSArray procSet);
+	public void injectProcSetArray(PDFormXObject innerForm, PDPage page,
+                                   PDResources innerFormResources, PDResources imageFormResources,
+                                   PDResources holderFormResources, COSArray procSet);
 	
 	/**
 	 * injects appearance streams
@@ -217,8 +224,10 @@ public interface PDFTemplateBuilder {
 	 * @param properties
 	 * @throws IOException
 	 */
-	public void injectAppearanceStreams(PDStream holderFormStream, PDStream innterFormStream, PDStream imageFormStream, String imageObjectName,
-			String imageName, String innerFormName, PDVisibleSignDesigner properties) throws IOException;
+	public void injectAppearanceStreams(PDStream holderFormStream, PDStream innterFormStream,
+                                        PDStream imageFormStream, String imageObjectName,
+                                        String imageName, String innerFormName,
+                                        PDVisibleSignDesigner properties) throws IOException;
 	
 	/**
 	 * just to create visible signature
@@ -232,7 +241,8 @@ public interface PDFTemplateBuilder {
 	 * @param holderFormResources
 	 * @throws IOException
 	 */
-	public void createWidgetDictionary(PDSignatureField signatureField, PDResources holderFormResources) throws IOException;
+	public void createWidgetDictionary(PDSignatureField signatureField,
+                                       PDResources holderFormResources) throws IOException;
 	
 	/**
 	 * 

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateCreator.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateCreator.java?rev=1577056&r1=1577055&r2=1577056&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateCreator.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateCreator.java Thu Mar 13 08:00:12 2014
@@ -33,12 +33,11 @@ import org.apache.pdfbox.pdmodel.interac
 import org.apache.pdfbox.pdmodel.interactive.form.PDSignatureField;
 
 /**
- * Using that class, we  build pdf template
- * @author <a href="mailto:vakhtang.koroghlishvili@gmail.com"> vakhtang koroghlishvili (gogebashvili) </a>
+ * Using that class, we build pdf template.
+ * @author Vakhtang Koroghlishvili
  */
 public class PDFTemplateCreator
 {
-
     PDFTemplateBuilder pdfBuilder;
     private static final Log logger = LogFactory.getLog(PDFTemplateCreator.class);
 
@@ -49,17 +48,17 @@ public class PDFTemplateCreator
      */
     public PDFTemplateCreator(PDFTemplateBuilder bookBuilder)
     {
-        this.pdfBuilder = bookBuilder;
+        pdfBuilder = bookBuilder;
     }
 
     /**
-     * that method returns object of PDFStructur
+     * that method returns object of PDFStructure
      * 
      * @return PDFStructure
      */
     public PDFTemplateStructure getPdfStructure()
     {
-        return this.pdfBuilder.getStructure();
+        return pdfBuilder.getStructure();
     }
 
     /**
@@ -74,81 +73,81 @@ public class PDFTemplateCreator
         PDFTemplateStructure pdfStructure = pdfBuilder.getStructure();
 
         // we create array of [Text, ImageB, ImageC, ImageI]
-        this.pdfBuilder.createProcSetArray();
+        pdfBuilder.createProcSetArray();
         
         //create page
-        this.pdfBuilder.createPage(properties);
+        pdfBuilder.createPage(properties);
         PDPage page = pdfStructure.getPage();
 
         //create template
-        this.pdfBuilder.createTemplate(page);
+        pdfBuilder.createTemplate(page);
         PDDocument template = pdfStructure.getTemplate();
         
         //create /AcroForm
-        this.pdfBuilder.createAcroForm(template);
+        pdfBuilder.createAcroForm(template);
         PDAcroForm acroForm = pdfStructure.getAcroForm();
 
         // AcroForm contains singature fields
-        this.pdfBuilder.createSignatureField(acroForm);
+        pdfBuilder.createSignatureField(acroForm);
         PDSignatureField pdSignatureField = pdfStructure.getSignatureField();
         
         // create signature
-        this.pdfBuilder.createSignature(pdSignatureField, page, properties.getSignatureFieldName());
+        pdfBuilder.createSignature(pdSignatureField, page, properties.getSignatureFieldName());
        
         // that is /AcroForm/DR entry
-        this.pdfBuilder.createAcroFormDictionary(acroForm, pdSignatureField);
+        pdfBuilder.createAcroFormDictionary(acroForm, pdSignatureField);
         
         // create AffineTransform
-        this.pdfBuilder.createAffineTransform(properties.getAffineTransformParams());
+        pdfBuilder.createAffineTransform(properties.getAffineTransformParams());
         AffineTransform transform = pdfStructure.getAffineTransform();
        
         // rectangle, formatter, image. /AcroForm/DR/XObject contains that form
-        this.pdfBuilder.createSignatureRectangle(pdSignatureField, properties);
-        this.pdfBuilder.createFormaterRectangle(properties.getFormaterRectangleParams());
+        pdfBuilder.createSignatureRectangle(pdSignatureField, properties);
+        pdfBuilder.createFormaterRectangle(properties.getFormaterRectangleParams());
         PDRectangle formater = pdfStructure.getFormaterRectangle();
-        this.pdfBuilder.createSignatureImage(template, properties.getImage());
+        pdfBuilder.createSignatureImage(template, properties.getImage());
 
         // create form stream, form and  resource. 
-        this.pdfBuilder.createHolderFormStream(template);
+        pdfBuilder.createHolderFormStream(template);
         PDStream holderFormStream = pdfStructure.getHolderFormStream();
-        this.pdfBuilder.createHolderFormResources();
+        pdfBuilder.createHolderFormResources();
         PDResources holderFormResources = pdfStructure.getHolderFormResources();
-        this.pdfBuilder.createHolderForm(holderFormResources, holderFormStream, formater);
+        pdfBuilder.createHolderForm(holderFormResources, holderFormStream, formater);
         
         // that is /AP entry the appearance dictionary.
-        this.pdfBuilder.createAppearanceDictionary(pdfStructure.getHolderForm(), pdSignatureField);
+        pdfBuilder.createAppearanceDictionary(pdfStructure.getHolderForm(), pdSignatureField);
         
-        // inner formstream, form and resource (hlder form containts inner form)
-        this.pdfBuilder.createInnerFormStream(template);
-        this.pdfBuilder.createInnerFormResource();
+        // inner form stream, form and resource (hlder form containts inner form)
+        pdfBuilder.createInnerFormStream(template);
+        pdfBuilder.createInnerFormResource();
         PDResources innerFormResource = pdfStructure.getInnerFormResources();
-        this.pdfBuilder.createInnerForm(innerFormResource, pdfStructure.getInnterFormStream(), formater);
+        pdfBuilder.createInnerForm(innerFormResource, pdfStructure.getInnterFormStream(), formater);
         PDFormXObject innerForm = pdfStructure.getInnerForm();
        
         // inner form must be in the holder form as we wrote
-        this.pdfBuilder.insertInnerFormToHolerResources(innerForm, holderFormResources);
+        pdfBuilder.insertInnerFormToHolerResources(innerForm, holderFormResources);
         
         //  Image form is in this structure: /AcroForm/DR/FRM0/Resources/XObject/n0
-        this.pdfBuilder.createImageFormStream(template);
+        pdfBuilder.createImageFormStream(template);
         PDStream imageFormStream = pdfStructure.getImageFormStream();
-        this.pdfBuilder.createImageFormResources();
+        pdfBuilder.createImageFormResources();
         PDResources imageFormResources = pdfStructure.getImageFormResources();
-        this.pdfBuilder.createImageForm(imageFormResources, innerFormResource, imageFormStream, formater, transform,
-                pdfStructure.getImage());
+        pdfBuilder.createImageForm(imageFormResources, innerFormResource, imageFormStream, formater,
+                transform, pdfStructure.getImage());
        
         // now inject procSetArray
-        this.pdfBuilder.injectProcSetArray(innerForm, page, innerFormResource, imageFormResources, holderFormResources,
-                pdfStructure.getProcSet());
+        pdfBuilder.injectProcSetArray(innerForm, page, innerFormResource, imageFormResources,
+                holderFormResources, pdfStructure.getProcSet());
 
         String imgFormName = pdfStructure.getImageFormName();
         String imgName = pdfStructure.getImageName();
         String innerFormName = pdfStructure.getInnerFormName();
 
         // now create Streams of AP
-        this.pdfBuilder.injectAppearanceStreams(holderFormStream, imageFormStream, imageFormStream, imgFormName,
-                imgName, innerFormName, properties);
-        this.pdfBuilder.createVisualSignature(template);
-        this.pdfBuilder.createWidgetDictionary(pdSignatureField, holderFormResources);
+        pdfBuilder.injectAppearanceStreams(holderFormStream, imageFormStream, imageFormStream,
+                imgFormName, imgName, innerFormName, properties);
+        pdfBuilder.createVisualSignature(template);
+        pdfBuilder.createWidgetDictionary(pdSignatureField, holderFormResources);
         
         ByteArrayInputStream in = pdfStructure.getTemplateAppearanceStream();
         logger.info("stream returning started, size= " + in.available());
@@ -158,6 +157,5 @@ public class PDFTemplateCreator
         
         // return result of the stream 
         return in;
-
     }
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateStructure.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateStructure.java?rev=1577056&r1=1577055&r2=1577056&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateStructure.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateStructure.java Thu Mar 13 08:00:12 2014
@@ -34,15 +34,15 @@ import org.apache.pdfbox.pdmodel.common.
 import org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject;
 import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary;
+import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature;
 import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm;
 import org.apache.pdfbox.pdmodel.interactive.form.PDField;
 import org.apache.pdfbox.pdmodel.interactive.form.PDSignatureField;
 
 /**
- * Structure of PDF document with visible signature
- * 
- * @author <a href="mailto:vakhtang.koroghlishvili@gmail.com"> vakhtang koroghlishvili (gogebashvili) </a>
+ * Structure of PDF document with visible signature.
  * 
+ * @author Vakhtang Koroghlishvili
  */
 public class PDFTemplateStructure
 {
@@ -50,7 +50,7 @@ public class PDFTemplateStructure
     private PDDocument template;
     private PDAcroForm acroForm;
     private PDSignatureField signatureField;
-    private org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature pdSignature;
+    private PDSignature pdSignature;
     private COSDictionary acroFormDictionary;
     private PDRectangle singatureRectangle;
     private AffineTransform affineTransform;
@@ -115,7 +115,7 @@ public class PDFTemplateStructure
     }
 
     /**
-     * Gets Acroform
+     * Gets AcroForm
      * @return
      */
     public PDAcroForm getAcroForm()
@@ -124,7 +124,7 @@ public class PDFTemplateStructure
     }
 
     /**
-     * Sets Acroform
+     * Sets AcroForm
      * @param acroForm
      */
     public void setAcroForm(PDAcroForm acroForm)
@@ -154,7 +154,7 @@ public class PDFTemplateStructure
      * Gets PDSignatureField
      * @return
      */
-    public org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature getPdSignature()
+    public PDSignature getPdSignature()
     {
         return pdSignature;
     }
@@ -163,7 +163,7 @@ public class PDFTemplateStructure
      * Sets PDSignatureField
      * @param pdSignature
      */
-    public void setPdSignature(org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature pdSignature)
+    public void setPdSignature(PDSignature pdSignature)
     {
         this.pdSignature = pdSignature;
     }
@@ -608,5 +608,4 @@ public class PDFTemplateStructure
     {
         this.widgetDictionary = widgetDictionary;
     }
-
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSigBuilder.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSigBuilder.java?rev=1577056&r1=1577055&r2=1577056&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSigBuilder.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSigBuilder.java Thu Mar 13 08:00:12 2014
@@ -37,20 +37,20 @@ import org.apache.pdfbox.pdmodel.graphic
 import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceStream;
+import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature;
 import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm;
 import org.apache.pdfbox.pdmodel.interactive.form.PDField;
 import org.apache.pdfbox.pdmodel.interactive.form.PDSignatureField;
 
 /**
- * That's implementation of <b>PDFTemplateBuilder </b>
- * @see org.apache.pdfbox.pdmodel.interactive.digitalsignature.visible.PDFTemplateBuilder
- * @author <a href="mailto:vakhtang.koroghlishvili@gmail.com"> vakhtang koroghlishvili (gogebashvili) </a>
- * 
+ * Implementation of PDFTemplateBuilder.
+ * @see PDFTemplateBuilder
+ * @author Vakhtang Koroghlishvili
  */
 public class PDVisibleSigBuilder implements PDFTemplateBuilder
 {
     private PDFTemplateStructure pdfStructure;
-    private static final Log logger = LogFactory.getLog(PDVisibleSigBuilder.class);
+    private static final Log log = LogFactory.getLog(PDVisibleSigBuilder.class);
 
     @Override
     public void createPage(PDVisibleSignDesigner properties)
@@ -58,7 +58,7 @@ public class PDVisibleSigBuilder impleme
         PDPage page = new PDPage();
         page.setMediaBox(new PDRectangle(properties.getPageWidth(), properties.getPageHeight()));
         pdfStructure.setPage(page);
-        logger.info("PDF page has been created");
+        log.info("PDF page has been created");
     }
 
     @Override
@@ -72,8 +72,7 @@ public class PDVisibleSigBuilder impleme
     public PDVisibleSigBuilder()
     {
         pdfStructure = new PDFTemplateStructure();
-        logger.info("PDF Strucure has been Created");
-
+        log.info("PDF Strucure has been Created");
     }
 
     @Override
@@ -82,8 +81,7 @@ public class PDVisibleSigBuilder impleme
         PDAcroForm theAcroForm = new PDAcroForm(template);
         template.getDocumentCatalog().setAcroForm(theAcroForm);
         pdfStructure.setAcroForm(theAcroForm);
-        logger.info("Acro form page has been created");
-
+        log.info("Acro form page has been created");
     }
 
     @Override
@@ -97,14 +95,14 @@ public class PDVisibleSigBuilder impleme
     {
         PDSignatureField sf = new PDSignatureField(acroForm);
         pdfStructure.setSignatureField(sf);
-        logger.info("Signature field has been created");
+        log.info("Signature field has been created");
     }
 
     @Override
-    public void createSignature(PDSignatureField pdSignatureField, PDPage page, String signatureName)
-            throws IOException
+    public void createSignature(PDSignatureField pdSignatureField, PDPage page,
+                                String signatureName) throws IOException
     {
-        org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature pdSignature = new org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature();
+        PDSignature pdSignature = new PDSignature();
         pdSignatureField.setSignature(pdSignature);
         pdSignatureField.getWidget().setPage(page);
         page.getAnnotations().add(pdSignatureField.getWidget());
@@ -112,11 +110,12 @@ public class PDVisibleSigBuilder impleme
         pdSignature.setByteRange(new int[] { 0, 0, 0, 0 });
         pdSignature.setContents(new byte[4096]);
         pdfStructure.setPdSignature(pdSignature);
-        logger.info("PDSignatur has been created");
+        log.info("PDSignatur has been created");
     }
 
     @Override
-    public void createAcroFormDictionary(PDAcroForm acroForm, PDSignatureField signatureField) throws IOException
+    public void createAcroFormDictionary(PDAcroForm acroForm, PDSignatureField signatureField)
+            throws IOException
     {
         @SuppressWarnings("unchecked")
         List<PDField> acroFormFields = acroForm.getFields();
@@ -127,31 +126,32 @@ public class PDVisibleSigBuilder impleme
         acroFormDict.setString(COSName.DA, "/sylfaen 0 Tf 0 g");
         pdfStructure.setAcroFormFields(acroFormFields);
         pdfStructure.setAcroFormDictionary(acroFormDict);
-        logger.info("AcroForm dictionary has been created");
+        log.info("AcroForm dictionary has been created");
     }
 
     @Override
-    public void createSignatureRectangle(PDSignatureField signatureField, PDVisibleSignDesigner properties)
-            throws IOException
+    public void createSignatureRectangle(PDSignatureField signatureField,
+                                         PDVisibleSignDesigner properties) throws IOException
     {
 
         PDRectangle rect = new PDRectangle();
         rect.setUpperRightX(properties.getxAxis() + properties.getWidth());
         rect.setUpperRightY(properties.getTemplateHeight() - properties.getyAxis());
-        rect.setLowerLeftY(properties.getTemplateHeight() - properties.getyAxis() - properties.getHeight());
+        rect.setLowerLeftY(properties.getTemplateHeight() - properties.getyAxis() -
+                           properties.getHeight());
         rect.setLowerLeftX(properties.getxAxis());
         signatureField.getWidget().setRectangle(rect);
         pdfStructure.setSignatureRectangle(rect);
-        logger.info("rectangle of signature has been created");
+        log.info("rectangle of signature has been created");
     }
 
     @Override
     public void createAffineTransform(byte[] params)
     {
-        AffineTransform transform = new AffineTransform(params[0], params[1], params[2], params[3], params[4],
-                params[5]);
+        AffineTransform transform = new AffineTransform(params[0], params[1], params[2],
+                                                        params[3], params[4],  params[5]);
         pdfStructure.setAffineTransform(transform);
-        logger.info("Matrix has been added");
+        log.info("Matrix has been added");
     }
 
     @Override
@@ -164,16 +164,14 @@ public class PDVisibleSigBuilder impleme
         procSetArr.add(COSName.getPDFName("ImageC"));
         procSetArr.add(COSName.getPDFName("ImageI"));
         pdfStructure.setProcSet(procSetArr);
-        logger.info("ProcSet array has been created");
+        log.info("ProcSet array has been created");
     }
 
     @Override
     public void createSignatureImage(PDDocument template, BufferedImage image) throws IOException
     {
         pdfStructure.setImage(JPEGFactory.createFromImage(template, image));
-
-        logger.info("Visible Signature Image has been created");
-        // pdfStructure.setTemplate(template);'
+        log.info("Visible Signature Image has been created");
     }
 
     @Override
@@ -186,7 +184,7 @@ public class PDVisibleSigBuilder impleme
         formrect.setLowerLeftY(params[3]);
 
         pdfStructure.setFormaterRectangle(formrect);
-        logger.info("Formater rectangle has been created");
+        log.info("Formater rectangle has been created");
     }
 
     @Override
@@ -194,7 +192,7 @@ public class PDVisibleSigBuilder impleme
     {
         PDStream holderForm = new PDStream(template);
         pdfStructure.setHolderFormStream(holderForm);
-        logger.info("Holder form Stream has been created");
+        log.info("Holder form Stream has been created");
     }
 
     @Override
@@ -202,28 +200,27 @@ public class PDVisibleSigBuilder impleme
     {
         PDResources holderFormResources = new PDResources();
         pdfStructure.setHolderFormResources(holderFormResources);
-        logger.info("Holder form resources have been created");
+        log.info("Holder form resources have been created");
 
     }
 
     @Override
-    public void createHolderForm(PDResources holderFormResources, PDStream holderFormStream, PDRectangle formrect)
+    public void createHolderForm(PDResources holderFormResources, PDStream holderFormStream,
+                                 PDRectangle formrect)
     {
-
         PDFormXObject holderForm = new PDFormXObject(holderFormStream);
         holderForm.setResources(holderFormResources);
         holderForm.setBBox(formrect);
         holderForm.setFormType(1);
         pdfStructure.setHolderForm(holderForm);
-        logger.info("Holder form has been created");
+        log.info("Holder form has been created");
 
     }
 
     @Override
-    public void createAppearanceDictionary(PDFormXObject holderForml, PDSignatureField signatureField)
-            throws IOException
+    public void createAppearanceDictionary(PDFormXObject holderForml,
+                                           PDSignatureField signatureField) throws IOException
     {
-
         PDAppearanceDictionary appearance = new PDAppearanceDictionary();
         appearance.getCOSObject().setDirect(true);
 
@@ -233,8 +230,7 @@ public class PDVisibleSigBuilder impleme
         signatureField.getWidget().setAppearance(appearance);
 
         pdfStructure.setAppearanceDictionary(appearance);
-        logger.info("PDF appereance Dictionary has been created");
-
+        log.info("PDF appereance Dictionary has been created");
     }
 
     @Override
@@ -242,7 +238,8 @@ public class PDVisibleSigBuilder impleme
     {
         PDStream innterFormStream = new PDStream(template);
         pdfStructure.setInnterFormStream(innterFormStream);
-        logger.info("Strean of another form (inner form - it would be inside holder form) has been created");
+        log.info("Stream of another form (inner form - it would be inside holder form) " +
+                 "has been created");
     }
 
     @Override
@@ -250,27 +247,29 @@ public class PDVisibleSigBuilder impleme
     {
         PDResources innerFormResources = new PDResources();
         pdfStructure.setInnerFormResources(innerFormResources);
-        logger.info("Resources of another form (inner form - it would be inside holder form) have been created");
+        log.info("Resources of another form (inner form - it would be inside holder form)" +
+                 "have been created");
     }
 
     @Override
-    public void createInnerForm(PDResources innerFormResources, PDStream innerFormStream, PDRectangle formrect)
+    public void createInnerForm(PDResources innerFormResources, PDStream innerFormStream,
+                                PDRectangle formrect)
     {
         PDFormXObject innerForm = new PDFormXObject(innerFormStream);
         innerForm.setResources(innerFormResources);
         innerForm.setBBox(formrect);
         innerForm.setFormType(1);
         pdfStructure.setInnerForm(innerForm);
-        logger.info("Another form (inner form - it would be inside holder form) have been created");
-
+        log.info("Another form (inner form - it would be inside holder form) have been created");
     }
 
     @Override
-    public void insertInnerFormToHolerResources(PDFormXObject innerForm, PDResources holderFormResources)
+    public void insertInnerFormToHolerResources(PDFormXObject innerForm,
+                                                PDResources holderFormResources)
     {
         String name = holderFormResources.addXObject(innerForm, "FRM");
         pdfStructure.setInnerFormName(name);
-        logger.info("Alerady inserted inner form  inside holder form");
+        log.info("Alerady inserted inner form  inside holder form");
     }
 
     @Override
@@ -278,8 +277,7 @@ public class PDVisibleSigBuilder impleme
     {
         PDStream imageFormStream = new PDStream(template);
         pdfStructure.setImageFormStream(imageFormStream);
-        logger.info("Created image form Stream");
-
+        log.info("Created image form Stream");
     }
 
     @Override
@@ -287,60 +285,59 @@ public class PDVisibleSigBuilder impleme
     {
         PDResources imageFormResources = new PDResources();
         pdfStructure.setImageFormResources(imageFormResources);
-        logger.info("Created image form Resources");
+        log.info("Created image form Resources");
     }
 
     @Override
     public void createImageForm(PDResources imageFormResources, PDResources innerFormResource,
-            PDStream imageFormStream, PDRectangle formrect, AffineTransform at, PDImageXObject img)
-            throws IOException
+                                PDStream imageFormStream, PDRectangle formrect, AffineTransform at,
+                                PDImageXObject img) throws IOException
     {
-        /*
-         * if you need text on the visible signature 
-         * 
-         * PDFont font = PDTrueTypeFont.loadTTF(this.pdfStructure.getTemplate(), new File("D:\\arial.ttf")); 
-         * font.setFontEncoding(new WinAnsiEncoding());
-         * 
-         * Map<String, PDFont> fonts = new HashMap<String, PDFont>(); fonts.put("arial", font);
-         */
+        // if you need text on the visible signature:
+        //
+        // PDFont font = PDTrueTypeFont.loadTTF(this.pdfStructure.getTemplate(),
+        //                                      new File("D:\\arial.ttf"));
+        // font.setFontEncoding(new WinAnsiEncoding());
+        //
+        // Map<String, PDFont> fonts = new HashMap<String, PDFont>(); fonts.put("arial", font);
+
         PDFormXObject imageForm = new PDFormXObject(imageFormStream);
         imageForm.setBBox(formrect);
         imageForm.setMatrix(at);
         imageForm.setResources(imageFormResources);
         imageForm.setFormType(1);
-        /*
-         * imageForm.getResources().addFont(font); 
-         * imageForm.getResources().setFonts(fonts);
-         */
+
+        // imageForm.getResources().addFont(font);
+        // imageForm.getResources().setFonts(fonts);
 
         imageFormResources.getCOSObject().setDirect(true);
         String imageFormName = innerFormResource.addXObject(imageForm, "n");
         String imageName = imageFormResources.addXObject(img, "img");
-        this.pdfStructure.setImageForm(imageForm);
-        this.pdfStructure.setImageFormName(imageFormName);
-        this.pdfStructure.setImageName(imageName);
-        logger.info("Created image form");
+        pdfStructure.setImageForm(imageForm);
+        pdfStructure.setImageFormName(imageFormName);
+        pdfStructure.setImageName(imageName);
+        log.info("Created image form");
     }
 
     @Override
-    public void injectProcSetArray(PDFormXObject innerForm, PDPage page, PDResources innerFormResources,
-            PDResources imageFormResources, PDResources holderFormResources, COSArray procSet)
+    public void injectProcSetArray(PDFormXObject innerForm, PDPage page,
+                                   PDResources innerFormResources,  PDResources imageFormResources,
+                                   PDResources holderFormResources, COSArray procSet)
     {
-
-        innerForm.getResources().getCOSDictionary().setItem(COSName.PROC_SET, procSet); //
+        innerForm.getResources().getCOSDictionary().setItem(COSName.PROC_SET, procSet);
         page.getCOSDictionary().setItem(COSName.PROC_SET, procSet);
         innerFormResources.getCOSDictionary().setItem(COSName.PROC_SET, procSet);
         imageFormResources.getCOSDictionary().setItem(COSName.PROC_SET, procSet);
         holderFormResources.getCOSDictionary().setItem(COSName.PROC_SET, procSet);
-        logger.info("inserted ProcSet to PDF");
+        log.info("inserted ProcSet to PDF");
     }
 
     @Override
-    public void injectAppearanceStreams(PDStream holderFormStream, PDStream innterFormStream, PDStream imageFormStream,
-            String imageObjectName, String imageName, String innerFormName, PDVisibleSignDesigner properties)
-            throws IOException
+    public void injectAppearanceStreams(PDStream holderFormStream, PDStream innterFormStream,
+                                        PDStream imageFormStream, String imageObjectName,
+                                        String imageName, String innerFormName,
+                                        PDVisibleSignDesigner properties) throws IOException
     {
-
         // 100 means that document width is 100% via the rectangle. if rectangle
         // is 500px, images 100% is 500px.
         // String imgFormComment = "q "+imageWidthSize+ " 0 0 50 0 0 cm /" +
@@ -349,11 +346,13 @@ public class PDVisibleSigBuilder impleme
         String holderFormComment = "q 1 0 0 1 0 0 cm /" + innerFormName + " Do Q \n";
         String innerFormComment = "q 1 0 0 1 0 0 cm /" + imageObjectName + " Do Q\n";
 
-        appendRawCommands(pdfStructure.getHolderFormStream().createOutputStream(), holderFormComment);
-        appendRawCommands(pdfStructure.getInnterFormStream().createOutputStream(), innerFormComment);
-        appendRawCommands(pdfStructure.getImageFormStream().createOutputStream(), imgFormComment);
-        logger.info("Injected apereance stream to pdf");
-
+        appendRawCommands(pdfStructure.getHolderFormStream().createOutputStream(),
+                holderFormComment);
+        appendRawCommands(pdfStructure.getInnterFormStream().createOutputStream(),
+                innerFormComment);
+        appendRawCommands(pdfStructure.getImageFormStream().createOutputStream(),
+                imgFormComment);
+        log.info("Injected apereance stream to pdf");
     }
 
     public void appendRawCommands(OutputStream os, String commands) throws IOException
@@ -365,29 +364,26 @@ public class PDVisibleSigBuilder impleme
     @Override
     public void createVisualSignature(PDDocument template)
     {
-        this.pdfStructure.setVisualSignature(template.getDocument());
-        logger.info("Visible signature has been created");
-
+        pdfStructure.setVisualSignature(template.getDocument());
+        log.info("Visible signature has been created");
     }
 
     @Override
-    public void createWidgetDictionary(PDSignatureField signatureField, PDResources holderFormResources)
-            throws IOException
+    public void createWidgetDictionary(PDSignatureField signatureField,
+                                       PDResources holderFormResources) throws IOException
     {
-
         COSDictionary widgetDict = signatureField.getWidget().getDictionary();
         widgetDict.setNeedToBeUpdate(true);
         widgetDict.setItem(COSName.DR, holderFormResources.getCOSObject());
 
         pdfStructure.setWidgetDictionary(widgetDict);
-        logger.info("WidgetDictionary has been crated");
+        log.info("WidgetDictionary has been crated");
     }
 
     @Override
     public void closeTemplate(PDDocument template) throws IOException
     {
         template.close();
-        this.pdfStructure.getTemplate().close();
-
+        pdfStructure.getTemplate().close();
     }
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSigProperties.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSigProperties.java?rev=1577056&r1=1577055&r2=1577056&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSigProperties.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSigProperties.java Thu Mar 13 08:00:12 2014
@@ -22,8 +22,7 @@ import java.io.InputStream;
 /**
  * This builder class is in order to create visible signature properties.
  * 
- * @author <a href="mailto:vakhtang.koroghlishvili@gmail.com"> vakhtang koroghlishvili (gogebashvili) </a>
- * 
+ * @author Vakhtang Koroghlishvili
  */
 public class PDVisibleSigProperties
 {
@@ -206,5 +205,4 @@ public class PDVisibleSigProperties
     {
         this.visibleSignature = visibleSignature;
     }
-
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSignDesigner.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSignDesigner.java?rev=1577056&r1=1577055&r2=1577056&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSignDesigner.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSignDesigner.java Thu Mar 13 08:00:12 2014
@@ -33,7 +33,6 @@ import org.bouncycastle.util.Arrays;
 
 /**
  * Builder for visible signature design.
- *
  * Uses use param() instead of setParam()
  *
  * @author Vakhtang Koroghlishvili
@@ -111,7 +110,6 @@ public class PDVisibleSignDesigner
      */
     private void calculatePageSize(PDDocument document, int page)
     {
-
         if (page < 1)
         {
             throw new IllegalArgumentException("First page of pdf is 1, not " + page);
@@ -120,19 +118,18 @@ public class PDVisibleSignDesigner
         List<?> pages = document.getDocumentCatalog().getAllPages();
         PDPage firstPage =(PDPage) pages.get(page - 1);
         PDRectangle mediaBox = firstPage.findMediaBox();
-        this.pageHeight(mediaBox.getHeight());
-        this.pageWidth = mediaBox.getWidth();
+        pageHeight(mediaBox.getHeight());
+        pageWidth = mediaBox.getWidth();
 
         float x = this.pageWidth;
         float y = 0;
-        this.pageWidth = this.pageWidth + y;
+        pageWidth = this.pageWidth + y;
         float tPercent = (100 * y / (x + y));
-        this.imageSizeInPercents = 100 - tPercent;
-
+        imageSizeInPercents = 100 - tPercent;
     }
 
     /**
-     * 
+     *
      * @param path  of image location
      * @return image Stream
      * @throws IOException
@@ -157,7 +154,7 @@ public class PDVisibleSignDesigner
     }
 
     /**
-     * 
+     *
      * @param x - x coordinate
      * @param y - y coordinate
      * @return Visible Signature Configuration Object
@@ -170,7 +167,7 @@ public class PDVisibleSignDesigner
     }
 
     /**
-     * 
+     *
      * @return xAxis - gets x coordinates
      */
     public float getxAxis()
@@ -179,7 +176,7 @@ public class PDVisibleSignDesigner
     }
 
     /**
-     * 
+     *
      * @param xAxis  - x coordinate 
      * @return Visible Signature Configuration Object
      */
@@ -190,7 +187,7 @@ public class PDVisibleSignDesigner
     }
 
     /**
-     * 
+     *
      * @return yAxis
      */
     public float getyAxis()
@@ -199,7 +196,7 @@ public class PDVisibleSignDesigner
     }
 
     /**
-     * 
+     *
      * @param yAxis
      * @return Visible Signature Configuration Object
      */