pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jahew...@apache.org
Subject svn commit: r1635720 - in /pdfbox/trunk: pdfbox/src/main/java/org/apache/pdfbox/pdmodel/ pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/ preflight/src/main/java/org/apache/pdfbox/preflight/graphic/
Date Fri, 31 Oct 2014 08:21:47 GMT
Author: jahewson
Date: Fri Oct 31 08:21:47 2014
New Revision: 1635720

URL: http://svn.apache.org/r1635720
Log:
PDFBOX-2407: Fix issues with preflight colors

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDColorSpace.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/graphic/StandardColorSpaceHelper.java

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=1635720&r1=1635719&r2=1635720&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
08:21:47 2014
@@ -96,30 +96,6 @@ public final class PDResources implement
      */
     public PDColorSpace getColorSpace(COSName name) throws IOException
     {
-        // check for default color spaces - todo: move this into PDColorSpace.create?
-        if (name.equals(COSName.DEVICECMYK) &&
-            get(COSName.COLORSPACE, COSName.DEFAULT_CMYK) != null)
-        {
-            name = COSName.DEFAULT_CMYK;
-        }
-        else if (name.equals(COSName.DEVICERGB) &&
-                 get(COSName.COLORSPACE, COSName.DEFAULT_RGB) != null)
-        {
-            name = COSName.DEFAULT_RGB;
-        }
-        else if (name.equals(COSName.DEVICEGRAY) &&
-                 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);
-        }
-
         // get the instance
         COSBase object = get(COSName.COLORSPACE, name);
         if (object != null)

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDColorSpace.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDColorSpace.java?rev=1635720&r1=1635719&r2=1635720&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDColorSpace.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDColorSpace.java
Fri Oct 31 08:21:47 2014
@@ -71,6 +71,35 @@ public abstract class PDColorSpace imple
         {
             COSName name = (COSName)colorSpace;
 
+            // default color spaces
+            if (resources != null)
+            {
+                COSName defaultName = null;
+                if (name.equals(COSName.DEVICECMYK) &&
+                    resources.hasColorSpace(COSName.DEFAULT_CMYK))
+                {
+                    defaultName = COSName.DEFAULT_CMYK;
+                }
+                else if (name.equals(COSName.DEVICERGB) &&
+                         resources.hasColorSpace(COSName.DEFAULT_RGB))
+                {
+                    defaultName = COSName.DEFAULT_RGB;
+                }
+                else if (name.equals(COSName.DEVICEGRAY) &&
+                         resources.hasColorSpace(COSName.DEFAULT_GRAY))
+                {
+                    defaultName = COSName.DEFAULT_GRAY;
+                }
+
+                if (resources.hasColorSpace(defaultName))
+                {
+                    return resources.getColorSpace(defaultName);
+                }
+            }
+
+            // ---------------
+
+            // built-in color spaces
             if (name == COSName.DEVICECMYK || name == COSName.CMYK)
             {
                 return PDDeviceCMYK.INSTANCE;

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/graphic/StandardColorSpaceHelper.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/graphic/StandardColorSpaceHelper.java?rev=1635720&r1=1635719&r2=1635720&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/graphic/StandardColorSpaceHelper.java
(original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/graphic/StandardColorSpaceHelper.java
Fri Oct 31 08:21:47 2014
@@ -419,15 +419,18 @@ public class StandardColorSpaceHelper im
 
             try
             {
-                if (pdcs.getName().equals(ColorSpaces.DeviceCMYK.getLabel()))
+                if (pdcs.getName().equals(ColorSpaces.DeviceCMYK.getLabel()) &&
+                    resources.hasColorSpace(COSName.DEFAULT_CMYK))
                 {
                     defaultCS = resources.getColorSpace(COSName.DEFAULT_CMYK);
                 }
-                else if (pdcs.getName().equals(ColorSpaces.DeviceRGB.getLabel()))
+                else if (pdcs.getName().equals(ColorSpaces.DeviceRGB.getLabel()) &&
+                         resources.hasColorSpace(COSName.DEFAULT_RGB))
                 {
                     defaultCS = resources.getColorSpace(COSName.DEFAULT_RGB);
                 }
-                else if (pdcs.getName().equals(ColorSpaces.DeviceGray.getLabel()))
+                else if (pdcs.getName().equals(ColorSpaces.DeviceGray.getLabel()) &&
+                         resources.hasColorSpace(COSName.DEFAULT_GRAY))
                 {
                     defaultCS = resources.getColorSpace(COSName.DEFAULT_GRAY);
                 }



Mime
View raw message