Merge pull request #16 from yankee42/zugferd-exporter-closeable

Make ZUGFeRDExporter closeable to avoid warning "You did not close a PDF Document"
This commit is contained in:
Jochen Staerk
2017-05-09 19:03:03 +02:00
committed by GitHub

View File

@@ -11,6 +11,7 @@ package org.mustangproject.ZUGFeRD;
*/ */
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@@ -62,7 +63,7 @@ import org.apache.xmpbox.type.BadFieldValueException;
import org.apache.xmpbox.xml.XmpSerializer; import org.apache.xmpbox.xml.XmpSerializer;
import org.mustangproject.ZUGFeRD.model.*; import org.mustangproject.ZUGFeRD.model.*;
public class ZUGFeRDExporter { public class ZUGFeRDExporter implements Closeable {
/** /**
* * You will need Apache PDFBox. To use the ZUGFeRD exporter, implement * * You will need Apache PDFBox. To use the ZUGFeRD exporter, implement
@@ -539,6 +540,12 @@ public class ZUGFeRDExporter {
return cat; return cat;
} }
public void close() throws IOException {
if (doc != null) {
doc.close();
}
}
private static final ObjectFactory xmlFactory = new ObjectFactory(); private static final ObjectFactory xmlFactory = new ObjectFactory();
private final JAXBContext jaxbContext; private final JAXBContext jaxbContext;
private final Marshaller marshaller; private final Marshaller marshaller;