Update ZUGFeRDImporter.java

corrections for attachmentless pdfs, courtesy by Uwe Mock
This commit is contained in:
Jochen Staerk
2014-06-15 17:36:11 +02:00
parent 6d209be70a
commit 93bdab7132

View File

@@ -52,19 +52,20 @@ public class ZUGFeRDImporter {
public void extract(String pdfFilename) {
PDDocument doc;
PDDocument doc = null;
try {
doc = PDDocument.load(pdfFilename);
// PDDocumentInformation info = doc.getDocumentInformation();
PDEmbeddedFilesNameTreeNode etn;
PDDocumentNameDictionary names = new PDDocumentNameDictionary(
doc.getDocumentCatalog());
PDEmbeddedFilesNameTreeNode etn;
etn = names.getEmbeddedFiles();
Map<String, COSObjectable> efMap = etn.getNames();
// String filePath = "/tmp/";
if (efMap==null) {
if (etn==null) {
doc.close();
return;
}
Map<String, COSObjectable> efMap = etn.getNames();
// String filePath = "/tmp/";
for (String filename : efMap.keySet()) {
/**
* currently (in the release candidate of version 1) only one
@@ -93,6 +94,13 @@ public class ZUGFeRDImporter {
// TODO Auto-generated catch block
e1.printStackTrace();
}
finally {
try {
if(doc!=null) {
doc.close();
}
} catch (IOException e) {}
}
}