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 2016/04/09 17:34:21 UTC
svn commit: r1738359 -
/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java
Author: tilman
Date: Sat Apr 9 15:34:20 2016
New Revision: 1738359
URL: http://svn.apache.org/viewvc?rev=1738359&view=rev
Log:
PDFBOX-3312: avoid NPE if document wasn't loaded / fix javadoc
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=1738359&r1=1738358&r2=1738359&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 Sat Apr 9 15:34:20 2016
@@ -1107,18 +1107,23 @@ public class PDDocument implements Close
}
}
- /**
- * Save the PDF as an incremental update. This is only possible if the PDF was loaded from a file.
+ /**
+ * Save the PDF as an incremental update. This is only possible if the PDF was loaded from a
+ * file or a stream, not if the document was created in PDFBox itself.
*
* @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.
+ * @throws IllegalStateException if the document was not loaded from a file or a stream.
*/
public void saveIncremental(OutputStream output) throws IOException
{
COSWriter writer = null;
try
{
+ if (pdfSource == null)
+ {
+ throw new IllegalStateException("document was not loaded from a file or a stream");
+ }
writer = new COSWriter(output, pdfSource);
writer.write(this, signInterface);
writer.close();