see history

This commit is contained in:
Jochen Stärk
2018-08-29 14:12:34 +02:00
parent 3e9fb55ab8
commit 8df75e2f27
4 changed files with 44 additions and 2 deletions

View File

@@ -1,3 +1,9 @@
1.5.4
=====
2018-08-29
Fixed #62 fail gracefully on commandline extraction of XML if none is present.
New public function: ZUGFeRDImporter.getUTF8 returns raw XML without Byte Order Mark, if one had been used.
1.5.3
=====

Binary file not shown.

View File

@@ -495,6 +495,36 @@ public class ZUGFeRDImporter {
return new String(rawXML);
}
/**
*
* @return return UTF8 XML (without BOM) of the invoice
*/
public String getUTF8() {
if (rawXML == null) {
return null;
}
if (rawXML.length<3) {
return new String(rawXML);
}
byte[] bomlessData;
if ((rawXML[0] == (byte) 0xEF)
&& (rawXML[1] == (byte) 0xBB)
&& (rawXML[2] == (byte) 0xBF)) {
// I don't like BOMs, lets remove it
bomlessData = new byte[rawXML.length - 3];
System.arraycopy(rawXML, 3, bomlessData, 0,
rawXML.length - 3);
} else {
bomlessData = rawXML;
}
return new String(bomlessData);
}
/**
* Returns the raw XML data as extracted from the ZUGFeRD PDF file.
*/

View File

@@ -368,11 +368,17 @@ public class Toecount {
zi.extract(pdfName);
try {
Files.write(Paths.get(xmlName), zi.getRawXML());
byte[] XMLContent=zi.getRawXML();
if (XMLContent==null) {
System.err.println("No ZUGFeRD XML found in PDF file");
} else {
Files.write(Paths.get(xmlName), XMLContent);
System.out.println("Written to " + xmlName);
}
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("Written to " + xmlName);
} else if (a3only) {
/*