This commit is contained in:
Jochen Stärk
2017-11-19 18:29:27 +01:00
parent a2a7a85f05
commit d8a3e5d4f6
3 changed files with 12 additions and 4 deletions

View File

@@ -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);

View File

@@ -183,7 +183,6 @@ 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);

View File

@@ -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);
}