pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1829910 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDICCBased.java
Date Mon, 23 Apr 2018 17:39:29 GMT
Author: tilman
Date: Mon Apr 23 17:39:29 2018
New Revision: 1829910

URL: http://svn.apache.org/viewvc?rev=1829910&view=rev
Log:
PDFBOX-4200: catch IOException if ICC profile cannot be read and use alternate colorspace

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDICCBased.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDICCBased.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDICCBased.java?rev=1829910&r1=1829909&r2=1829910&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDICCBased.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDICCBased.java
Mon Apr 23 17:39:29 2018
@@ -157,29 +157,24 @@ public final class PDICCBased extends PD
                                         Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
             }
         }
-        catch (RuntimeException e)
+        catch (ProfileDataException | CMMException | IllegalArgumentException |
+               ArrayIndexOutOfBoundsException | IOException e)
         {
-            if (e instanceof ProfileDataException ||
-                e instanceof CMMException ||
-                e instanceof IllegalArgumentException ||
-                e instanceof ArrayIndexOutOfBoundsException)
-            {
-                // fall back to alternateColorSpace color space
-                awtColorSpace = null;
-                alternateColorSpace = getAlternateColorSpace();
-                if (alternateColorSpace.equals(PDDeviceRGB.INSTANCE))
-                {
-                    isRGB = true;
-                }
-                LOG.warn("Can't read embedded ICC profile (" + e.getLocalizedMessage() +

-                         "), using alternate color space: " + alternateColorSpace.getName());
-                initialColor = alternateColorSpace.getInitialColor();
-            }
-            else
-            {
-                throw e;
-            }
+            fallbackToAlternateColorSpace(e);
+        }
+    }
+
+    private void fallbackToAlternateColorSpace(Exception e) throws IOException
+    {
+        awtColorSpace = null;
+        alternateColorSpace = getAlternateColorSpace();
+        if (alternateColorSpace.equals(PDDeviceRGB.INSTANCE))
+        {
+            isRGB = true;
         }
+        LOG.warn("Can't read embedded ICC profile (" + e.getLocalizedMessage() +
+                "), using alternate color space: " + alternateColorSpace.getName());
+        initialColor = alternateColorSpace.getInitialColor();
     }
 
     /**



Mime
View raw message