You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by tc...@apache.org on 2015/12/17 01:24:19 UTC
svn commit: r1720482 -
/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java
Author: tchojecki
Date: Thu Dec 17 00:24:19 2015
New Revision: 1720482
URL: http://svn.apache.org/viewvc?rev=1720482&view=rev
Log:
PDFBOX-3169
add an additional method, that handle the saveIncremental write for non-signature cases. It will copy the origin document and the incremental update into the given Outputstream.
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=1720482&r1=1720481&r2=1720482&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 Thu Dec 17 00:24:19 2015
@@ -708,13 +708,24 @@ public class COSWriter implements ICOSVi
}
}
+ /**
+ * Write an incremental update for a non signature case. This can be used for e.g. augmenting signatures.
+ *
+ * @throws IOException
+ */
+ private void doWriteIncrement() throws IOException
+ {
+ ByteArrayOutputStream byteOut = (ByteArrayOutputStream) output;
+ byteOut.flush();
+ byte[] buffer = byteOut.toByteArray();
+ SequenceInputStream signStream = new SequenceInputStream(new RandomAccessInputStream(incrementalInput),
+ new ByteArrayInputStream(buffer));
+ // write the data to the incremental output stream
+ IOUtils.copy(signStream, incrementalOutput);
+ }
+
private void doWriteSignature() throws IOException
{
- if (signatureOffset == 0 || byteRangeOffset == 0)
- {
- return;
- }
-
// calculate the ByteRange values
long inLength = incrementalInput.length();
long beforeLength = signatureOffset;
@@ -1090,7 +1101,12 @@ public class COSWriter implements ICOSVi
if(incrementalUpdate)
{
- doWriteSignature();
+ if (signatureOffset == 0 || byteRangeOffset == 0)
+ {
+ doWriteIncrement();
+ } else {
+ doWriteSignature();
+ }
}
return null;