pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1696327 - in /pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process: AbstractProcess.java reflect/ExtGStateValidationProcess.java reflect/ResourcesValidationProcess.java
Date Mon, 17 Aug 2015 18:48:06 GMT
Author: tilman
Date: Mon Aug 17 18:48:06 2015
New Revision: 1696327

URL: http://svn.apache.org/r1696327
Log:
PDFBOX-2804: move font error handler to base class to use it for ExtGState font check

Modified:
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/AbstractProcess.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/ExtGStateValidationProcess.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/ResourcesValidationProcess.java

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/AbstractProcess.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/AbstractProcess.java?rev=1696327&r1=1696326&r2=1696327&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/AbstractProcess.java
(original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/AbstractProcess.java
Mon Aug 17 18:48:06 2015
@@ -21,7 +21,11 @@
 
 package org.apache.pdfbox.preflight.process;
 
+import java.io.IOException;
 import java.util.List;
+import org.apache.pdfbox.cos.COSDictionary;
+import org.apache.pdfbox.cos.COSName;
+import org.apache.pdfbox.preflight.PreflightConstants;
 
 import org.apache.pdfbox.preflight.PreflightContext;
 import org.apache.pdfbox.preflight.ValidationResult.ValidationError;
@@ -41,4 +45,55 @@ public abstract class AbstractProcess im
             addValidationError(ctx, error);
         }
     }
