pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jahew...@apache.org
Subject svn commit: r1635607 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox: contentstream/operator/color/ pdmodel/
Date Thu, 30 Oct 2014 20:30:13 GMT
Author: jahewson
Date: Thu Oct 30 20:30:12 2014
New Revision: 1635607

URL: http://svn.apache.org/r1635607
Log:
PDFBOX-2407: Support for default color spaces

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetNonStrokingColorSpace.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetNonStrokingDeviceCMYKColor.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetNonStrokingDeviceGrayColor.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetNonStrokingDeviceRGBColor.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetStrokingColorSpace.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetStrokingDeviceCMYKColor.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetStrokingDeviceGrayColor.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetStrokingDeviceRGBColor.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetNonStrokingColorSpace.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetNonStrokingColorSpace.java?rev=1635607&r1=1635606&r2=1635607&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetNonStrokingColorSpace.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetNonStrokingColorSpace.java
Thu Oct 30 20:30:12 2014
@@ -44,7 +44,7 @@ public class SetNonStrokingColorSpace ex
 
         try
         {
-            PDColorSpace cs = PDColorSpace.create(name, context.getResources());
+            PDColorSpace cs = context.getResources().getColorSpace(name);
             context.getGraphicsState().setNonStrokingColorSpace(cs);
             context.getGraphicsState().setNonStrokingColor(cs.getInitialColor());
         }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetNonStrokingDeviceCMYKColor.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetNonStrokingDeviceCMYKColor.java?rev=1635607&r1=1635606&r2=1635607&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetNonStrokingDeviceCMYKColor.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetNonStrokingDeviceCMYKColor.java
Thu Oct 30 20:30:12 2014
@@ -17,6 +17,8 @@
 package org.apache.pdfbox.contentstream.operator.color;
 
 import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.cos.COSName;
+import org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace;
 import org.apache.pdfbox.pdmodel.graphics.color.PDDeviceCMYK;
 import org.apache.pdfbox.contentstream.operator.Operator;
 
@@ -34,7 +36,8 @@ public class SetNonStrokingDeviceCMYKCol
     @Override
     public void process(Operator operator, List<COSBase> arguments) throws IOException
     {
-        context.getGraphicsState().setNonStrokingColorSpace(PDDeviceCMYK.INSTANCE);
+        PDColorSpace cs = context.getResources().getColorSpace(COSName.DEVICECMYK);
+        context.getGraphicsState().setNonStrokingColorSpace(cs);
         super.process(operator, arguments);
     }
 

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetNonStrokingDeviceGrayColor.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetNonStrokingDeviceGrayColor.java?rev=1635607&r1=1635606&r2=1635607&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetNonStrokingDeviceGrayColor.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetNonStrokingDeviceGrayColor.java
Thu Oct 30 20:30:12 2014
@@ -17,6 +17,8 @@
 package org.apache.pdfbox.contentstream.operator.color;
 
 import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.cos.COSName;
+import org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace;
 import org.apache.pdfbox.pdmodel.graphics.color.PDDeviceGray;
 import org.apache.pdfbox.contentstream.operator.Operator;
 
@@ -34,7 +36,8 @@ public class SetNonStrokingDeviceGrayCol
     @Override
     public void process(Operator operator, List<COSBase> arguments) throws IOException
     {
-        context.getGraphicsState().setNonStrokingColorSpace(PDDeviceGray.INSTANCE);
+        PDColorSpace cs = context.getResources().getColorSpace(COSName.DEVICEGRAY);
+        context.getGraphicsState().setNonStrokingColorSpace(cs);
         super.process(operator, arguments);
     }
 

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetNonStrokingDeviceRGBColor.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetNonStrokingDeviceRGBColor.java?rev=1635607&r1=1635606&r2=1635607&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetNonStrokingDeviceRGBColor.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetNonStrokingDeviceRGBColor.java
Thu Oct 30 20:30:12 2014
@@ -17,6 +17,8 @@
 package org.apache.pdfbox.contentstream.operator.color;
 
 import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.cos.COSName;
+import org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace;
 import org.apache.pdfbox.pdmodel.graphics.color.PDDeviceRGB;
 import org.apache.pdfbox.contentstream.operator.Operator;
 
