pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1767748 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java
Date Wed, 02 Nov 2016 17:55:45 GMT
Author: tilman
Date: Wed Nov  2 17:55:44 2016
New Revision: 1767748

URL: http://svn.apache.org/viewvc?rev=1767748&view=rev
Log:
PDFBOX-3552: update ByteRange COSArray so that users can access the actual values before closing

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=1767748&r1=1767747&r2=1767748&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 Wed Nov 
2 17:55:44 2016
@@ -218,6 +218,7 @@ public class COSWriter implements ICOSVi
     private OutputStream incrementalOutput;
     private SignatureInterface signatureInterface;
     private byte[] incrementPart;
+    private COSArray byteRangeArray;
 
     /**
      * COSWriter constructor comment.
@@ -693,6 +694,13 @@ public class COSWriter implements ICOSVi
         long afterLength = getStandardOutput().getPos() - (inLength + signatureLength) -
(signatureOffset - inLength);
 
         String byteRange = "0 " + beforeLength + " " + afterOffset + " " + afterLength +
"]";
+        
+        // Assign the values to the actual COSArray, so that the user can access it before
closing
+        byteRangeArray.set(0, COSInteger.ZERO);
+        byteRangeArray.set(1, COSInteger.get(beforeLength));
+        byteRangeArray.set(2, COSInteger.get(afterOffset));
+        byteRangeArray.set(3, COSInteger.get(afterLength));
+
         if (byteRangeLength - byteRange.length() < 0)
         {
             throw new IOException("Can't write new ByteRange, not enough space");
@@ -1047,6 +1055,7 @@ public class COSWriter implements ICOSVi
                     }
                     else if(reachedSignature && COSName.BYTERANGE.equals(entry.getKey()))
                     {
+                        byteRangeArray = (COSArray) entry.getValue();
                         byteRangeOffset = getStandardOutput().getPos() + 1;
                         value.accept(this);
                         byteRangeLength = getStandardOutput().getPos() - 1 - byteRangeOffset;



Mime
View raw message