pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jahew...@apache.org
Subject svn commit: r1635667 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox: contentstream/PDFStreamEngine.java pdmodel/PDResources.java
Date Fri, 31 Oct 2014 05:03:00 GMT
Author: jahewson
Date: Fri Oct 31 05:03:00 2014
New Revision: 1635667

URL: http://svn.apache.org/r1635667
Log:
PDFBOX-2407: Fix: Support for default color spaces (for Device colors) v2

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java?rev=1635667&r1=1635666&r2=1635667&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java
Fri Oct 31 05:03:00 2014
@@ -478,6 +478,12 @@ public class PDFStreamEngine
         {
             resources = currentPage.getResources();
         }
+
+        // resources are required in PDF
+        if (resources == null)
+        {
+            resources = new PDResources();
+        }
         return parentResources;
     }
 

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java?rev=1635667&r1=1635666&r2=1635667&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java Fri Oct 31
05:03:00 2014
@@ -108,18 +108,30 @@ public final class PDResources implement
             name = COSName.DEFAULT_RGB;
         }
         else if (name.equals(COSName.DEVICEGRAY) &&
-                 get(COSName.COLORSPACE, COSName.DEFAULT_RGB) != null)
+                 get(COSName.COLORSPACE, COSName.DEFAULT_GRAY) != null)
         {
             name = COSName.DEFAULT_GRAY;
         }
+        else if (name.equals(COSName.DEVICECMYK) ||
+                 name.equals(COSName.DEVICERGB) ||
+                 name.equals(COSName.DEVICEGRAY))
+        {
+            // built-in device color spaces
+            return PDColorSpace.create(name, this);
+        }
 
         COSBase object = get(COSName.COLORSPACE, name);
-        if (object == null)
+        if (object == null &&
+            name.equals(COSName.DEVICECMYK) ||
+            name.equals(COSName.DEVICERGB) ||
+            name.equals(COSName.DEVICEGRAY))
         {
+            // the named color space does not exist, but it's built-in
             return PDColorSpace.create(name, this);
         }
         else
         {
+            // finally handle named color spaces
             return PDColorSpace.create(object, this);
         }
     }



Mime
View raw message