@@ -34,7 +36,8 @@ public class SetNonStrokingDeviceRGBColo
     @Override
     public void process(Operator operator, List<COSBase> arguments) throws IOException
     {
-        context.getGraphicsState().setNonStrokingColorSpace(PDDeviceRGB.INSTANCE);
+        PDColorSpace cs = context.getResources().getColorSpace(COSName.DEVICERGB);
+        context.getGraphicsState().setNonStrokingColorSpace(cs);
         super.process(operator, arguments);
     }
 

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetStrokingColorSpace.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetStrokingColorSpace.java?rev=1635607&r1=1635606&r2=1635607&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetStrokingColorSpace.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetStrokingColorSpace.java
Thu Oct 30 20:30:12 2014
@@ -44,7 +44,7 @@ public class SetStrokingColorSpace exten
 
         try
         {
-            PDColorSpace cs = PDColorSpace.create(name, context.getResources());
+            PDColorSpace cs = context.getResources().getColorSpace(name);
             context.getGraphicsState().setStrokingColorSpace(cs);
             context.getGraphicsState().setStrokingColor(cs.getInitialColor());
         }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetStrokingDeviceCMYKColor.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetStrokingDeviceCMYKColor.java?rev=1635607&r1=1635606&r2=1635607&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetStrokingDeviceCMYKColor.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetStrokingDeviceCMYKColor.java
Thu Oct 30 20:30:12 2014
@@ -17,6 +17,8 @@
 package org.apache.pdfbox.contentstream.operator.color;
 
 import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.cos.COSName;
+import org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace;
 import org.apache.pdfbox.pdmodel.graphics.color.PDDeviceCMYK;
 import org.apache.pdfbox.contentstream.operator.Operator;
 
@@ -33,7 +35,8 @@ public class SetStrokingDeviceCMYKColor 
     @Override
     public void process(Operator operator, List<COSBase> arguments) throws IOException
     {
-        context.getGraphicsState().setStrokingColorSpace(PDDeviceCMYK.INSTANCE);
+        PDColorSpace cs = context.getResources().getColorSpace(COSName.DEVICECMYK);
+        context.getGraphicsState().setNonStrokingColorSpace(cs);
         super.process(operator, arguments);
     }
 

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetStrokingDeviceGrayColor.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetStrokingDeviceGrayColor.java?rev=1635607&r1=1635606&r2=1635607&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetStrokingDeviceGrayColor.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetStrokingDeviceGrayColor.java
Thu Oct 30 20:30:12 2014
@@ -17,6 +17,8 @@
 package org.apache.pdfbox.contentstream.operator.color;
 
 import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.cos.COSName;
+import org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace;
 import org.apache.pdfbox.pdmodel.graphics.color.PDDeviceGray;
 import org.apache.pdfbox.contentstream.operator.Operator;
 
@@ -33,7 +35,8 @@ public class SetStrokingDeviceGrayColor 
 {
     public void process(Operator operator, List<COSBase> arguments) throws IOException
     {
-        context.getGraphicsState().setStrokingColorSpace(PDDeviceGray.INSTANCE);
+        PDColorSpace cs = context.getResources().getColorSpace(COSName.DEVICEGRAY);
+        context.getGraphicsState().setNonStrokingColorSpace(cs);
         super.process(operator, arguments);
     }
 

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetStrokingDeviceRGBColor.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetStrokingDeviceRGBColor.java?rev=1635607&r1=1635606&r2=1635607&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetStrokingDeviceRGBColor.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/color/SetStrokingDeviceRGBColor.java
Thu Oct 30 20:30:12 2014
@@ -17,6 +17,8 @@
 package org.apache.pdfbox.contentstream.operator.color;
 
 import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.cos.COSName;
+import org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace;
 import org.apache.pdfbox.pdmodel.graphics.color.PDDeviceRGB;
 import org.apache.pdfbox.contentstream.operator.Operator;
 
@@ -40,7 +42,8 @@ public class SetStrokingDeviceRGBColor e
      */
     public void process(Operator operator, List<COSBase> arguments) throws IOException
     {
-        context.getGraphicsState().setStrokingColorSpace(PDDeviceRGB.INSTANCE);
+        PDColorSpace cs = context.getResources().getColorSpace(COSName.DEVICERGB);
+        context.getGraphicsState().setNonStrokingColorSpace(cs);
         super.process(operator, arguments);
     }
 

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=1635607&r1=1635606&r2=1635607&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 Thu Oct 30
20:30:12 2014
@@ -96,6 +96,23 @@ public final class PDResources implement
      */
     public PDColorSpace getColorSpace(COSName name) throws IOException
     {
+        // check for default color spaces
+        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_RGB) != null)
+        {
+            name = COSName.DEFAULT_GRAY;
+        }
+
         COSBase object = get(COSName.COLORSPACE, name);
         if (object == null)
         {



Mime
View raw message