pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1803886 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel: PDDocument.java PDPage.java
Date Wed, 02 Aug 2017 17:23:20 GMT
Author: tilman
Date: Wed Aug  2 17:23:20 2017
New Revision: 1803886

URL: http://svn.apache.org/viewvc?rev=1803886&view=rev
Log:
PDFBOX-2852: remove unneeded nullcheck; simplify code; improve javadoc

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.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=1803886&r1=1803885&r2=1803886&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 Wed Aug  2
17:23:20 2017
@@ -666,21 +666,9 @@ public class PDDocument implements Close
     public PDPage importPage(PDPage page) throws IOException
     {
         PDPage importedPage = new PDPage(new COSDictionary(page.getCOSObject()), resourceCache);
-        InputStream in = null;
-        try
-        {
-            in = page.getContents();
-            if (in != null)
-            {
-                PDStream dest = new PDStream(this, in, COSName.FLATE_DECODE);
-                importedPage.setContents(dest);
-            }
-            addPage(importedPage);
-        }
-        catch (IOException e)
-        {
-            IOUtils.closeQuietly(in);
-        }
+        PDStream dest = new PDStream(this, page.getContents(), COSName.FLATE_DECODE);
+        importedPage.setContents(dest);
+        addPage(importedPage);
         importedPage.setCropBox(page.getCropBox());
         importedPage.setMediaBox(page.getMediaBox());
         importedPage.setRotation(page.getRotation());

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java?rev=1803886&r1=1803885&r2=1803886&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java Wed Aug  2 17:23:20
2017
@@ -139,6 +139,13 @@ public class PDPage implements COSObject
         return streams.iterator();
     }
     
+    /**
+     * Returns the content stream(s) of this page as a single input stream.
+     *
+     * @return An InputStream, never null. Multiple content streams are concatenated and
separated
+     * with a newline. An empty stream is returned if the page doesn't have any content stream.
+     * @throws IOException If the stream could not be read
+     */
     @Override
     public InputStream getContents() throws IOException
     {



Mime
View raw message