diff --git a/mustang/toecount/pom.xml b/mustang/toecount/pom.xml index 01a276b5..21fb77e9 100755 --- a/mustang/toecount/pom.xml +++ b/mustang/toecount/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.mustangproject.ZUGFeRD toecount - 0.0.6-SNAPSHOT + 0.0.7-SNAPSHOT ZUGFeRD PDF checker Shows statistics on how many PDFs in a directory are ZUGFeRD-Compliant diff --git a/mustang/toecount/src/main/java/toecount/FileChecker.java b/mustang/toecount/src/main/java/toecount/FileChecker.java index c1ad9d64..33fe0dc0 100755 --- a/mustang/toecount/src/main/java/toecount/FileChecker.java +++ b/mustang/toecount/src/main/java/toecount/FileChecker.java @@ -30,11 +30,34 @@ public class FileChecker { return false; } ZUGFeRDImporter zi=new ZUGFeRDImporter(); - zi.extract(filename); - if (zi.canParse()) { - thisRun.incZUGFeRDCount(); - return true; - } else { + try { + zi.extract(filename); + if (zi.canParse()) { + thisRun.incZUGFeRDCount(); + return true; + } else { + return false; + } + } catch (NullPointerException e) { + // something really rare happened -- corrupted ZF? + /*** + * e.g. Exception in thread "main" java.lang.NullPointerException + at org.mustangproject.ZUGFeRD.ZUGFeRDImporter.extractLowLevel(ZUGFeRDImporter.java:90) + at org.mustangproject.ZUGFeRD.ZUGFeRDImporter.extract(ZUGFeRDImporter.java:64) + at toecount.FileChecker.checkForZUGFeRD(FileChecker.java:33) + at toecount.Toecount.main(Toecount.java:111) + * + */ + // Ignore nevertheless, most likely we're batch processing + return false; + } catch (Exception e2) { + /** + * probably thrown up from + AM org.apache.pdfbox.pdfparser.PDFParser parse, most likely + INFORMATION: Document is encrypted + but also other internal PDF errors possible like + ..Okt 23, 2015 11:17:53 AM org.apache.pdfbox.pdfparser.XrefTrailerResolver setStartxref + */ return false; } } diff --git a/mustang/toecount/src/main/java/toecount/Toecount.java b/mustang/toecount/src/main/java/toecount/Toecount.java index 6c0c412e..50c8d2a4 100755 --- a/mustang/toecount/src/main/java/toecount/Toecount.java +++ b/mustang/toecount/src/main/java/toecount/Toecount.java @@ -22,7 +22,7 @@ public class Toecount { } private static void printHelp() { System.out - .println("Mustangproject.org's Toecount 0.0.6 \r\n" + .println("Mustangproject.org's Toecount 0.0.7 \r\n" + "A Apache Public License command line tool for statistics on PDF invoices with\r\n" + "ZUGFeRD Metadata (http://www.zugferd.de)\r\n" + "\r\n"