pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1841629 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/JPEGFactory.java
Date Fri, 21 Sep 2018 18:57:03 GMT
Author: tilman
Date: Fri Sep 21 18:57:02 2018
New Revision: 1841629

URL: http://svn.apache.org/viewvc?rev=1841629&view=rev
Log:
PDFBOX-4317: catch exception that happens with CMYK test with oracle image reader

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/JPEGFactory.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/JPEGFactory.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/JPEGFactory.java?rev=1841629&r1=1841628&r2=1841629&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/JPEGFactory.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/JPEGFactory.java
Fri Sep 21 18:57:02 2018
@@ -177,20 +177,27 @@ public final class JPEGFactory
     {
         // Metadata format:
         // https://docs.oracle.com/javase/10/docs/api/javax/imageio/metadata/doc-files/jpeg_metadata.html
-        IIOMetadata imageMetadata = reader.getImageMetadata(0);
-        Element tree = (Element) imageMetadata.getAsTree("javax_imageio_jpeg_image_1.0");
-        Element markerSequence = (Element) tree.getElementsByTagName("markerSequence").item(0);
-        NodeList nodeList = markerSequence.getElementsByTagName("sof");
-        if (nodeList != null && nodeList.getLength() > 0)
+        try
         {
-            Element element = (Element) nodeList.item(0);
-            String process = element.getAttribute("process");
-            if ("2".equals(process))
+            IIOMetadata imageMetadata = reader.getImageMetadata(0);
+            Element tree = (Element) imageMetadata.getAsTree("javax_imageio_jpeg_image_1.0");
+            Element markerSequence = (Element) tree.getElementsByTagName("markerSequence").item(0);
+            NodeList nodeList = markerSequence.getElementsByTagName("sof");
+            if (nodeList != null && nodeList.getLength() > 0)
             {
-                LOG.warn("Progressive JPEGs are not properly supported by Adobe Reader;");
-                LOG.warn("please check whether your PDF displays.");
+                Element element = (Element) nodeList.item(0);
+                String process = element.getAttribute("process");
+                if ("2".equals(process))
+                {
+                    LOG.warn("Progressive JPEGs are not properly supported by Adobe Reader;");
+                    LOG.warn("please check whether your PDF displays.");
+                }
             }
         }
+        catch (IOException ex)
+        {
+            LOG.debug("error reading metadata", ex);
+        }
     }
 
     /**



Mime
View raw message