Fix ClassCastException in CLI (Main.java).

This commit is contained in:
langfr
2024-08-21 00:01:22 +01:00
parent d5341f0a28
commit 81328c939b
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.");
}