pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r1547541 - /pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/edit/PDPageContentStream.java
Date Tue, 03 Dec 2013 19:29:41 GMT
Author: lehmi
Date: Tue Dec  3 19:29:41 2013
New Revision: 1547541

URL: http://svn.apache.org/r1547541
Log:
PDFBOX-1789: avoid NPE after reseting the content stream

Modified:
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/edit/PDPageContentStream.java

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/edit/PDPageContentStream.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/edit/PDPageContentStream.java?rev=1547541&r1=1547540&r2=1547541&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/edit/PDPageContentStream.java
(original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/edit/PDPageContentStream.java
Tue Dec  3 19:29:41 2013
@@ -66,7 +66,6 @@ public class PDPageContentStream
      */
     private static final Log LOG = LogFactory.getLog(PDPageContentStream.class);
 
-    private PDPage page;
     private OutputStream output;
     private boolean inTextMode = false;
     private PDResources resources;
@@ -186,15 +185,6 @@ public class PDPageContentStream
     public PDPageContentStream(PDDocument document, PDPage sourcePage, boolean appendContent,
boolean compress,
             boolean resetContext) throws IOException
     {
-
-        page = sourcePage;
-        resources = page.getResources();
-        if (resources == null)
-        {
-            resources = new PDResources();
-            page.setResources(resources);
-        }
-
         // Get the pdstream from the source page instead of creating a new one
         PDStream contents = sourcePage.getContents();
         boolean hasContent = contents != null;
@@ -276,6 +266,14 @@ public class PDPageContentStream
         }
         formatDecimal.setMaximumFractionDigits(10);
         formatDecimal.setGroupingUsed(false);
+        // this has to be done here, as the resources will be set to null when reseting the
content stream
+        resources = sourcePage.getResources();
+        if (resources == null)
+        {
+            resources = new PDResources();
+            sourcePage.setResources(resources);
+        }
+
     }
 
     /**
@@ -1513,7 +1511,6 @@ public class PDPageContentStream
         output.close();
         currentNonStrokingColorSpace = null;
         currentStrokingColorSpace = null;
-        page = null;
         resources = null;
     }
 }



Mime
View raw message