+
+    /**
+     * PDFont loads embedded fonts in its constructor so we have to handle IOExceptions
+     * from PDFont and translate them into validation errors.
+     */
+    protected void addFontError(COSDictionary dictionary, PreflightContext context, IOException
e)
+    {
+        COSName type = dictionary.getCOSName(COSName.TYPE, COSName.FONT);
+        if (!COSName.FONT.equals(type))
+        {
+            addValidationError(context, new ValidationError(PreflightConstants.ERROR_FONTS_UNKNOWN_FONT_TYPE,
"Expected 'Font' dictionary but found '" + type.getName() + "'"));
+        }
+        String fontName = "Unknown";
+        if (dictionary.containsKey(COSName.BASE_FONT))
+        {
+            fontName = dictionary.getNameAsString(COSName.BASE_FONT);
+        }
+        COSName subType = dictionary.getCOSName(COSName.SUBTYPE);
+        if (COSName.TYPE1.equals(subType))
+        {
+            addValidationError(context, new ValidationError(PreflightConstants.ERROR_FONTS_TYPE1_DAMAGED,
"The FontFile can't be read for " + fontName + ": " + e.getMessage()));
+        }
+        else if (COSName.MM_TYPE1.equals(subType))
+        {
+            addValidationError(context, new ValidationError(PreflightConstants.ERROR_FONTS_TYPE1_DAMAGED,
"The FontFile can't be read for " + fontName + ": " + e.getMessage()));
+        }
+        else if (COSName.TRUE_TYPE.equals(subType))
+        {
+            addValidationError(context, new ValidationError(PreflightConstants.ERROR_FONTS_TRUETYPE_DAMAGED,
"The FontFile can't be read for " + fontName + ": " + e.getMessage()));
+        }
+        else if (COSName.TYPE3.equals(subType))
+        {
+            addValidationError(context, new ValidationError(PreflightConstants.ERROR_FONTS_TYPE3_DAMAGED,
"The FontFile can't be read for " + fontName + ": " + e.getMessage()));
+        }
+        else if (COSName.TYPE0.equals(subType))
+        {
+            addValidationError(context, new ValidationError(PreflightConstants.ERROR_FONTS_CID_DAMAGED,
"The FontFile can't be read for " + fontName + ": " + e.getMessage()));
+        }
+        else if (COSName.CID_FONT_TYPE0.equals(subType))
+        {
+            addValidationError(context, new ValidationError(PreflightConstants.ERROR_FONTS_UNKNOWN_FONT_TYPE,
"Unexpected CIDFontType0 descendant font for " + fontName + ": " + e.getMessage()));
+        }
+        else if (COSName.CID_FONT_TYPE2.equals(subType))
+        {
+            addValidationError(context, new ValidationError(PreflightConstants.ERROR_FONTS_UNKNOWN_FONT_TYPE,
"Unexpected CIDFontType2 descendant font for " + fontName + ": " + e.getMessage()));
+        }
+        else
+        {
+            addValidationError(context, new ValidationError(PreflightConstants.ERROR_FONTS_UNKNOWN_FONT_TYPE,
"Unknown font type for " + fontName));
+        }
+    }
 }

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/ExtGStateValidationProcess.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/ExtGStateValidationProcess.java?rev=1696327&r1=1696326&r2=1696327&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/ExtGStateValidationProcess.java
(original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/ExtGStateValidationProcess.java
Mon Aug 17 18:48:06 2015
@@ -216,8 +216,7 @@ public class ExtGStateValidationProcess
             }
             catch (IOException e)
             {
-                //TODO find way to use addFontError from ResourcesValidationProcess
-                //addFontError((COSDictionary)fontDict, context);
+                addFontError((COSDictionary) fontDict, context, e);
             }
         }
 

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/ResourcesValidationProcess.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/ResourcesValidationProcess.java?rev=1696327&r1=1696326&r2=1696327&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/ResourcesValidationProcess.java
(original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/ResourcesValidationProcess.java
Mon Aug 17 18:48:06 2015
@@ -141,68 +141,6 @@ public class ResourcesValidationProcess
     }
 
     /**
-     * PDFont loads embedded fonts in its constructor so we have to handle IOExceptions
-     * from PDFont and translate them into validation errors.
-     */
-    private void addFontError(COSDictionary dictionary, PreflightContext context, IOException
e)
-    {
-        COSName type = dictionary.getCOSName(COSName.TYPE, COSName.FONT);
-        if (!COSName.FONT.equals(type))
-        {
-            addValidationError(context, new ValidationError(PreflightConstants.ERROR_FONTS_UNKNOWN_FONT_TYPE,
-                    "Expected 'Font' dictionary but found '" + type.getName() + "'"));
-        }
-
-        String fontName = "Unknown";
-        if (dictionary.containsKey(COSName.BASE_FONT))
-        {
-            fontName = dictionary.getNameAsString(COSName.BASE_FONT);
-        }
-
-        COSName subType = dictionary.getCOSName(COSName.SUBTYPE);
-        if (COSName.TYPE1.equals(subType))
-        {
-            addValidationError(context, new ValidationError(PreflightConstants.ERROR_FONTS_TYPE1_DAMAGED,
-                    "The FontFile can't be read for " + fontName + ": " + e.getMessage()));
-        }
-        else if (COSName.MM_TYPE1.equals(subType))
-        {
-            addValidationError(context, new ValidationError(PreflightConstants.ERROR_FONTS_TYPE1_DAMAGED,
-                    "The FontFile can't be read for " + fontName + ": " + e.getMessage()));
-        }
-        else if (COSName.TRUE_TYPE.equals(subType))
-        {
-            addValidationError(context, new ValidationError(PreflightConstants.ERROR_FONTS_TRUETYPE_DAMAGED,
-                                        "The FontFile can't be read for " + fontName + ":
" + e.getMessage()));
-        }
-        else if (COSName.TYPE3.equals(subType))
-        {
-            addValidationError(context, new ValidationError(PreflightConstants.ERROR_FONTS_TYPE3_DAMAGED,
-                    "The FontFile can't be read for " + fontName + ": " + e.getMessage()));
-        }
-        else if (COSName.TYPE0.equals(subType))
-        {
-            addValidationError(context, new ValidationError(PreflightConstants.ERROR_FONTS_CID_DAMAGED,
-                    "The FontFile can't be read for " + fontName + ": " + e.getMessage()));
-        }
-        else if (COSName.CID_FONT_TYPE0.equals(subType))
-        {
-            addValidationError(context, new ValidationError(PreflightConstants.ERROR_FONTS_UNKNOWN_FONT_TYPE,
-                    "Unexpected CIDFontType0 descendant font for " + fontName + ": " + e.getMessage()));
-        }
-        else if (COSName.CID_FONT_TYPE2.equals(subType))
-        {
-            addValidationError(context, new ValidationError(PreflightConstants.ERROR_FONTS_UNKNOWN_FONT_TYPE,
-                    "Unexpected CIDFontType2 descendant font for " + fontName + ": " + e.getMessage()));
-        }
-        else
-        {
-            addValidationError(context, new ValidationError(PreflightConstants.ERROR_FONTS_UNKNOWN_FONT_TYPE,
-                    "Unknown font type for " + fontName));
-        }
-    }
-
-    /**
      * 
      * @param context
      * @param resources



Mime
View raw message