see history
This commit is contained in:
@@ -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
|
1.5.3
|
||||||
=====
|
=====
|
||||||
|
|||||||
Binary file not shown.
@@ -495,7 +495,37 @@ public class ZUGFeRDImporter {
|
|||||||
return new String(rawXML);
|
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.
|
* Returns the raw XML data as extracted from the ZUGFeRD PDF file.
|
||||||
*/
|
*/
|
||||||
public byte[] getRawXML() {
|
public byte[] getRawXML() {
|
||||||
|
|||||||
@@ -368,11 +368,17 @@ public class Toecount {
|
|||||||
|
|
||||||
zi.extract(pdfName);
|
zi.extract(pdfName);
|
||||||
try {
|
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) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
System.out.println("Written to " + xmlName);
|
|
||||||
|
|
||||||
} else if (a3only) {
|
} else if (a3only) {
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user