You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by le...@apache.org on 2012/03/17 11:41:16 UTC

svn commit: r1301914 [1/3] - in /pdfbox/trunk: preflight/src/main/java/org/apache/padaf/preflight/contentstream/ preflight/src/main/java/org/apache/padaf/preflight/font/ preflight/src/main/java/org/apache/padaf/preflight/utils/ xmpbox/src/main/java/org...

Author: leleueri
Date: Sat Mar 17 10:41:15 2012
New Revision: 1301914

URL: http://svn.apache.org/viewvc?rev=1301914&view=rev
Log:
[PDFBOX-1245 & PDFBOX-1251]
- Ignore the FontName comparison (it is a recommendation of the PDFReference, not a requirement of the PDF/A specification)
- Fix a cast problem to check the RenderingIntent
- Manage an additional format to describe a complexType in a PDFAExtensionSchema

[PDFBOX-1236]
- Use PDFBOX-1253 to fix this issue

Modified:
    pdfbox/trunk/preflight/src/main/java/org/apache/padaf/preflight/contentstream/ContentStreamWrapper.java
    pdfbox/trunk/preflight/src/main/java/org/apache/padaf/preflight/font/CompositeFontValidator.java
    pdfbox/trunk/preflight/src/main/java/org/apache/padaf/preflight/font/Type1FontValidator.java
    pdfbox/trunk/preflight/src/main/java/org/apache/padaf/preflight/utils/ContentStreamEngine.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/parser/XMPDocumentBuilder.java
    pdfbox/trunk/xmpbox/src/main/java/org/apache/padaf/xmpbox/type/ComplexPropertyContainer.java
    pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/ComplexMetadataPropertyTest.java

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/padaf/preflight/contentstream/ContentStreamWrapper.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/padaf/preflight/contentstream/ContentStreamWrapper.java?rev=1301914&r1=1301913&r2=1301914&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/padaf/preflight/contentstream/ContentStreamWrapper.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/padaf/preflight/contentstream/ContentStreamWrapper.java Sat Mar 17 10:41:15 2012
@@ -332,28 +332,19 @@ public class ContentStreamWrapper extend
 
 		int codeLength = 1;
 		for (int i = 0; i < string.length; i += codeLength) {
-			// Decode the value to a Unicode character
+			int cid = -1; 
 			codeLength = 1;
-			String c = null;
 			try {
-				c = font.encode(string, i, codeLength);
-				if (c == null && i + 1 < string.length) {
+				cid = font.encodeToCID(string, i, codeLength);
+				if (cid == -1 && i + 1 < string.length) {
 					// maybe a multibyte encoding
 					codeLength++;
-					c = font.encode(string, i, codeLength);
+					cid = font.encodeToCID(string, i, codeLength);
 				}
 			} catch (IOException e) {
 				throwContentStreamException("Encoding can't interpret the character code", ERROR_FONTS_ENCODING_ERROR);
 			}
 
-			// ---- According to the length of the character encoding,
-			// convert the character to CID
-			int cid = 0;
-			for (int j = 0; j < codeLength; j++) {
-				cid <<= 8;
-				cid += ((string[i + j] + 256) % 256);
-			}
-
 			try {
 				fontContainer.checkCID(cid);
 			} catch (GlyphException e) {

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/padaf/preflight/font/CompositeFontValidator.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/padaf/preflight/font/CompositeFontValidator.java?rev=1301914&r1=1301913&r2=1301914&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/padaf/preflight/font/CompositeFontValidator.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/padaf/preflight/font/CompositeFontValidator.java Sat Mar 17 10:41:15 2012
@@ -541,7 +541,7 @@ public class CompositeFontValidator exte
 		PDFontDescriptorDictionary pfDescriptor = new PDFontDescriptorDictionary(
 				fontDescDic);
 		boolean isValid = checkFontDescriptorMandatoryFields(pfDescriptor);
-		isValid = isValid && checkCIDKeyedFontName(pfDescriptor, true);
+		isValid = isValid && checkCIDKeyedFontName(pfDescriptor);
 		isValid = isValid && checkFontFileElement_CIDFontType0(pfDescriptor);
 		isValid = isValid && checkCIDSet(pfDescriptor);
 		return isValid;
@@ -557,32 +557,16 @@ public class CompositeFontValidator exte
 	 * 
 	 * @param pfDescriptor
 	 *          The FontDescriptor dictionary which contains the FontName to check
-	 * @param checkConsistency
-	 *          true if the font name must be consistent with the BaseName of the
-	 *          Font dictionary
 	 * @return
 	 */
-	protected boolean checkCIDKeyedFontName(
-			PDFontDescriptorDictionary pfDescriptor, boolean checkConsistency) {
+	protected boolean checkCIDKeyedFontName(PDFontDescriptorDictionary pfDescriptor) {
 		String fontName = pfDescriptor.getFontName();
-		String baseName = this.pFont.getBaseFont();
-
 		if (fontName == null) {
 			this.fontContainer.addError(new ValidationResult.ValidationError(
 					ERROR_FONTS_DESCRIPTOR_INVALID,
 					"The FontName in font descriptor is missing"));
 			return false;
 		}
-
-		if (checkConsistency
-				&& !(fontName.equals(baseName) || fontName.contains(baseName) || baseName
-						.contains(fontName))) {
-			this.fontContainer
-			.addError(new ValidationResult.ValidationError(
-					ERROR_FONTS_DESCRIPTOR_INVALID,
-					"The FontName in font descriptor isn't the same as the BaseFont in the Font dictionary"));
-			return false;
-		}
 		return true;
 	}
 
@@ -794,7 +778,7 @@ public class CompositeFontValidator exte
 		PDFontDescriptorDictionary pfDescriptor = new PDFontDescriptorDictionary(
 				fontDescDic);
 		boolean isValid = checkFontDescriptorMandatoryFields(pfDescriptor);
-		isValid = isValid && checkCIDKeyedFontName(pfDescriptor, false);
+		isValid = isValid && checkCIDKeyedFontName(pfDescriptor);
 		isValid = isValid && checkFontFileElement_CIDFontType2(pfDescriptor);
 		isValid = isValid && checkCIDSet(pfDescriptor);
 		return isValid;

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/padaf/preflight/font/Type1FontValidator.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/padaf/preflight/font/Type1FontValidator.java?rev=1301914&r1=1301913&r2=1301914&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/padaf/preflight/font/Type1FontValidator.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/padaf/preflight/font/Type1FontValidator.java Sat Mar 17 10:41:15 2012
@@ -133,13 +133,9 @@ public class Type1FontValidator extends 
 	 */
 	boolean checkFontName() {
 		String fontName = this.pFontDesc.getFontName();
-		String baseName = this.pFont.getBaseFont();
-
-		// For a Type1 Font, the FontName is the same as the BaseName.
-		if (fontName == null || (!fontName.equals(baseName))) {
+		if (fontName == null) {
 			this.fontContainer
-			.addError(new ValidationResult.ValidationError(
-					ERROR_FONTS_DESCRIPTOR_INVALID,
+			.addError(new ValidationResult.ValidationError(ERROR_FONTS_DESCRIPTOR_INVALID,
 			"The FontName in font descriptor isn't the same as the BaseFont in the Font dictionary"));
 			return false;
 		}

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/padaf/preflight/utils/ContentStreamEngine.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/padaf/preflight/utils/ContentStreamEngine.java?rev=1301914&r1=1301913&r2=1301914&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/padaf/preflight/utils/ContentStreamEngine.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/padaf/preflight/utils/ContentStreamEngine.java Sat Mar 17 10:41:15 2012
@@ -229,7 +229,14 @@ public abstract class ContentStreamEngin
 	protected void validRenderingIntent(PDFOperator operator, List arguments)
 			throws ContentStreamException {
 		if ("ri".equals(operator.getOperation())) {
-			if (!RenderingIntents.contains(arguments.get(0))) {
+			String riArgument0 = "";
+			if (arguments.get(0) instanceof COSName) {
+				riArgument0 = ((COSName)arguments.get(0)).getName();
+			} else if (arguments.get(0) instanceof String) {
+				riArgument0 = (String)arguments.get(0);
+			}
+
+			if (!RenderingIntents.contains(riArgument0)) {
 				throwContentStreamException("Unexpected value '" + arguments.get(0)
 						+ "' for ri operand. ", ERROR_GRAPHIC_UNEXPECTED_VALUE_FOR_KEY);
 			}