You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2022/01/14 17:03:11 UTC

svn commit: r1897044 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/state: PDExtendedGraphicsState.java PDGraphicsState.java

Author: tilman
Date: Fri Jan 14 17:03:10 2022
New Revision: 1897044

URL: http://svn.apache.org/viewvc?rev=1897044&view=rev
Log:
PDFBOX-5361: OPM is an integer, as pointed out by Gerhard Hiller

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/state/PDExtendedGraphicsState.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/state/PDGraphicsState.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/state/PDExtendedGraphicsState.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/state/PDExtendedGraphicsState.java?rev=1897044&r1=1897043&r2=1897044&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/state/PDExtendedGraphicsState.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/state/PDExtendedGraphicsState.java Fri Jan 14 17:03:10 2022
@@ -94,7 +94,8 @@ public class PDExtendedGraphicsState imp
             }
             else if( key.equals( COSName.OPM ) )
             {
-                gs.setOverprintMode( defaultIfNull( getOverprintMode(), 0 ) );
+                Integer overprintMode = getOverprintMode();
+                gs.setOverprintMode(overprintMode != null ? overprintMode : 0);
             }
             else if( key.equals( COSName.OP ) )
             {
@@ -349,7 +350,7 @@ public class PDExtendedGraphicsState imp
     }
 
     /**
-     * This will get the overprint control(OP).
+     * This will set the overprint control(OP).
      *
      * @param op The overprint control.
      */
@@ -370,7 +371,7 @@ public class PDExtendedGraphicsState imp
     }
 
     /**
-     * This will get the overprint control(OP).
+     * This will set the overprint control(OP).
      *
      * @param op The overprint control.
      */
@@ -384,19 +385,33 @@ public class PDExtendedGraphicsState imp
      *
      * @return The overprint control mode or null if one has not been set.
      */
-    public Float getOverprintMode()
+    public Integer getOverprintMode()
     {
-        return getFloatItem(COSName.OPM);
+        Integer retval = null;
+        COSBase base = dict.getDictionaryObject(COSName.OPM);
+        if (base instanceof COSNumber)
+        {
+            COSNumber value = (COSNumber) base;
+            retval = value.intValue();
+        }
+        return retval;
     }
 
     /**
-     * This will get the overprint mode(OPM).
+     * This will set the overprint mode(OPM).
      *
      * @param overprintMode The overprint mode
      */
-    public void setOverprintMode( Float overprintMode )
+    public void setOverprintMode(Integer overprintMode)
     {
-        setFloatItem(COSName.OPM, overprintMode);
+        if (overprintMode == null)
+        {
+            dict.removeItem(COSName.OPM);
+        }
+        else
+        {
+            dict.setInt(COSName.OPM, overprintMode);
+        }
     }
 
     /**
@@ -431,7 +446,7 @@ public class PDExtendedGraphicsState imp
     }
 
     /**
-     * This will get the flatness tolerance.
+     * This will set the flatness tolerance.
      *
      * @param flatness The new flatness tolerance
      */
@@ -451,7 +466,7 @@ public class PDExtendedGraphicsState imp
     }
 
     /**
-     * This will get the smoothness tolerance.
+     * This will set the smoothness tolerance.
      *
      * @param smoothness The new smoothness tolerance
      */
@@ -471,7 +486,7 @@ public class PDExtendedGraphicsState imp
     }
 
     /**
-     * This will get the automatic stroke adjustment flag.
+     * This will set the automatic stroke adjustment flag.
      *
      * @param sa The new automatic stroke adjustment flag.
      */
@@ -491,7 +506,7 @@ public class PDExtendedGraphicsState imp
     }
 
     /**
-     * This will get the stroking alpha constant.
+     * This will set the stroking alpha constant.
      *
      * @param alpha The new stroking alpha constant.
      */
@@ -511,7 +526,7 @@ public class PDExtendedGraphicsState imp
     }
 
     /**
-     * This will get the non stroking alpha constant.
+     * This will set the non stroking alpha constant.
      *
      * @param alpha The new non stroking alpha constant.
      */
@@ -533,7 +548,7 @@ public class PDExtendedGraphicsState imp
     }
 
     /**
-     * This will get the alpha source flag (“alpha is shape”), that specifies whether the current
+     * This will set the alpha source flag (“alpha is shape”), that specifies whether the current
      * soft mask and alpha constant shall be interpreted as shape values (true) or opacity values
      * (false).
      *
@@ -591,7 +606,7 @@ public class PDExtendedGraphicsState imp
     }
 
     /**
-     * This will get the text knockout flag.
+     * This will set the text knockout flag.
      *
      * @param tk The text knockout flag.
      */

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/state/PDGraphicsState.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/state/PDGraphicsState.java?rev=1897044&r1=1897043&r2=1897044&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/state/PDGraphicsState.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/state/PDGraphicsState.java Fri Jan 14 17:03:10 2022
@@ -69,7 +69,7 @@ public class PDGraphicsState implements
     // DEVICE-DEPENDENT parameters
     private boolean overprint = false;
     private boolean nonStrokingOverprint = false;
-    private double overprintMode = 0;
+    private int overprintMode = 0;
     //black generation
     //undercolor removal
     private COSBase transfer = null;
@@ -352,7 +352,7 @@ public class PDGraphicsState implements
      *
      * @return The value of the overprint mode parameter.
      */
-    public double getOverprintMode()
+    public int getOverprintMode()
     {
         return overprintMode;
     }
@@ -362,7 +362,7 @@ public class PDGraphicsState implements
      *
      * @param value The value of the overprint mode parameter.
      */
-    public void setOverprintMode(double value)
+    public void setOverprintMode(int value)
     {
         overprintMode = value;
     }