closes #39
This commit is contained in:
@@ -75,6 +75,8 @@ public class ZUGFeRDExporter implements Closeable {
|
||||
|
||||
private boolean disableAutoClose;
|
||||
|
||||
private boolean fileAttached=false;
|
||||
|
||||
public ZUGFeRDExporter() {
|
||||
init();
|
||||
}
|
||||
@@ -274,7 +276,6 @@ public class ZUGFeRDExporter implements Closeable {
|
||||
* <code>setZUGFeRDXMLData(byte[] zugferdData)</code>
|
||||
*/
|
||||
public void PDFattachZugferdFile(IZUGFeRDExportableTransaction trans) throws IOException {
|
||||
|
||||
xmlProvider.generateXML(trans);
|
||||
String filename = getFilenameForVersion(ZFVersion);
|
||||
PDFAttachGenericFile(doc, filename, "Alternative",
|
||||
@@ -283,6 +284,9 @@ public class ZUGFeRDExporter implements Closeable {
|
||||
}
|
||||
|
||||
public void export(String ZUGFeRDfilename) throws IOException {
|
||||
if (!fileAttached) {
|
||||
throw new IOException("File must be attached (usually with PDFattachZugferdFile) before perfoming this operation");
|
||||
}
|
||||
doc.save(ZUGFeRDfilename);
|
||||
if (!disableAutoClose) {
|
||||
close();
|
||||
@@ -290,6 +294,9 @@ public class ZUGFeRDExporter implements Closeable {
|
||||
}
|
||||
|
||||
public void export(OutputStream output) throws IOException {
|
||||
if (!fileAttached) {
|
||||
throw new IOException("File must be attached (usually with PDFattachZugferdFile) before perfoming this operation");
|
||||
}
|
||||
doc.save(output);
|
||||
if (!disableAutoClose) {
|
||||
close();
|
||||
@@ -316,6 +323,8 @@ public class ZUGFeRDExporter implements Closeable {
|
||||
*/
|
||||
public void PDFAttachGenericFile(PDDocument doc, String filename, String relationship, String description,
|
||||
String subType, byte[] data) throws IOException {
|
||||
fileAttached=true;
|
||||
|
||||
PDComplexFileSpecification fs = new PDComplexFileSpecification();
|
||||
fs.setFile(filename);
|
||||
|
||||
|
||||
@@ -183,8 +183,7 @@ public class MustangReaderWriterCustomXMLTest extends TestCase {
|
||||
+ "</ram:SpecifiedTradeProduct>\n" + "</ram:IncludedSupplyChainTradeLineItem>\n"
|
||||
+ "</rsm:SpecifiedSupplyChainTradeTransaction>\n" + "</rsm:CrossIndustryDocument>";
|
||||
zea1.setZUGFeRDXMLData(ownZUGFeRDXML.getBytes("UTF-8"));
|
||||
zea1.PDFattachZugferdFile(null);
|
||||
|
||||
|
||||
ByteArrayOutputStream baos=new ByteArrayOutputStream();
|
||||
zea1.disableAutoClose(true);
|
||||
zea1.export(TARGET_PDF);
|
||||
|
||||
@@ -412,7 +412,7 @@ public class MustangReaderWriterEdgeTest extends TestCase implements IZUGFeRDExp
|
||||
ze.setZUGFeRDVersion(1);
|
||||
ze.PDFattachZugferdFile(this);
|
||||
String theXML=new String(ze.getProvider().getXML());
|
||||
//assertTrue(theXML.contains("<rsm:CrossIndustryDocument"));
|
||||
assertTrue(theXML.contains("<rsm:CrossIndustryDocument"));
|
||||
ze.export(TARGET_PDF);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user