pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From leleu...@apache.org
Subject svn commit: r1376200 - /pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/SinglePageValidationProcess.java
Date Wed, 22 Aug 2012 19:18:03 GMT
Author: leleueri
Date: Wed Aug 22 19:18:03 2012
New Revision: 1376200

URL: http://svn.apache.org/viewvc?rev=1376200&view=rev
Log:
[PDFBOX-1395] - Transparency isn't checked in Page dictionary

Modified:
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/SinglePageValidationProcess.java

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/SinglePageValidationProcess.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/SinglePageValidationProcess.java?rev=1376200&r1=1376199&r2=1376200&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/SinglePageValidationProcess.java
(original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/SinglePageValidationProcess.java
Wed Aug 22 19:18:03 2012
@@ -27,8 +27,11 @@ import static org.apache.pdfbox.prefligh
 import static org.apache.pdfbox.preflight.PreflightConfiguration.GRAPHIC_PROCESS;
 import static org.apache.pdfbox.preflight.PreflightConfiguration.RESOURCES_PROCESS;
 import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_GRAPHIC_INVALID;
+import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_GRAPHIC_TRANSPARENCY_GROUP;
 import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_UNKOWN_ERROR;
 import static org.apache.pdfbox.preflight.PreflightConstants.PAGE_DICTIONARY_VALUE_THUMB;
+import static org.apache.pdfbox.preflight.PreflightConstants.XOBJECT_DICTIONARY_KEY_GROUP;
+import static org.apache.pdfbox.preflight.PreflightConstants.XOBJECT_DICTIONARY_VALUE_S_TRANSPARENCY;
 
 import java.io.IOException;
 import java.util.List;
@@ -36,6 +39,7 @@ import java.util.Map;
 
 import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSDictionary;
+import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.cos.COSObject;
 import org.apache.pdfbox.pdmodel.PDPage;
 import org.apache.pdfbox.pdmodel.PDResources;
@@ -53,6 +57,7 @@ import org.apache.pdfbox.preflight.graph
 import org.apache.pdfbox.preflight.graphic.ColorSpaceHelperFactory;
 import org.apache.pdfbox.preflight.graphic.ColorSpaceHelperFactory.ColorSpaceRestriction;
 import org.apache.pdfbox.preflight.process.AbstractProcess;
+import org.apache.pdfbox.preflight.utils.COSUtils;
 import org.apache.pdfbox.preflight.utils.ContextHelper;
 
 public class SinglePageValidationProcess extends AbstractProcess {
@@ -70,7 +75,7 @@ public class SinglePageValidationProcess
 		validateColorSpaces(context, page);
 		validateResources(context, page);
 		validateGraphicObjects(context, page);
-
+		validateGroupTransparency(context, page);
 		// TODO
 		// add MetaData validation ?
 
@@ -177,4 +182,24 @@ public class SinglePageValidationProcess
 			throw new ValidationException("Unable to access Annotation", e);
 		}
 	}
+	
+	/**
+	 * Check that the group dictionary doesn't have a Transparency attribute
+	 * 
+	 * @param context
+	 * @param page
+	 * @throws ValidationException
+	 */
+	protected void validateGroupTransparency(PreflightContext context, PDPage page) throws ValidationException
{
+		COSBase baseGroup = page.getCOSDictionary().getItem(XOBJECT_DICTIONARY_KEY_GROUP);
+		COSDictionary groupDictionary = COSUtils.getAsDictionary(baseGroup, context.getDocument().getDocument());
+		if (groupDictionary != null) {
+			String sVal = groupDictionary.getNameAsString(COSName.S);
+			if (XOBJECT_DICTIONARY_VALUE_S_TRANSPARENCY.equals(sVal)) {
+				context.addValidationError(new ValidationError(ERROR_GRAPHIC_TRANSPARENCY_GROUP , "Group
has a transparency S entry or the S entry is null."));
+				return;
+			}
+		}
+	}
+
 }



Mime
View raw message