You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2014/11/27 23:02:19 UTC
svn commit: r1642238 - in
/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font:
DescendantFontValidator.java TrueTypeFontValidator.java
Type0FontValidator.java Type3FontValidator.java
Author: tilman
Date: Thu Nov 27 22:02:19 2014
New Revision: 1642238
URL: http://svn.apache.org/r1642238
Log:
PDFBOX-1675: improve error messages
Modified:
pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/DescendantFontValidator.java
pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/TrueTypeFontValidator.java
pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type0FontValidator.java
pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type3FontValidator.java
Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/DescendantFontValidator.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/DescendantFontValidator.java?rev=1642238&r1=1642237&r2=1642238&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/DescendantFontValidator.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/DescendantFontValidator.java Thu Nov 27 22:02:19 2014
@@ -63,7 +63,8 @@ public abstract class DescendantFontVali
if (!arePresent)
{
- this.fontContainer.push(new ValidationError(ERROR_FONTS_DICTIONARY_INVALID, "Required keys are missing"));
+ this.fontContainer.push(new ValidationError(ERROR_FONTS_DICTIONARY_INVALID,
+ font.getName() + ": Required keys are missing"));
}
checkCIDSystemInfo(fontDictionary.getItem(COSName.CIDSYSTEMINFO));
Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/TrueTypeFontValidator.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/TrueTypeFontValidator.java?rev=1642238&r1=1642237&r2=1642238&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/TrueTypeFontValidator.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/TrueTypeFontValidator.java Thu Nov 27 22:02:19 2014
@@ -66,7 +66,7 @@ public class TrueTypeFontValidator exten
|| !(encodingValue instanceof MacRomanEncoding || encodingValue instanceof WinAnsiEncoding))
{
this.fontContainer.push(new ValidationError(ERROR_FONTS_ENCODING,
- "The Encoding is invalid for the NonSymbolic TTF"));
+ fd.getFontName() + ": The Encoding is invalid for the NonSymbolic TTF"));
}
}
@@ -77,7 +77,7 @@ public class TrueTypeFontValidator exten
if (fd.isSymbolic() && ((COSDictionary) fontDictionary).getItem(COSName.ENCODING) != null)
{
this.fontContainer.push(new ValidationError(ERROR_FONTS_ENCODING,
- "The Encoding should be missing for the Symbolic TTF"));
+ fd.getFontName() + ": The Encoding should be missing for the Symbolic TTF"));
}
}
}
Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type0FontValidator.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type0FontValidator.java?rev=1642238&r1=1642237&r2=1642238&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type0FontValidator.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type0FontValidator.java Thu Nov 27 22:02:19 2014
@@ -97,7 +97,7 @@ public class Type0FontValidator extends
if (!areFieldsPResent)
{
this.fontContainer.push(new ValidationError(ERROR_FONTS_DICTIONARY_INVALID,
- "Some keys are missing from composite font dictionary"));
+ font.getName() + ": Some keys are missing from composite font dictionary"));
}
}
@@ -117,7 +117,7 @@ public class Type0FontValidator extends
* returns an error if the array has more than one element.
*/
this.fontContainer.push(new ValidationError(ERROR_FONTS_CIDKEYED_INVALID,
- "CIDFont is missing from the DescendantFonts array or the size of array is greater than 1"));
+ font.getName() + ": CIDFont is missing from the DescendantFonts array or the size of array is greater than 1"));
return;
}
@@ -125,7 +125,7 @@ public class Type0FontValidator extends
if (cidFont == null)
{
this.fontContainer.push(new ValidationError(ERROR_FONTS_CIDKEYED_INVALID,
- "The DescendantFonts array should have one element with is a dictionary."));
+ font.getName() + ": The DescendantFonts array should have one element with is a dictionary."));
return;
}
@@ -152,7 +152,7 @@ public class Type0FontValidator extends
else
{
this.fontContainer.push(new ValidationError(ERROR_FONTS_DICTIONARY_INVALID,
- "Type and/or Subtype keys are missing"));
+ font.getName() + ": Type and/or Subtype keys are missing"));
}
return cidFontValidator;
}
@@ -168,7 +168,8 @@ public class Type0FontValidator extends
}
catch (IOException e)
{
- this.fontContainer.push(new ValidationError(ERROR_FONTS_CID_DAMAGED, "The CIDType0 font is damaged"));
+ this.fontContainer.push(new ValidationError(ERROR_FONTS_CID_DAMAGED,
+ font.getName() + ": The CIDType0 font is damaged", e));
return null;
}
}
@@ -184,7 +185,8 @@ public class Type0FontValidator extends
}
catch (IOException e)
{
- this.fontContainer.push(new ValidationError(ERROR_FONTS_CID_DAMAGED, "The CIDType2 font is damaged"));
+ this.fontContainer.push(new ValidationError(ERROR_FONTS_CID_DAMAGED,
+ font.getName() + ": The CIDType2 font is damaged", e));
return null;
}
}
@@ -211,7 +213,7 @@ public class Type0FontValidator extends
.equals(str)))
{
this.fontContainer.push(new ValidationError(ERROR_FONTS_CIDKEYED_INVALID,
- "The CMap is a string but it isn't an Identity-H/V"));
+ font.getName() + ": The CMap is a string but it isn't an Identity-H/V"));
return;
}
}
@@ -227,7 +229,7 @@ public class Type0FontValidator extends
{
// CMap type is invalid
this.fontContainer.push(new ValidationError(ERROR_FONTS_CIDKEYED_CMAP_INVALID_OR_MISSING,
- "The CMap type is invalid"));
+ font.getName() + ": The CMap type is invalid"));
}
}
@@ -264,22 +266,22 @@ public class Type0FontValidator extends
if (cmapName == null || "".equals(cmapName) || wmode > 1)
{
this.fontContainer.push(new ValidationError(ERROR_FONTS_CIDKEYED_CMAP_INVALID_OR_MISSING,
- "Some elements in the CMap dictionary are missing or invalid"));
+ font.getName() + ": Some elements in the CMap dictionary are missing or invalid"));
}
else if (!(wmValue == wmode && cmapName.equals(cmnValue)))
{
this.fontContainer.push(new ValidationError(ERROR_FONTS_CIDKEYED_CMAP_INVALID_OR_MISSING,
- "CMapName or WMode is inconsistent"));
+ font.getName() + ": CMapName or WMode is inconsistent"));
}
else if (!FONT_DICTIONARY_VALUE_TYPE_CMAP.equals(type))
{
this.fontContainer.push(new ValidationError(ERROR_FONTS_CIDKEYED_CMAP_INVALID_OR_MISSING,
- "The CMap type is invalid"));
+ font.getName() + ": The CMap type is invalid"));
}
}
catch (IOException e)
{
- this.fontContainer.push(new ValidationError(ERROR_FONTS_CID_CMAP_DAMAGED, "The CMap type is damaged"));
+ this.fontContainer.push(new ValidationError(ERROR_FONTS_CID_CMAP_DAMAGED, font.getName() + ": The CMap type is damaged", e));
}
COSDictionary cmapUsed = (COSDictionary) aCMap.getDictionaryObject(COSName
@@ -354,7 +356,7 @@ public class Type0FontValidator extends
if (!regCF.equals(regCM) || !ordCF.equals(ordCM))
{
this.fontContainer.push(new ValidationError(ERROR_FONTS_CIDKEYED_SYSINFO,
- "The CIDSystemInfo is inconsistent"));
+ font.getName() + ": The CIDSystemInfo is inconsistent"));
}
}
}
Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type3FontValidator.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type3FontValidator.java?rev=1642238&r1=1642237&r2=1642238&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type3FontValidator.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type3FontValidator.java Thu Nov 27 22:02:19 2014
@@ -98,7 +98,7 @@ public class Type3FontValidator extends
if (!areFieldsPResent)
{
this.fontContainer.push(new ValidationError(ERROR_FONTS_DICTIONARY_INVALID,
- "Some required fields are missing from the Font dictionary."));
+ font.getName() + ": Some required fields are missing from the Font dictionary."));
}
}
@@ -113,7 +113,7 @@ public class Type3FontValidator extends
if (!COSUtils.isArray(fontBBox, cosDocument))
{
this.fontContainer.push(new ValidationError(ERROR_FONTS_DICTIONARY_INVALID,
- "The FontBBox element isn't an array"));
+ font.getName() + ": The FontBBox element isn't an array"));
return;
}
@@ -124,7 +124,7 @@ public class Type3FontValidator extends
if (bbox.size() != 4)
{
this.fontContainer.push(new ValidationError(ERROR_FONTS_DICTIONARY_INVALID,
- "The FontBBox element is invalid"));
+ font.getName() + ": The FontBBox element is invalid"));
return;
}
@@ -134,7 +134,7 @@ public class Type3FontValidator extends
if (!(COSUtils.isFloat(elt, cosDocument) || COSUtils.isInteger(elt, cosDocument)))
{
this.fontContainer.push(new ValidationError(ERROR_FONTS_DICTIONARY_INVALID,
- "An element of FontBBox isn't a number"));
+ font.getName() + ": An element of FontBBox isn't a number"));
return;
}
}
@@ -150,7 +150,7 @@ public class Type3FontValidator extends
if (!COSUtils.isArray(fontMatrix, cosDocument))
{
this.fontContainer.push(new ValidationError(ERROR_FONTS_DICTIONARY_INVALID,
- "The FontMatrix element isn't an array"));
+ font.getName() + ": The FontMatrix element isn't an array"));
return;
}
@@ -161,7 +161,7 @@ public class Type3FontValidator extends
if (matrix.size() != 6)
{
this.fontContainer.push(new ValidationError(ERROR_FONTS_DICTIONARY_INVALID,
- "The FontMatrix element is invalid"));
+ font.getName() + ": The FontMatrix element is invalid"));
return;
}
@@ -171,7 +171,7 @@ public class Type3FontValidator extends
if (!(COSUtils.isFloat(elt, cosDocument) || COSUtils.isInteger(elt, cosDocument)))
{
this.fontContainer.push(new ValidationError(ERROR_FONTS_DICTIONARY_INVALID,
- "An element of FontMatrix isn't a number"));
+ font.getName() + ": An element of FontMatrix isn't a number"));
return;
}
}
@@ -211,7 +211,7 @@ public class Type3FontValidator extends
{
// the encoding entry is invalid
this.fontContainer.push(new ValidationError(ERROR_FONTS_TYPE3_DAMAGED,
- "The Encoding entry doesn't have the right type"));
+ font.getName() + ": The Encoding entry doesn't have the right type"));
}
}
@@ -259,7 +259,7 @@ public class Type3FontValidator extends
if (widths == null || widths.isEmpty())
{
this.fontContainer.push(new ValidationError(ERROR_FONTS_DICTIONARY_INVALID,
- "The Witdhs array is unreachable"));
+ font.getName() + ": The Witdhs array is unreachable"));
return;
}
@@ -267,7 +267,7 @@ public class Type3FontValidator extends
if (charProcs == null)
{
this.fontContainer.push(new ValidationError(ERROR_FONTS_DICTIONARY_INVALID,
- "The CharProcs element isn't a dictionary"));
+ font.getName() + ": The CharProcs element isn't a dictionary"));
return;
}
@@ -283,7 +283,7 @@ public class Type3FontValidator extends
if (widths.size() != expectedLength)
{
this.fontContainer.push(new ValidationError(ERROR_FONTS_DICTIONARY_INVALID,
- "The length of Witdhs array is invalid. Expected : \"" + expectedLength + "\" Current : \""
+ font.getName() + ": The length of Witdhs array is invalid. Expected : \"" + expectedLength + "\" Current : \""
+ widths.size() + "\""));
return;
}
@@ -308,7 +308,7 @@ public class Type3FontValidator extends
else
{
GlyphException glyphEx = new GlyphException(ERROR_FONTS_METRICS, code,
- "The character with CID\"" + code + "\" should have a width equals to " + width);
+ font.getName() + ": The character with CID\"" + code + "\" should have a width equals to " + width);
this.fontContainer.markAsInvalid(code, glyphEx);
}
}
@@ -323,7 +323,7 @@ public class Type3FontValidator extends
catch (IOException e)
{
this.fontContainer.push(new ValidationError(ERROR_FONTS_TYPE3_DAMAGED,
- "The CharProcs references an element which can't be read"));
+ font.getName() + ": The CharProcs references an element which can't be read", e));
return;
}
}
@@ -353,7 +353,7 @@ public class Type3FontValidator extends
// There are no character description, we declare the Glyph as Invalid. If the character
// is used in a Stream, the GlyphDetail will throw an exception.
GlyphException glyphEx = new GlyphException(ERROR_FONTS_METRICS, code,
- "The CharProcs \"" + font.getEncoding().getName(code) + "\" doesn't exist");
+ font.getName() + ": The CharProcs \"" + font.getEncoding().getName(code) + "\" doesn't exist");
this.fontContainer.markAsInvalid(code, glyphEx);
}
return charProc;
@@ -386,7 +386,7 @@ public class Type3FontValidator extends
if (dictionary == null)
{
this.fontContainer.push(new ValidationError(ERROR_FONTS_DICTIONARY_INVALID,
- "The Resources element isn't a dictionary"));
+ font.getName() + ": The Resources element isn't a dictionary"));
return;
}
@@ -415,13 +415,13 @@ public class Type3FontValidator extends
if (!aContainer.isValid())
{
this.fontContainer.push(new ValidationError(ERROR_FONTS_TYPE3_DAMAGED,
- "The Resources dictionary of type 3 font contains invalid font"));
+ font.getName() + ": The Resources dictionary of type 3 font contains invalid font"));
}
}
catch (IOException e)
{
context.addValidationError(new ValidationError(PreflightConstants.ERROR_FONTS_DAMAGED,
- "Unable to valid the Type3 : " + e.getMessage()));
+ font.getName() + ": Unable to valid the Type3 : " + e.getMessage(), e));
}
}
}