You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2015/04/20 19:09:28 UTC

svn commit: r1674945 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java

Author: tilman
Date: Mon Apr 20 17:09:27 2015
New Revision: 1674945

URL: http://svn.apache.org/r1674945
Log:
PDFBOX-2716: throw IllegalStateException instead of NPE if saveIncremental() called after loading from a stream instead of a file

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java?rev=1674945&r1=1674944&r2=1674945&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java Mon Apr 20 17:09:27 2015
@@ -968,13 +968,18 @@ public class PDDocument implements Close
     }
 
    /**
-     * Save the PDF as an incremental update.
+     * Save the PDF as an incremental update. This is only possible if the PDF was loaded from a file.
      *
      * @param output stream to write
      * @throws IOException if the output could not be written
+     * @throws IllegalStateException if the document was not loaded from a file.
      */
     public void saveIncremental(OutputStream output) throws IOException
     {
+        if (incrementalFile == null)
+        {
+            throw new IllegalStateException("Incremental save is only possible if the document was loaded from a file");
+        }
         InputStream input = new RandomAccessBufferedFileInputStream(incrementalFile);
         COSWriter writer = null;
         try