pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1764009 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java
Date Sun, 09 Oct 2016 20:38:49 GMT
Author: tilman
Date: Sun Oct  9 20:38:49 2016
New Revision: 1764009

URL: http://svn.apache.org/viewvc?rev=1764009&view=rev
Log:
PDFBOX-3525: move the signature check to visitFromDictionary(), because it didn't work when
the signaturefield is a direct object

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java?rev=1764009&r1=1764008&r2=1764009&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java Sun Oct 
9 20:38:49 2016
@@ -507,15 +507,6 @@ public class COSWriter implements ICOSVi
     public void doWriteObject( COSBase obj ) throws IOException
     {
         writtenObjects.add( obj );
-        if(obj instanceof COSDictionary)
-        {
-            COSBase itemType = ((COSDictionary) obj).getItem(COSName.TYPE);
-            if (COSName.SIG.equals(itemType) || COSName.DOC_TIME_STAMP.equals(itemType))
-            {
-                reachedSignature = true;
-            }
-        }
-
         // find the physical reference
         currentObjectKey = getObjectKey( obj );
         // add a x ref entry
@@ -744,7 +735,7 @@ public class COSWriter implements ICOSVi
      * created signature should be set using {@link #writeExternalSignature(byte[])}.
      * <p>
      * When {@link SignatureInterface} instance is used, COSWriter obtains and writes the
signature
-     * itsef.
+     * itself.
      * </p>
      *
      * @return data stream to be signed
@@ -983,6 +974,14 @@ public class COSWriter implements ICOSVi
     @Override
     public Object visitFromDictionary(COSDictionary obj) throws IOException
     {
+        if (!reachedSignature)
+        {
+            COSBase itemType = obj.getItem(COSName.TYPE);
+            if (COSName.SIG.equals(itemType) || COSName.DOC_TIME_STAMP.equals(itemType))
+            {
+                reachedSignature = true;
+            }
+        }        
         getStandardOutput().write(DICT_OPEN);
         getStandardOutput().writeEOL();
         for (Map.Entry<COSName, COSBase> entry : obj.entrySet())



Mime
View raw message