Update ZUGFeRDImporter.java
corrections for attachmentless pdfs, courtesy by Uwe Mock
This commit is contained in:
@@ -52,19 +52,20 @@ public class ZUGFeRDImporter {
|
|||||||
|
|
||||||
|
|
||||||
public void extract(String pdfFilename) {
|
public void extract(String pdfFilename) {
|
||||||
PDDocument doc;
|
PDDocument doc = null;
|
||||||
try {
|
try {
|
||||||
doc = PDDocument.load(pdfFilename);
|
doc = PDDocument.load(pdfFilename);
|
||||||
// PDDocumentInformation info = doc.getDocumentInformation();
|
// PDDocumentInformation info = doc.getDocumentInformation();
|
||||||
PDEmbeddedFilesNameTreeNode etn;
|
|
||||||
PDDocumentNameDictionary names = new PDDocumentNameDictionary(
|
PDDocumentNameDictionary names = new PDDocumentNameDictionary(
|
||||||
doc.getDocumentCatalog());
|
doc.getDocumentCatalog());
|
||||||
|
PDEmbeddedFilesNameTreeNode etn;
|
||||||
etn = names.getEmbeddedFiles();
|
etn = names.getEmbeddedFiles();
|
||||||
Map<String, COSObjectable> efMap = etn.getNames();
|
if (etn==null) {
|
||||||
// String filePath = "/tmp/";
|
doc.close();
|
||||||
if (efMap==null) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Map<String, COSObjectable> efMap = etn.getNames();
|
||||||
|
// String filePath = "/tmp/";
|
||||||
for (String filename : efMap.keySet()) {
|
for (String filename : efMap.keySet()) {
|
||||||
/**
|
/**
|
||||||
* currently (in the release candidate of version 1) only one
|
* currently (in the release candidate of version 1) only one
|
||||||
@@ -93,6 +94,13 @@ public class ZUGFeRDImporter {
|
|||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
|
try {
|
||||||
|
if(doc!=null) {
|
||||||
|
doc.close();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user