diff --git a/mustang/pom.xml b/mustang/pom.xml
index cbe62a6d..ff8f23e1 100644
--- a/mustang/pom.xml
+++ b/mustang/pom.xml
@@ -3,12 +3,12 @@
com.github.rayman2200
mustang-sample-project
- 1.3.0-SNAPSHOT
+ 1.3.0
org.mustangproject.ZUGFeRD
mustang
- 1.3.0-SNAPSHOT
+ 1.3.0
jar
Mustang
@@ -68,4 +68,8 @@
+
+
+ mustang-1.3.0
+
diff --git a/mustang/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporter.java b/mustang/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporter.java
index 6c45ebe7..31bb2f9d 100644
--- a/mustang/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporter.java
+++ b/mustang/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporter.java
@@ -381,7 +381,13 @@ public class ZUGFeRDExporter {
return getA1ParserValidationResult(parser);
}
+ /***
+ * Will return a boolean if the inputstream is valid PDF/A-1 and close the input stream
+ * @param file
+ * @return
+ */
public boolean isValidA1(InputStream file) {
+
ByteArrayDataSource fd;
try {
fd = new ByteArrayDataSource(file);
@@ -439,11 +445,22 @@ public class ZUGFeRDExporter {
public PDDocumentCatalog PDFmakeA3compliant(InputStream file,
String producer, String creator, boolean attachZugferdHeaders)
throws IOException, TransformerException {
+ /* cache the file content in memory, unfortunately the next step, isValidA1,
+ * will close the input stream but the step thereafter (loadPDFA3) needs
+ * and open one*/
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ byte[] buf = new byte[1024];
+ int n = 0;
+ while ((n = file.read(buf)) >= 0)
+ baos.write(buf, 0, n);
+ byte[] content = baos.toByteArray();
- if (!ignoreA1Errors && !isValidA1(file)) {
+ InputStream is1 = new ByteArrayInputStream(content);
+ if (!ignoreA1Errors && !isValidA1(is1)) {
throw new IOException("File is not a valid PDF/A-1 input file");
}
- loadPDFA3(file);
+ InputStream is2 = new ByteArrayInputStream(content);
+ loadPDFA3(is2);
return makeDocPDFA3compliant(producer, creator, attachZugferdHeaders);
}
diff --git a/pom.xml b/pom.xml
index 5bb6a839..14c84c9c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,14 +2,14 @@
4.0.0
com.github.rayman2200
mustang-sample-project
- 1.3.0-SNAPSHOT
+ 1.3.0
pom
scm:git:https://github.com/AlexanderSchmidt/PDFA3.git
scm:git:https://github.com/AlexanderSchmidt/PDFA3.git
https://github.com/AlexanderSchmidt/PDFA3.git
- HEAD
+ mustang-sample-project-1.3.0