Return-Path: X-Original-To: apmail-pdfbox-commits-archive@www.apache.org Delivered-To: apmail-pdfbox-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C5F0D109D2 for ; Tue, 25 Nov 2014 16:42:16 +0000 (UTC) Received: (qmail 31740 invoked by uid 500); 25 Nov 2014 16:42:16 -0000 Delivered-To: apmail-pdfbox-commits-archive@pdfbox.apache.org Received: (qmail 31722 invoked by uid 500); 25 Nov 2014 16:42:16 -0000 Mailing-List: contact commits-help@pdfbox.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@pdfbox.apache.org Delivered-To: mailing list commits@pdfbox.apache.org Received: (qmail 31713 invoked by uid 99); 25 Nov 2014 16:42:16 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Nov 2014 16:42:16 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Nov 2014 16:41:52 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id E907F2388A74; Tue, 25 Nov 2014 16:41:49 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1641649 - in /pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font: container/ descriptor/ Date: Tue, 25 Nov 2014 16:41:49 -0000 To: commits@pdfbox.apache.org From: tilman@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20141125164149.E907F2388A74@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tilman Date: Tue Nov 25 16:41:49 2014 New Revision: 1641649 URL: http://svn.apache.org/r1641649 Log: PDFBOX-2517: improve error messages Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/container/Type0Container.java pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/descriptor/CIDType0DescriptorHelper.java pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/descriptor/CIDType2DescriptorHelper.java pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/descriptor/FontDescriptorHelper.java pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/descriptor/TrueTypeDescriptorHelper.java pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/descriptor/Type1DescriptorHelper.java Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/container/Type0Container.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/container/Type0Container.java?rev=1641649&r1=1641648&r2=1641649&view=diff ============================================================================== --- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/container/Type0Container.java (original) +++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/container/Type0Container.java Tue Nov 25 16:41:49 2014 @@ -41,6 +41,7 @@ public class Type0Container extends Font this.delegateFontContainer = delegateFontContainer; } + @Override public List getAllErrors() { if (this.delegateFontContainer != null) @@ -50,6 +51,7 @@ public class Type0Container extends Font return this.errorBuffer; } + @Override public boolean isValid() { boolean result = (this.errorBuffer.isEmpty() && isEmbeddedFont()); @@ -60,6 +62,7 @@ public class Type0Container extends Font return result; } + @Override public boolean isEmbeddedFont() { boolean result = embeddedFont; Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/descriptor/CIDType0DescriptorHelper.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/descriptor/CIDType0DescriptorHelper.java?rev=1641649&r1=1641648&r2=1641649&view=diff ============================================================================== --- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/descriptor/CIDType0DescriptorHelper.java (original) +++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/descriptor/CIDType0DescriptorHelper.java Tue Nov 25 16:41:49 2014 @@ -28,11 +28,6 @@ import static org.apache.pdfbox.prefligh import static org.apache.pdfbox.preflight.PreflightConstants.FONT_DICTIONARY_VALUE_TYPE0C; import static org.apache.pdfbox.preflight.PreflightConstants.FONT_DICTIONARY_VALUE_TYPE1C; -import java.io.IOException; -import java.util.List; - -import org.apache.fontbox.cff.CFFFont; -import org.apache.fontbox.cff.CFFParser; import org.apache.pdfbox.cos.COSBase; import org.apache.pdfbox.cos.COSDocument; import org.apache.pdfbox.cos.COSName; @@ -64,8 +59,8 @@ public class CIDType0DescriptorHelper ex COSStream stream = ff3.getStream(); if (stream == null) { - this.fContainer.push(new ValidationError(ERROR_FONTS_FONT_FILEX_INVALID, "The FontFile is missing for " - + fontDescriptor.getFontName())); + this.fContainer.push(new ValidationError(ERROR_FONTS_FONT_FILEX_INVALID, + fontDescriptor.getFontName() + ": The FontFile is missing")); this.fContainer.notEmbedded(); } else @@ -76,7 +71,8 @@ public class CIDType0DescriptorHelper ex if (!(FONT_DICTIONARY_VALUE_TYPE0C.equals(st) || FONT_DICTIONARY_VALUE_TYPE1C.equals(st))) { this.fContainer.push(new ValidationError(ERROR_FONTS_FONT_FILEX_INVALID, - "The FontFile3 stream doesn't have the right Subtype for " + fontDescriptor.getFontName())); + fontDescriptor.getFontName() + + ": The FontFile3 stream doesn't have the right Subtype")); } checkCIDSet(fontDescriptor); @@ -110,7 +106,9 @@ public class CIDType0DescriptorHelper ex { if (font.isDamaged()) { - this.fContainer.push(new ValidationError(ERROR_FONTS_CID_DAMAGED, "The FontFile can't be read")); + this.fContainer.push(new ValidationError(ERROR_FONTS_CID_DAMAGED, + font.getName() + ": The FontFile can't be read")); + } } } Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/descriptor/CIDType2DescriptorHelper.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/descriptor/CIDType2DescriptorHelper.java?rev=1641649&r1=1641648&r2=1641649&view=diff ============================================================================== --- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/descriptor/CIDType2DescriptorHelper.java (original) +++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/descriptor/CIDType2DescriptorHelper.java Tue Nov 25 16:41:49 2014 @@ -78,8 +78,8 @@ public class CIDType2DescriptorHelper ex COSStream stream = ff2.getStream(); if (stream == null) { - this.fContainer.push(new ValidationError(ERROR_FONTS_FONT_FILEX_INVALID, "The FontFile is missing for " - + fontDescriptor.getFontName())); + this.fContainer.push(new ValidationError(ERROR_FONTS_FONT_FILEX_INVALID, + fontDescriptor.getFontName() + ": The FontFile is missing")); this.fContainer.notEmbedded(); } } @@ -92,7 +92,8 @@ public class CIDType2DescriptorHelper ex { if (font.isDamaged()) { - this.fContainer.push(new ValidationError(ERROR_FONTS_CID_DAMAGED, "The FontFile can't be read")); + this.fContainer.push(new ValidationError(ERROR_FONTS_CID_DAMAGED, + font.getName() + ": The FontFile can't be read")); } } } Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/descriptor/FontDescriptorHelper.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/descriptor/FontDescriptorHelper.java?rev=1641649&r1=1641648&r2=1641649&view=diff ============================================================================== --- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/descriptor/FontDescriptorHelper.java (original) +++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/descriptor/FontDescriptorHelper.java Tue Nov 25 16:41:49 2014 @@ -124,7 +124,7 @@ public abstract class FontDescriptorHelp else { this.fContainer.push(new ValidationError(ERROR_FONTS_DESCRIPTOR_INVALID, - "FontDescriptor is null or is an AFM Descriptor")); + this.font.getName() + ": FontDescriptor is null or is an AFM Descriptor")); this.fContainer.notEmbedded(); } } @@ -244,7 +244,7 @@ public abstract class FontDescriptorHelp if (metadata.getFilters() != null && !metadata.getFilters().isEmpty()) { this.fContainer.push(new ValidationError(ERROR_SYNTAX_STREAM_INVALID_FILTER, - "Filter specified in font file metadata dictionnary")); + this.font.getName() + ": Filter specified in font file metadata dictionnary")); return; } @@ -267,16 +267,16 @@ public abstract class FontDescriptorHelp { if (e.getErrorType() == ErrorType.NoValueType) { - this.fContainer.push(new ValidationError(ERROR_METADATA_UNKNOWN_VALUETYPE, e.getMessage())); + this.fContainer.push(new ValidationError(ERROR_METADATA_UNKNOWN_VALUETYPE, e.getMessage(), e)); } else if (e.getErrorType() == ErrorType.XpacketBadEnd) { this.fContainer.push(new ValidationError(ERROR_METADATA_FORMAT_XPACKET, - "Unable to parse font metadata due to : " + e.getMessage())); + this.font.getName() + ": Unable to parse font metadata due to : " + e.getMessage(), e)); } else { - this.fContainer.push(new ValidationError(ERROR_METADATA_FORMAT, e.getMessage())); + this.fContainer.push(new ValidationError(ERROR_METADATA_FORMAT, e.getMessage(), e)); } } } @@ -284,7 +284,7 @@ public abstract class FontDescriptorHelp catch (IllegalStateException e) { this.fContainer.push(new ValidationError(ERROR_METADATA_FORMAT_UNKOWN, - "The Metadata entry doesn't reference a stream object")); + this.font.getName() + ": The Metadata entry doesn't reference a stream object", e)); } } @@ -303,7 +303,7 @@ public abstract class FontDescriptorHelp catch (IOException e) { this.fContainer.push(new ValidationError(ERROR_METADATA_FORMAT_STREAM, - "Unable to read font metadata due to : " + e.getMessage())); + this.font.getName() + ": Unable to read font metadata due to : " + e.getMessage(), e)); } finally { Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/descriptor/TrueTypeDescriptorHelper.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/descriptor/TrueTypeDescriptorHelper.java?rev=1641649&r1=1641648&r2=1641649&view=diff ============================================================================== --- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/descriptor/TrueTypeDescriptorHelper.java (original) +++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/descriptor/TrueTypeDescriptorHelper.java Tue Nov 25 16:41:49 2014 @@ -25,16 +25,12 @@ import static org.apache.pdfbox.prefligh import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_FONTS_FONT_FILEX_INVALID; import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_FONTS_TRUETYPE_DAMAGED; -import java.io.ByteArrayInputStream; import java.io.IOException; -import org.apache.commons.io.IOUtils; -import org.apache.fontbox.ttf.TTFParser; import org.apache.fontbox.ttf.TrueTypeFont; import org.apache.pdfbox.cos.COSName; import org.apache.pdfbox.cos.COSStream; import org.apache.pdfbox.pdmodel.common.PDStream; -import org.apache.pdfbox.pdmodel.font.PDFont; import org.apache.pdfbox.pdmodel.font.PDFontDescriptor; import org.apache.pdfbox.pdmodel.font.PDTrueTypeFont; import org.apache.pdfbox.preflight.PreflightContext; @@ -58,8 +54,8 @@ public class TrueTypeDescriptorHelper ex COSStream stream = (fontFile == null ? null : fontFile.getStream()); if (stream == null) { - this.fContainer.push(new ValidationError(ERROR_FONTS_FONT_FILEX_INVALID, "The FontFile2 is missing for " - + fontDescriptor.getFontName())); + this.fContainer.push(new ValidationError(ERROR_FONTS_FONT_FILEX_INVALID, + fontDescriptor.getFontName() + ": The FontFile2 is missing")); this.fContainer.notEmbedded(); return null; } @@ -67,7 +63,7 @@ public class TrueTypeDescriptorHelper ex if (stream.getInt(COSName.LENGTH1) <= 0) { this.fContainer.push(new ValidationError(ERROR_FONTS_FONT_FILEX_INVALID, - "The FontFile entry /Length1 is invalid for " + fontDescriptor.getFontName())); + fontDescriptor.getFontName() + ": The FontFile entry /Length1 is invalid")); return null; } @@ -80,7 +76,7 @@ public class TrueTypeDescriptorHelper ex if (font.isDamaged()) { this.fContainer.push(new ValidationError(ERROR_FONTS_TRUETYPE_DAMAGED, - "The FontFile can't be read for " + this.font.getName())); + this.font.getName() + ": The FontFile can't be read")); } else { @@ -91,14 +87,13 @@ public class TrueTypeDescriptorHelper ex if (pdTrueTypeFont.isSymbolic() && ttf.getCmap().getCmaps().length != 1) { this.fContainer.push(new ValidationError(ERROR_FONTS_ENCODING, - "Symbolic TrueType font has more than one 'cmap' entry for " + - this.font.getName())); + this.font.getName() + ": Symbolic TrueType font has more than one 'cmap' entry")); } } catch (IOException e) { this.fContainer.push(new ValidationError(ERROR_FONTS_TRUETYPE_DAMAGED, - "The TTF 'cmap' could not be read for " + this.font.getName())); + this.font.getName() + ": The TTF 'cmap' could not be read")); } } } Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/descriptor/Type1DescriptorHelper.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/descriptor/Type1DescriptorHelper.java?rev=1641649&r1=1641648&r2=1641649&view=diff ============================================================================== --- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/descriptor/Type1DescriptorHelper.java (original) +++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/font/descriptor/Type1DescriptorHelper.java Tue Nov 25 16:41:49 2014 @@ -58,7 +58,8 @@ public class Type1DescriptorHelper exten if (charsetStr == null || "".equals(charsetStr)) { this.fContainer.push(new ValidationError(ERROR_FONTS_CHARSET_MISSING_FOR_SUBSET, - "The Charset entry is missing for the Type1 Subset")); + fontDescriptor.getFontName() + + ": The Charset entry is missing for the Type1 Subset")); result = false; } } @@ -76,8 +77,8 @@ public class Type1DescriptorHelper exten COSStream stream = ff1.getStream(); if (stream == null) { - this.fContainer.push(new ValidationError(ERROR_FONTS_FONT_FILEX_INVALID, "The FontFile is missing for " - + fontDescriptor.getFontName())); + this.fContainer.push(new ValidationError(ERROR_FONTS_FONT_FILEX_INVALID, + fontDescriptor.getFontName() + ": The FontFile is missing")); this.fContainer.notEmbedded(); return null; } @@ -87,8 +88,8 @@ public class Type1DescriptorHelper exten boolean hasLength3 = stream.getInt(COSName.getPDFName(FONT_DICTIONARY_KEY_LENGTH3)) >= 0; if (!(hasLength1 && hasLength2 && hasLength3)) { - this.fContainer.push(new ValidationError(ERROR_FONTS_FONT_FILEX_INVALID, "The FontFile is invalid for " - + fontDescriptor.getFontName())); + this.fContainer.push(new ValidationError(ERROR_FONTS_FONT_FILEX_INVALID, + fontDescriptor.getFontName() + ": The FontFile is invalid")); return null; } @@ -106,7 +107,7 @@ public class Type1DescriptorHelper exten if (font.isDamaged()) { this.fContainer.push(new ValidationError(ERROR_FONTS_TYPE1_DAMAGED, - "The FontFile can't be read for " + this.font.getName())); + this.font.getName() + ": The FontFile can't be read")); } } }