pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1753578 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible: PDFTemplateCreator.java PDFTemplateStructure.java
Date Wed, 20 Jul 2016 17:23:47 GMT
Author: tilman
Date: Wed Jul 20 17:23:47 2016
New Revision: 1753578

URL: http://svn.apache.org/viewvc?rev=1753578&view=rev
Log:
PDFBOX-3017: deprecate / remove poorly named method "getTemplateAppearanceStream"

Modified:
    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

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=1753578&r1=1753577&r2=1753578&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
Wed Jul 20 17:23:47 2016
@@ -18,12 +18,15 @@ package org.apache.pdfbox.pdmodel.intera
 
 import java.awt.geom.AffineTransform;
 import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.pdfbox.cos.COSDocument;
 import org.apache.pdfbox.cos.COSName;
+import org.apache.pdfbox.pdfwriter.COSWriter;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDPage;
 import org.apache.pdfbox.pdmodel.PDResources;
@@ -152,7 +155,7 @@ public class PDFTemplateCreator
         pdfBuilder.createVisualSignature(template);
         pdfBuilder.createWidgetDictionary(pdSignatureField, holderFormResources);
         
-        ByteArrayInputStream in = pdfStructure.getTemplateAppearanceStream();
+        InputStream in = getVisualSignatureAsStream(pdfStructure.getVisualSignature());
         logger.info("stream returning started, size= " + in.available());
         
         // we must close the document
@@ -161,4 +164,13 @@ public class PDFTemplateCreator
         // return result of the stream 
         return in;
     }
-}
+
+    private InputStream getVisualSignatureAsStream(COSDocument visualSignature) throws IOException
+    {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        COSWriter writer = new COSWriter(baos);
+        writer.write(visualSignature);
+        writer.close();
+        return new ByteArrayInputStream(baos.toByteArray());
+    }   
+}
\ No newline at end of file

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=1753578&r1=1753577&r2=1753578&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
Wed Jul 20 17:23:47 2016
@@ -17,15 +17,11 @@
 package org.apache.pdfbox.pdmodel.interactive.digitalsignature.visible;
 
 import java.awt.geom.AffineTransform;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
 import java.util.List;
 import org.apache.pdfbox.cos.COSArray;
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSDocument;
 import org.apache.pdfbox.cos.COSName;
-import org.apache.pdfbox.pdfwriter.COSWriter;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDPage;
 import org.apache.pdfbox.pdmodel.PDResources;
@@ -61,7 +57,7 @@ public class PDFTemplateStructure
     private PDResources holderFormResources;
     private PDFormXObject holderForm;
     private PDAppearanceDictionary appearanceDictionary;
-    private PDStream innterFormStream;
+    private PDStream innerFormStream;
     private PDResources innerFormResources;
     private PDFormXObject innerForm;
     private PDStream imageFormStream;
@@ -74,6 +70,8 @@ public class PDFTemplateStructure
     private PDFormXObject imageForm;
     private COSDictionary widgetDictionary;
 
+    // no constructor
+    
     /**
      * Returns document page.
      * @return the page
@@ -362,16 +360,16 @@ public class PDFTemplateStructure
      */
     public PDStream getInnerFormStream()
     {
-        return innterFormStream;
+        return innerFormStream;
     }
 
     /**
      * Sets inner form stream
-     * @param innterFormStream
+     * @param innerFormStream
      */
-    public void setInnterFormStream(PDStream innterFormStream)
+    public void setInnterFormStream(PDStream innerFormStream)
     {
-        this.innterFormStream = innterFormStream;
+        this.innerFormStream = innerFormStream;
     }
 
     /**
@@ -567,25 +565,6 @@ public class PDFTemplateStructure
     {
         this.acroFormFields = acroFormFields;
     }
-    
-   /**
-    * Gets AP of the created template
-    * @return the templates Appearance Stream
-    * @throws IOException
-    */
-    public ByteArrayInputStream getTemplateAppearanceStream() throws IOException
-    {
-        COSDocument visualSignature = getVisualSignature();
-        ByteArrayOutputStream memoryOut = new ByteArrayOutputStream();
-        COSWriter memoryWriter = new COSWriter(memoryOut);
-        memoryWriter.write(visualSignature);
-
-        ByteArrayInputStream input = new ByteArrayInputStream(memoryOut.toByteArray());
-
-        getTemplate().close();
-
-        return input;
-    }
 
     /**
      * Gets Widget Dictionary.



Mime
View raw message