Additional data amendments
This commit is contained in:
@@ -113,6 +113,9 @@ public class ZUGFeRDExporter implements Closeable {
|
|||||||
private PDDocument doc;
|
private PDDocument doc;
|
||||||
int ZFVersion;
|
int ZFVersion;
|
||||||
|
|
||||||
|
private HashMap<String,byte[]> additionalXMLs=new HashMap<String,byte[]>();
|
||||||
|
|
||||||
|
|
||||||
private boolean disableAutoClose;
|
private boolean disableAutoClose;
|
||||||
|
|
||||||
private boolean fileAttached = false;
|
private boolean fileAttached = false;
|
||||||
@@ -129,6 +132,10 @@ public class ZUGFeRDExporter implements Closeable {
|
|||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addAdditonalXML(String filename, byte[] xml) {
|
||||||
|
additionalXMLs.put(filename, xml);
|
||||||
|
}
|
||||||
|
|
||||||
public static String getNamespaceForVersion(int ver) {
|
public static String getNamespaceForVersion(int ver) {
|
||||||
if (ver == 1) {
|
if (ver == 1) {
|
||||||
return "urn:ferd:pdfa:CrossIndustryDocument:invoice:1p0#";
|
return "urn:ferd:pdfa:CrossIndustryDocument:invoice:1p0#";
|
||||||
@@ -340,6 +347,9 @@ public class ZUGFeRDExporter implements Closeable {
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
for (String filenameAdditional : additionalXMLs.keySet()) {
|
||||||
|
PDFAttachGenericFile(doc, filenameAdditional, "Supplement", "ZUGFeRD extension/additional data", "text/xml", additionalXMLs.get(filenameAdditional));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void export(String ZUGFeRDfilename) throws IOException {
|
public void export(String ZUGFeRDfilename) throws IOException {
|
||||||
@@ -459,6 +469,7 @@ public class ZUGFeRDExporter implements Closeable {
|
|||||||
cus.setXML(zugferdData);
|
cus.setXML(zugferdData);
|
||||||
this.xmlProvider = cus;
|
this.xmlProvider = cus;
|
||||||
PDFattachZugferdFile(null);
|
PDFattachZugferdFile(null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ import java.io.ByteArrayOutputStream;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
import javax.activation.DataSource;
|
import javax.activation.DataSource;
|
||||||
import javax.activation.FileDataSource;
|
import javax.activation.FileDataSource;
|
||||||
import org.apache.pdfbox.io.IOUtils;
|
import org.apache.pdfbox.io.IOUtils;
|
||||||
@@ -43,6 +45,9 @@ public class ZUGFeRDExporterFromA3Factory implements IExporterFactory {
|
|||||||
/** Creator tool (attribute for PDF) */
|
/** Creator tool (attribute for PDF) */
|
||||||
protected String creatorTool = null;
|
protected String creatorTool = null;
|
||||||
|
|
||||||
|
private HashMap<String,byte[]> additionalXMLs=new HashMap<String,byte[]>();
|
||||||
|
|
||||||
|
|
||||||
protected int ZFVersion=ZUGFeRDExporter.DefaultZUGFeRDVersion;
|
protected int ZFVersion=ZUGFeRDExporter.DefaultZUGFeRDVersion;
|
||||||
protected boolean ensurePDFisUpgraded=false;
|
protected boolean ensurePDFisUpgraded=false;
|
||||||
private boolean attachZUGFeRDHeaders=true;
|
private boolean attachZUGFeRDHeaders=true;
|
||||||
@@ -123,7 +128,7 @@ public class ZUGFeRDExporterFromA3Factory implements IExporterFactory {
|
|||||||
IOUtils.copy(in, buffer);
|
IOUtils.copy(in, buffer);
|
||||||
return buffer.toByteArray();
|
return buffer.toByteArray();
|
||||||
}
|
}
|
||||||
private static boolean isValidA1(DataSource dataSource) throws IOException {
|
private static boolean isValidA1(DataSource dataSource) throws IOException {
|
||||||
return getPDFAParserValidationResult(new PreflightParser(dataSource));
|
return getPDFAParserValidationResult(new PreflightParser(dataSource));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import java.io.ByteArrayInputStream;
|
|||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@@ -67,6 +68,7 @@ public class ZUGFeRDImporter {
|
|||||||
private String holder;
|
private String holder;
|
||||||
private String amount;
|
private String amount;
|
||||||
private String dueDate;
|
private String dueDate;
|
||||||
|
private HashMap<String,byte[]> additionalXMLs=new HashMap<String,byte[]>();
|
||||||
/** Raw XML form of the extracted data - may be directly obtained. */
|
/** Raw XML form of the extracted data - may be directly obtained. */
|
||||||
private byte[] rawXML = null;
|
private byte[] rawXML = null;
|
||||||
private String bankName;
|
private String bankName;
|
||||||
@@ -151,7 +153,6 @@ public class ZUGFeRDImporter {
|
|||||||
|
|
||||||
private void extractFiles(Map<String, PDComplexFileSpecification> names) throws IOException {
|
private void extractFiles(Map<String, PDComplexFileSpecification> names) throws IOException {
|
||||||
for (String filename : names.keySet()) {
|
for (String filename : names.keySet()) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* currently (in the release candidate of version 1) only one attached file with
|
* currently (in the release candidate of version 1) only one attached file with
|
||||||
* the name ZUGFeRD-invoice.xml is allowed
|
* the name ZUGFeRD-invoice.xml is allowed
|
||||||
@@ -174,9 +175,20 @@ public class ZUGFeRDImporter {
|
|||||||
// fos.write(embeddedFile.getByteArray());
|
// fos.write(embeddedFile.getByteArray());
|
||||||
// fos.close();
|
// fos.close();
|
||||||
}
|
}
|
||||||
|
if (filename.startsWith("additional_data")) {
|
||||||
|
|
||||||
|
PDComplexFileSpecification fileSpec = names.get(filename);
|
||||||
|
PDEmbeddedFile embeddedFile = fileSpec.getEmbeddedFile();
|
||||||
|
additionalXMLs.put(filename, embeddedFile.toByteArray());
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public HashMap<String, byte[]> getAdditionalData() {
|
||||||
|
return additionalXMLs;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* needs to be called to be able to call the getters
|
* needs to be called to be able to call the getters
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user