diff --git a/History.md b/History.md index 8a668175..994052b7 100644 --- a/History.md +++ b/History.md @@ -1,18 +1,19 @@ 2.9.0 ======= +2023-11-27 -Missing closing tag in BankDetails when there's no BIC number #339 -ZUGFeRDExporterFromA3 did not set default ZUGFeRD Version -Have a way to merge to PDF file without knowing if it is A-1 or A-3 #341 -Be able to validate XR 3.0 #347 +- Missing closing tag in BankDetails when there's no BIC number #339 +- ZUGFeRDExporterFromA3 did not set default ZUGFeRD Version +- Have a way to merge to PDF file without knowing if it is A-1 or A-3 #341 +- Be able to validate XR 3.0 #347 2.8.0 ======= 2023-09-14 -Improvement of included notes #331 -fixes #259 by Heavenfighter -introduction of --disable-file-logging command line option +- Improvement of included notes #331 +- fixes #259 by Heavenfighter +- introduction of --disable-file-logging command line option 2.7.3 ======= diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporterFromPDFA.java b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporterFromPDFA.java index a97a23e4..37ab4167 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporterFromPDFA.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporterFromPDFA.java @@ -60,8 +60,12 @@ protected IZUGFeRDExporter getExporter() { return theExporter; } - private byte[] fileToByteArrayInputStream(String pdfFilename) throws IOException { + protected byte[] filenameToByteArray(String pdfFilename) throws IOException { FileInputStream fileInputStream = new FileInputStream(pdfFilename); + return inputstreamToByteArray(fileInputStream); + } + + protected byte[] inputstreamToByteArray(InputStream fileInputStream) throws IOException { byte[] bytes = new byte[fileInputStream.available()]; DataInputStream dataInputStream = new DataInputStream(fileInputStream); dataInputStream.readFully(bytes); @@ -105,7 +109,7 @@ private int getPDFAVersion(byte[] byteArrayInputStream) throws IOException { * @throws IOException */ public IZUGFeRDExporter load(String pdfFilename) throws IOException { - determineAndSetExporter(getPDFAVersion(fileToByteArrayInputStream(pdfFilename))); + determineAndSetExporter(getPDFAVersion(filenameToByteArray(pdfFilename))); return theExporter.load(pdfFilename); } @@ -133,7 +137,7 @@ public IZUGFeRDExporter load(byte[] pdfBinary) throws IOException { * @throws IOException if anything is wrong with inputstream */ public IZUGFeRDExporter load(InputStream pdfSource) throws IOException { - determineAndSetExporter(getPDFAVersion(pdfSource.readAllBytes())); + determineAndSetExporter(getPDFAVersion(inputstreamToByteArray(pdfSource))); return theExporter.load(pdfSource); }