Merge pull request #451 from langfr/bugfix/451

Fix ClassCastException in CLI (Main.java).
This commit is contained in:
Jochen Staerk
2024-08-28 13:41:45 +02:00
committed by GitHub
2 changed files with 9 additions and 4 deletions

View File

@@ -722,9 +722,6 @@ public class Main {
((ZUGFeRDExporterFromPDFA) ze).ignorePDFAErrors();
}
}
for (FileAttachment attachment : attachments) {
((ZUGFeRDExporterFromA3) ze).attachFile(attachment.getFilename(), attachment.getData(), attachment.getMimetype(), attachment.getRelation());
}
ze.load(pdfName);
ze.setProducer("Mustang-cli")
@@ -737,6 +734,14 @@ public class Main {
ze.setXML(Files.readAllBytes(Paths.get(xmlName)));
for (FileAttachment attachment : attachments) {
if (((ZUGFeRDExporterFromPDFA) ze).getExporter() instanceof ZUGFeRDExporterFromA3 ) {
((ZUGFeRDExporterFromA3) ((ZUGFeRDExporterFromPDFA) ze).getExporter()).attachFile(attachment.getFilename(), attachment.getData(), attachment.getMimetype(), attachment.getRelation());
} else {
System.err.println("IZUGFeRDExporter ze is not of type 'ZUGFeRDExporterFromA3'");
}
}
ze.export(outName);
System.out.println("Written to " + outName);

View File

@@ -72,7 +72,7 @@ public class ZUGFeRDExporterFromPDFA implements IZUGFeRDExporter {
}
protected IZUGFeRDExporter getExporter() {
public IZUGFeRDExporter getExporter() {
if (theExporter==null) {
throw new RuntimeException("In ZUGFeRDExporterFromPDFA, source must always be loaded before other operations are performed.");
}