pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1848454 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PDFRenderer.java
Date Sat, 08 Dec 2018 11:18:09 GMT
Author: tilman
Date: Sat Dec  8 11:18:09 2018
New Revision: 1848454

URL: http://svn.apache.org/viewvc?rev=1848454&view=rev
Log:
PDFBOX-4401: be more specific for recommendation to use KCMS

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PDFRenderer.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PDFRenderer.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PDFRenderer.java?rev=1848454&r1=1848453&r2=1848454&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PDFRenderer.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PDFRenderer.java Sat Dec
 8 11:18:09 2018
@@ -21,6 +21,8 @@ import java.awt.Graphics2D;
 import java.awt.image.BufferedImage;
 import java.io.IOException;
 import java.util.StringTokenizer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.pdfbox.cos.COSName;
@@ -401,14 +403,55 @@ public class PDFRenderer
                 // Make sure that class exists
                 Class.forName("sun.java2d.cmm.kcms.KcmsServiceProvider");
 
-                LOG.info("To get higher rendering speed on java 8 or 9,");
+                String version = System.getProperty("java.version");
+                if (version == null)
+                {
+                    return;
+                }
+                Matcher matcher = Pattern.compile("1.8.0_(\\d+)").matcher(version);
+                if (matcher.matches() && matcher.groupCount() >= 1)
+                {
+                    try
+                    {
+                        int v = Integer.parseInt(matcher.group(1));
+                        if (v >= 191)
+                        {
+                            // LCMS no longer bad
+                            return;
+                        }
+                    }
+                    catch (NumberFormatException ex)
+                    {
+                        return;
+                    }
+                }
+                matcher = Pattern.compile("9.0.(\\d+)").matcher(version);
+                if (matcher.matches() && matcher.groupCount() >= 1)
+                {
+                    try
+                    {
+                        int v = Integer.parseInt(matcher.group(1));
+                        if (v >= 4)
+                        {
+                            // LCMS no longer bad
+                            return;
+                        }
+                    }
+                    catch (NumberFormatException ex)
+                    {
+                        return;
+                    }
+                }
+                LOG.info("Your current java version is: " + version);
+                LOG.info("To get higher rendering speed on old java 1.8 or 9 versions,");
+                LOG.info("  update to the latest 1.8 or 9 version (>= 1.8.0_191 or >=
9.0.4),");
+                LOG.info("  or");
                 LOG.info("  use the option -Dsun.java2d.cmm=sun.java2d.cmm.kcms.KcmsServiceProvider");
                 LOG.info("  or call System.setProperty(\"sun.java2d.cmm\", \"sun.java2d.cmm.kcms.KcmsServiceProvider\")");
             }
             catch (ClassNotFoundException e)
             {
-                // jdk 10 and higher
-                LOG.debug("KCMS doesn't exist anymore. SO SAD!");
+                // KCMS not available
             }
         }
     }



Mime
View raw message