updated filename, PDF/A schema extension for ZF2
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<groupId>org.mustangproject.ZUGFeRD</groupId>
|
||||
<artifactId>mustang</artifactId>
|
||||
<name>Mustang</name>
|
||||
<version>1.4.1-SNAPSHOT</version>
|
||||
<version>1.4.2-SNAPSHOT</version>
|
||||
<description>The Mustang project is a java library to read and write ZUGFeRD meta data inside your invoice PDFs</description>
|
||||
<url>http://www.mustangproject.org/</url>
|
||||
<mailingLists>
|
||||
|
||||
2
pom.xml
2
pom.xml
@@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.mustangproject.ZUGFeRD</groupId>
|
||||
<artifactId>mustang</artifactId>
|
||||
<version>1.4.1-SNAPSHOT</version>
|
||||
<version>1.4.2-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>Mustang</name>
|
||||
<description>The Mustang project is a java library to read and write ZUGFeRD meta data inside your invoice PDFs</description>
|
||||
|
||||
@@ -39,6 +39,15 @@ public class XMPSchemaPDFAExtensions extends PDFAExtensionSchema {
|
||||
public final String prefix_pdfaSchema = "pdfaSchema";
|
||||
public final String xmlns_pdfaProperty = "http://www.aiim.org/pdfa/ns/property#";
|
||||
public final String prefix_pdfaProperty = "pdfaProperty";
|
||||
public String namespace = null;
|
||||
public String prefix = null;
|
||||
|
||||
|
||||
public void setZUGFeRDVersion(int ver) {
|
||||
namespace=ZUGFeRDExporter.getNamespaceForVersion(ver);
|
||||
prefix=ZUGFeRDExporter.getPrefixForVersion(ver);
|
||||
}
|
||||
|
||||
|
||||
private DefinedStructuredType addProperty(ArrayProperty parent, String name, String type, String category,
|
||||
String description) {
|
||||
@@ -68,17 +77,15 @@ public class XMPSchemaPDFAExtensions extends PDFAExtensionSchema {
|
||||
}
|
||||
|
||||
public XMPSchemaPDFAExtensions(XMPMetadata metadata) {
|
||||
|
||||
super(metadata);
|
||||
setZUGFeRDVersion(2);
|
||||
attachExtensions(metadata, true);
|
||||
|
||||
}
|
||||
|
||||
public XMPSchemaPDFAExtensions(XMPMetadata metadata, boolean withZF) {
|
||||
|
||||
super(metadata);
|
||||
setZUGFeRDVersion(2);
|
||||
attachExtensions(metadata, withZF);
|
||||
|
||||
}
|
||||
|
||||
public void attachExtensions(XMPMetadata metadata, boolean withZF) {
|
||||
@@ -98,10 +105,10 @@ public class XMPSchemaPDFAExtensions extends PDFAExtensionSchema {
|
||||
li.addProperty(pdfa1);
|
||||
|
||||
pdfa1 = new TextType(metadata, xmlns_pdfaSchema, prefix_pdfaSchema, PDFASchemaType.NAMESPACE_URI,
|
||||
"urn:ferd:pdfa:CrossIndustryDocument:invoice:1p0#");
|
||||
namespace);
|
||||
li.addProperty(pdfa1);
|
||||
|
||||
pdfa1 = new TextType(metadata, xmlns_pdfaSchema, prefix_pdfaSchema, PDFASchemaType.PREFIX, "zf");
|
||||
pdfa1 = new TextType(metadata, xmlns_pdfaSchema, prefix_pdfaSchema, PDFASchemaType.PREFIX, prefix);
|
||||
li.addProperty(pdfa1);
|
||||
|
||||
ArrayProperty newSeq = new ArrayProperty(metadata, xmlns_pdfaSchema, prefix_pdfaSchema,
|
||||
@@ -112,7 +119,7 @@ public class XMPSchemaPDFAExtensions extends PDFAExtensionSchema {
|
||||
addProperty(newSeq, "DocumentType", "Text", "external", "INVOICE");
|
||||
addProperty(newSeq, "Version", "Text", "external", "The actual version of the ZUGFeRD XML schema");
|
||||
addProperty(newSeq, "ConformanceLevel", "Text", "external",
|
||||
"The conformance level of the embedded ZUGFeRD data");
|
||||
"The selected ZUGFeRD profile completeness");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,14 +15,14 @@ public class XMPSchemaZugferd extends XMPSchema {
|
||||
/**
|
||||
* This is what needs to be added to the RDF metadata - basically the name of the embedded Zugferd file
|
||||
*/
|
||||
public XMPSchemaZugferd(XMPMetadata metadata, ZUGFeRDConformanceLevel conformanceLevel) {
|
||||
super(metadata, "urn:ferd:pdfa:CrossIndustryDocument:invoice:1p0#", "zf", "ZUGFeRD Schema");
|
||||
public XMPSchemaZugferd(XMPMetadata metadata, ZUGFeRDConformanceLevel conformanceLevel, String URN, String prefix, String filename) {
|
||||
super(metadata, URN, prefix, "ZUGFeRD Schema");
|
||||
|
||||
setAboutAsSimple("");
|
||||
|
||||
setTextPropertyValue("ConformanceLevel", conformanceLevel.name());
|
||||
setTextPropertyValue("DocumentType", "INVOICE");
|
||||
setTextPropertyValue("DocumentFileName", "ZUGFeRD-invoice.xml");
|
||||
setTextPropertyValue("DocumentFileName", filename);
|
||||
setTextPropertyValue("Version", "1.0");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,11 +35,10 @@ import java.util.Map;
|
||||
public class ZUGFeRDExporter implements Closeable {
|
||||
|
||||
/**
|
||||
* * You will need Apache PDFBox. To use the ZUGFeRD exporter, implement
|
||||
* IZUGFeRDExportableTransaction in yourTransaction (which will require you
|
||||
* to implement Product, Item and Contact) then call doc =
|
||||
* PDDocument.load(PDFfilename); // automatically add Zugferd to all
|
||||
* outgoing invoices ZUGFeRDExporter ze = new ZUGFeRDExporter();
|
||||
* To use the ZUGFeRD exporter, implement IZUGFeRDExportableTransaction in
|
||||
* yourTransaction (which will require you to implement Product, Item and
|
||||
* Contact) then call doc = PDDocument.load(PDFfilename); // automatically add
|
||||
* Zugferd to all outgoing invoices ZUGFeRDExporter ze = new ZUGFeRDExporter();
|
||||
* ze.PDFmakeA3compliant(doc, "Your application name",
|
||||
* System.getProperty("user.name"), true); ze.PDFattachZugferdFile(doc,
|
||||
* yourTransaction);
|
||||
@@ -47,33 +46,11 @@ public class ZUGFeRDExporter implements Closeable {
|
||||
* doc.save(PDFfilename);
|
||||
*
|
||||
* @author jstaerk
|
||||
* @deprecated Use the factory methods {@link #createFromPDFA3(String)}, {@link #createFromPDFA3(InputStream)} or
|
||||
* the {@link ZUGFeRDExporterFromA1Factory} instead
|
||||
* @deprecated Use the factory methods {@link #createFromPDFA3(String)},
|
||||
* {@link #createFromPDFA3(InputStream)} or the
|
||||
* {@link ZUGFeRDExporterFromA1Factory} instead
|
||||
*
|
||||
*/
|
||||
|
||||
public ZUGFeRDExporter() {
|
||||
init();
|
||||
}
|
||||
public ZUGFeRDExporter(PDDocument doc2) {
|
||||
doc=doc2;
|
||||
init();
|
||||
}
|
||||
|
||||
public void setVersion(int ver) {
|
||||
if (ver==1) {
|
||||
ZUGFeRD1PullProvider z1p =new ZUGFeRD1PullProvider();
|
||||
this.xmlProvider=z1p;
|
||||
|
||||
} else {
|
||||
ZUGFeRD2PullProvider z2p =new ZUGFeRD2PullProvider();
|
||||
this.xmlProvider=z2p;
|
||||
}
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setVersion(2);
|
||||
}
|
||||
// // MAIN CLASS
|
||||
@Deprecated
|
||||
private PDFAConformanceLevel conformanceLevel = PDFAConformanceLevel.UNICODE;
|
||||
@@ -83,25 +60,82 @@ public class ZUGFeRDExporter implements Closeable {
|
||||
private ZUGFeRDConformanceLevel zUGFeRDConformanceLevel = ZUGFeRDConformanceLevel.EXTENDED;
|
||||
|
||||
/**
|
||||
* Data (XML invoice) to be added to the ZUGFeRD PDF. It may be externally
|
||||
* set, in which case passing a IZUGFeRDExportableTransaction is not
|
||||
* necessary. By default it is null meaning the caller needs to pass a
|
||||
* Data (XML invoice) to be added to the ZUGFeRD PDF. It may be externally set,
|
||||
* in which case passing a IZUGFeRDExportableTransaction is not necessary. By
|
||||
* default it is null meaning the caller needs to pass a
|
||||
* IZUGFeRDExportableTransaction for the XML to be populated.
|
||||
*/
|
||||
IXMLProvider xmlProvider;
|
||||
@Deprecated
|
||||
private boolean ignoreA1Errors;
|
||||
private PDDocument doc;
|
||||
int ZFVersion;
|
||||
|
||||
public ZUGFeRDExporter() {
|
||||
init();
|
||||
}
|
||||
|
||||
public ZUGFeRDExporter(PDDocument doc2) {
|
||||
doc = doc2;
|
||||
init();
|
||||
}
|
||||
|
||||
public static String getNamespaceForVersion(int ver) {
|
||||
if (ver == 1) {
|
||||
return "urn:ferd:pdfa:CrossIndustryDocument:invoice:1p0#";
|
||||
} else if (ver == 2) {
|
||||
return "urn:factur-x:pdfa:CrossIndustryDocument:invoice:1p0#";
|
||||
} else {
|
||||
throw new IllegalArgumentException("Version not supported");
|
||||
}
|
||||
}
|
||||
|
||||
public static String getPrefixForVersion(int ver) {
|
||||
if (ver == 1) {
|
||||
return "zf";
|
||||
} else if (ver == 2) {
|
||||
return "fx";
|
||||
} else {
|
||||
throw new IllegalArgumentException("Version not supported");
|
||||
}
|
||||
}
|
||||
|
||||
public static String getFilenameForVersion(int ver) {
|
||||
if (ver == 1) {
|
||||
return "ZUGFeRD-invoice.xml";
|
||||
} else if (ver == 2) {
|
||||
return "factur-x.xml";
|
||||
} else {
|
||||
throw new IllegalArgumentException("Version not supported");
|
||||
}
|
||||
}
|
||||
|
||||
public void setZUGFeRDVersion(int ver) {
|
||||
if (ver == 1) {
|
||||
ZUGFeRD1PullProvider z1p = new ZUGFeRD1PullProvider();
|
||||
this.xmlProvider = z1p;
|
||||
} else if (ver == 2) {
|
||||
ZUGFeRD2PullProvider z2p = new ZUGFeRD2PullProvider();
|
||||
this.xmlProvider = z2p;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Version not supported");
|
||||
}
|
||||
ZFVersion = ver;
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setZUGFeRDVersion(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* All files are PDF/A-3, setConformance refers to the level conformance.
|
||||
*
|
||||
* PDF/A-3 has three conformance levels, called "A", "U" and "B".
|
||||
*
|
||||
* PDF/A-3-B where B means only visually preservable, U -standard for
|
||||
* Mustang- means visually and unicode preservable and A means full
|
||||
* compliance, i.e. visually, unicode and structurally preservable and
|
||||
* tagged PDF, i.e. useful metainformation for blind people.
|
||||
* PDF/A-3-B where B means only visually preservable, U -standard for Mustang-
|
||||
* means visually and unicode preservable and A means full compliance, i.e.
|
||||
* visually, unicode and structurally preservable and tagged PDF, i.e. useful
|
||||
* metainformation for blind people.
|
||||
*
|
||||
* Feel free to pass "A" as new level if you know what you are doing :-)
|
||||
*
|
||||
@@ -120,14 +154,16 @@ public class ZUGFeRDExporter implements Closeable {
|
||||
*
|
||||
* PDF/A-3 has three conformance levels, called "A", "U" and "B".
|
||||
*
|
||||
* PDF/A-3-B where B means only visually preservable, U -standard for
|
||||
* Mustang- means visually and unicode preservable and A means full
|
||||
* compliance, i.e. visually, unicode and structurally preservable and
|
||||
* tagged PDF, i.e. useful metainformation for blind people.
|
||||
* PDF/A-3-B where B means only visually preservable, U -standard for Mustang-
|
||||
* means visually and unicode preservable and A means full compliance, i.e.
|
||||
* visually, unicode and structurally preservable and tagged PDF, i.e. useful
|
||||
* metainformation for blind people.
|
||||
*
|
||||
* Feel free to pass "A" as new level if you know what you are doing :-)
|
||||
*
|
||||
* @deprecated Use {@link #setConformanceLevel(org.mustangproject.ZUGFeRD.PDFAConformanceLevel)} instead
|
||||
* @deprecated Use
|
||||
* {@link #setConformanceLevel(org.mustangproject.ZUGFeRD.PDFAConformanceLevel)}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void setConformanceLevel(String newLevel) {
|
||||
@@ -163,7 +199,8 @@ public class ZUGFeRDExporter implements Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use the factory method {@link #createFromPDFA3(InputStream)} instead
|
||||
* @deprecated Use the factory method {@link #createFromPDFA3(InputStream)}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void loadPDFA3(InputStream file) throws IOException {
|
||||
@@ -175,23 +212,18 @@ public class ZUGFeRDExporter implements Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes A PDF/A3a-compliant document from a PDF-A1 compliant document (on
|
||||
* the metadata level, this will not e.g. convert graphics to JPG-2000)
|
||||
* Makes A PDF/A3a-compliant document from a PDF-A1 compliant document (on the
|
||||
* metadata level, this will not e.g. convert graphics to JPG-2000)
|
||||
*
|
||||
* @deprecated use the {@link ZUGFeRDExporterFromA1Factory} instead
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public PDDocumentCatalog PDFmakeA3compliant(String filename,
|
||||
String producer, String creator, boolean attachZugferdHeaders)
|
||||
throws IOException, TransformerException {
|
||||
public PDDocumentCatalog PDFmakeA3compliant(String filename, String producer, String creator,
|
||||
boolean attachZugferdHeaders) throws IOException, TransformerException {
|
||||
|
||||
doc = createPDFA1Factory()
|
||||
.setProducer(producer)
|
||||
.setCreator(creator)
|
||||
.setAttachZUGFeRDHeaders(attachZugferdHeaders)
|
||||
.load(filename)
|
||||
.doc;
|
||||
doc = createPDFA1Factory().setProducer(producer).setCreator(creator)
|
||||
.setAttachZUGFeRDHeaders(attachZugferdHeaders).load(filename).doc;
|
||||
|
||||
return doc.getDocumentCatalog();
|
||||
}
|
||||
@@ -200,15 +232,11 @@ public class ZUGFeRDExporter implements Closeable {
|
||||
* @deprecated use the {@link ZUGFeRDExporterFromA1Factory} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public PDDocumentCatalog PDFmakeA3compliant(InputStream file,
|
||||
String producer, String creator, boolean attachZugferdHeaders) throws IOException, TransformerException {
|
||||
public PDDocumentCatalog PDFmakeA3compliant(InputStream file, String producer, String creator,
|
||||
boolean attachZugferdHeaders) throws IOException, TransformerException {
|
||||
|
||||
doc = createPDFA1Factory()
|
||||
.setProducer(producer)
|
||||
.setCreator(creator)
|
||||
.setAttachZUGFeRDHeaders(attachZugferdHeaders)
|
||||
.load(file)
|
||||
.doc;
|
||||
doc = createPDFA1Factory().setProducer(producer).setCreator(creator)
|
||||
.setAttachZUGFeRDHeaders(attachZugferdHeaders).load(file).doc;
|
||||
|
||||
return doc.getDocumentCatalog();
|
||||
}
|
||||
@@ -218,9 +246,7 @@ public class ZUGFeRDExporter implements Closeable {
|
||||
if (ignoreA1Errors) {
|
||||
factory.ignorePDFAErrors();
|
||||
}
|
||||
return factory
|
||||
.setZUGFeRDConformanceLevel(zUGFeRDConformanceLevel)
|
||||
.setConformanceLevel(conformanceLevel);
|
||||
return factory.setZUGFeRDConformanceLevel(zUGFeRDConformanceLevel).setConformanceLevel(conformanceLevel);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -230,25 +256,20 @@ public class ZUGFeRDExporter implements Closeable {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Embeds the Zugferd XML structure in a file named ZUGFeRD-invoice.xml.
|
||||
*
|
||||
* @param trans
|
||||
* a IZUGFeRDExportableTransaction that provides the data-model
|
||||
* to populate the XML. This parameter may be null, if so the XML
|
||||
* data should hav ebeen set via
|
||||
* a IZUGFeRDExportableTransaction that provides the data-model to
|
||||
* populate the XML. This parameter may be null, if so the XML data
|
||||
* should hav ebeen set via
|
||||
* <code>setZUGFeRDXMLData(byte[] zugferdData)</code>
|
||||
*/
|
||||
public void PDFattachZugferdFile(IZUGFeRDExportableTransaction trans)
|
||||
throws IOException {
|
||||
public void PDFattachZugferdFile(IZUGFeRDExportableTransaction trans) throws IOException {
|
||||
|
||||
xmlProvider.generateXML(trans);
|
||||
|
||||
PDFAttachGenericFile(
|
||||
doc,
|
||||
"ZUGFeRD-invoice.xml",
|
||||
"Alternative",
|
||||
String filename = getFilenameForVersion(ZFVersion);
|
||||
PDFAttachGenericFile(doc, filename, "Alternative",
|
||||
"Invoice metadata conforming to ZUGFeRD standard (http://www.ferd-net.de/front_content.php?idcat=231&lang=4)",
|
||||
"text/xml", xmlProvider.getXML());
|
||||
}
|
||||
@@ -278,13 +299,11 @@ public class ZUGFeRDExporter implements Closeable {
|
||||
* the binary data of the file/attachment
|
||||
* @throws java.io.IOException
|
||||
*/
|
||||
public void PDFAttachGenericFile(PDDocument doc, String filename,
|
||||
String relationship, String description, String subType, byte[] data)
|
||||
throws IOException {
|
||||
public void PDFAttachGenericFile(PDDocument doc, String filename, String relationship, String description,
|
||||
String subType, byte[] data) throws IOException {
|
||||
PDComplexFileSpecification fs = new PDComplexFileSpecification();
|
||||
fs.setFile(filename);
|
||||
|
||||
|
||||
COSDictionary dict = fs.getCOSObject();
|
||||
dict.setName("AFRelationship", relationship);
|
||||
dict.setString("UF", filename);
|
||||
@@ -302,14 +321,12 @@ public class ZUGFeRDExporter implements Closeable {
|
||||
|
||||
// In addition make sure the embedded file is set under /UF
|
||||
dict = fs.getCOSObject();
|
||||
COSDictionary efDict = (COSDictionary) dict
|
||||
.getDictionaryObject(COSName.EF);
|
||||
COSDictionary efDict = (COSDictionary) dict.getDictionaryObject(COSName.EF);
|
||||
COSBase lowerLevelFile = efDict.getItem(COSName.F);
|
||||
efDict.setItem(COSName.UF, lowerLevelFile);
|
||||
|
||||
// now add the entry to the embedded file tree and set in the document.
|
||||
PDDocumentNameDictionary names = new PDDocumentNameDictionary(
|
||||
doc.getDocumentCatalog());
|
||||
PDDocumentNameDictionary names = new PDDocumentNameDictionary(doc.getDocumentCatalog());
|
||||
PDEmbeddedFilesNameTreeNode efTree = names.getEmbeddedFiles();
|
||||
if (efTree == null) {
|
||||
efTree = new PDEmbeddedFilesNameTreeNode();
|
||||
@@ -330,8 +347,7 @@ public class ZUGFeRDExporter implements Closeable {
|
||||
doc.getDocumentCatalog().setNames(names);
|
||||
|
||||
// AF entry (Array) in catalog with the FileSpec
|
||||
COSArray cosArray = (COSArray) doc.getDocumentCatalog()
|
||||
.getCOSObject().getItem("AF");
|
||||
COSArray cosArray = (COSArray) doc.getDocumentCatalog().getCOSObject().getItem("AF");
|
||||
if (cosArray == null) {
|
||||
cosArray = new COSArray();
|
||||
}
|
||||
@@ -345,8 +361,8 @@ public class ZUGFeRDExporter implements Closeable {
|
||||
|
||||
/**
|
||||
* Sets the ZUGFeRD XML data to be attached as a single byte array. This is
|
||||
* useful for use-cases where the XML has already been produced by some
|
||||
* external API or component.
|
||||
* useful for use-cases where the XML has already been produced by some external
|
||||
* API or component.
|
||||
*
|
||||
* @param zugferdData
|
||||
* XML data to be set as a byte array (XML file in raw form).
|
||||
|
||||
@@ -9,13 +9,11 @@ import org.apache.pdfbox.preflight.PreflightDocument;
|
||||
import org.apache.pdfbox.preflight.exception.ValidationException;
|
||||
import org.apache.pdfbox.preflight.parser.PreflightParser;
|
||||
import org.apache.pdfbox.preflight.utils.ByteArrayDataSource;
|
||||
import org.apache.pdfbox.util.Version;
|
||||
import org.apache.xmpbox.XMPMetadata;
|
||||
import org.apache.xmpbox.schema.AdobePDFSchema;
|
||||
import org.apache.xmpbox.schema.DublinCoreSchema;
|
||||
import org.apache.xmpbox.schema.PDFAIdentificationSchema;
|
||||
import org.apache.xmpbox.schema.XMPBasicSchema;
|
||||
import org.apache.xmpbox.type.BadFieldValueException;
|
||||
import org.apache.xmpbox.xml.XmpSerializer;
|
||||
|
||||
import javax.activation.DataSource;
|
||||
@@ -28,6 +26,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
public class ZUGFeRDExporterFromA3Factory implements IExporterFactory {
|
||||
protected boolean ignorePDFAErrors = false;
|
||||
@@ -41,6 +40,7 @@ public class ZUGFeRDExporterFromA3Factory implements IExporterFactory {
|
||||
protected PDMetadata metadata = null;
|
||||
protected PDFAIdentificationSchema pdfaid = null;
|
||||
protected XMPMetadata xmp = null;
|
||||
protected int ZFVersion=2;
|
||||
/**
|
||||
* Makes A PDF/A3a-compliant document from a PDF-A1 compliant document (on the
|
||||
* metadata level, this will not e.g. convert graphics to JPG-2000)
|
||||
@@ -56,6 +56,10 @@ public class ZUGFeRDExporterFromA3Factory implements IExporterFactory {
|
||||
}
|
||||
|
||||
|
||||
public void setZUGFeRDversion(int version) {
|
||||
ZFVersion=version;
|
||||
}
|
||||
|
||||
public void prepareDocument(PDDocument doc) throws IOException {
|
||||
String fullProducer = producer + " (via mustangproject.org " + org.mustangproject.ZUGFeRD.Version.VERSION + ")";
|
||||
|
||||
@@ -102,7 +106,7 @@ public class ZUGFeRDExporterFromA3Factory implements IExporterFactory {
|
||||
PDDocument doc = PDDocument.load(pdfBinary);
|
||||
prepareDocument(doc);
|
||||
zugFeRDExporter = new ZUGFeRDExporter(doc);
|
||||
|
||||
zugFeRDExporter.setZUGFeRDVersion(ZFVersion);
|
||||
return zugFeRDExporter;
|
||||
}
|
||||
|
||||
@@ -164,7 +168,7 @@ public class ZUGFeRDExporterFromA3Factory implements IExporterFactory {
|
||||
public void addXMP(XMPMetadata metadata) {
|
||||
|
||||
if (attachZugferdHeaders) {
|
||||
XMPSchemaZugferd zf = new XMPSchemaZugferd(metadata, zugferdConformanceLevel);
|
||||
XMPSchemaZugferd zf = new XMPSchemaZugferd(metadata, zugferdConformanceLevel, ZUGFeRDExporter.getNamespaceForVersion(ZFVersion), ZUGFeRDExporter.getPrefixForVersion(ZFVersion), ZUGFeRDExporter.getFilenameForVersion(ZFVersion) );
|
||||
|
||||
metadata.addSchema(zf);
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ public class ZUGFeRDImporter {
|
||||
* currently (in the release candidate of version 1) only one
|
||||
* attached file with the name ZUGFeRD-invoice.xml is allowed
|
||||
* */
|
||||
if (filename.equals("ZUGFeRD-invoice.xml")) { //$NON-NLS-1$
|
||||
if ((filename.equals("ZUGFeRD-invoice.xml")||filename.equals("factur-x.xml"))) { //$NON-NLS-1$
|
||||
containsMeta = true;
|
||||
|
||||
PDComplexFileSpecification fileSpec = efMap.get(filename);
|
||||
@@ -284,6 +284,11 @@ public class ZUGFeRDImporter {
|
||||
}
|
||||
|
||||
ndList = document.getElementsByTagNameNS("*","SpecifiedTradePaymentTerms"); //$NON-NLS-1$
|
||||
if (ndList.getLength()==0) {
|
||||
// try ZF1, it can not harm
|
||||
ndList = document.getElementsByTagNameNS("*","SpecifiedCITradePaymentTerms"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
|
||||
for (int bookingIndex = 0; bookingIndex < ndList
|
||||
.getLength(); bookingIndex++) {
|
||||
|
||||
@@ -410,7 +410,7 @@ public class MustangReaderWriterEdgeTest extends TestCase implements IZUGFeRDExp
|
||||
.setCreator(System.getProperty("user.name"))
|
||||
.ignorePDFAErrors()
|
||||
.load(SOURCE_PDF)) {
|
||||
ze.setVersion(1);
|
||||
ze.setZUGFeRDVersion(1);
|
||||
ze.PDFattachZugferdFile(this);
|
||||
ze.export(TARGET_PDF);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user