From 6bb4ccaff0b2f0cb904e5d1eba7614e0c19411b8 Mon Sep 17 00:00:00 2001 From: "andreas.vef" Date: Wed, 14 Nov 2018 15:04:54 +0100 Subject: [PATCH] Added setCreatorTool (fix for https://github.com/ZUGFeRD/mustangproject/issues/38 Distinguish between creator, creatorTool and producer) --- .../org/mustangproject/ZUGFeRD/ZUGFeRDExporter.java | 13 ++++++++++++- .../ZUGFeRD/ZUGFeRDExporterFromA3Factory.java | 11 +++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporter.java b/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporter.java index c473689f..f5b97613 100644 --- a/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporter.java +++ b/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporter.java @@ -100,8 +100,12 @@ public class ZUGFeRDExporter implements Closeable { protected PDMetadata metadata = null; protected PDFAIdentificationSchema pdfaid = null; protected XMPMetadata xmp = null; + /** Producer attribute for PDF */ protected String producer = "mustangproject"; + /** Author/Creator attribute for PDF for PDF */ protected String creator = "mustangproject"; + /** CreatorTool */ + protected String creatorTool = "mustangproject"; @Deprecated private boolean ignoreA1Errors; @@ -558,7 +562,7 @@ public class ZUGFeRDExporter implements Closeable { XMPBasicSchema xsb = xmp.createAndAddXMPBasicSchema(); - xsb.setCreatorTool(creator); + xsb.setCreatorTool(creatorTool); xsb.setCreateDate(GregorianCalendar.getInstance()); // PDDocumentInformation pdi=doc.getDocumentInformation(); PDDocumentInformation pdi = new PDDocumentInformation(); @@ -619,6 +623,13 @@ public class ZUGFeRDExporter implements Closeable { public void setCreator(String creator) { this.creator = creator; } + /** + * the CreatorTool attribute for the PDF + * @param creator + */ + protected void setCreatorTool(String creatorTool) { + this.creatorTool = creatorTool; + } /** * the authoring software (use factory method instead) diff --git a/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporterFromA3Factory.java b/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporterFromA3Factory.java index 055c078c..ac9b2c43 100644 --- a/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporterFromA3Factory.java +++ b/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporterFromA3Factory.java @@ -36,8 +36,12 @@ public class ZUGFeRDExporterFromA3Factory implements IExporterFactory { protected boolean ignorePDFAErrors = false; protected ZUGFeRDConformanceLevel zugferdConformanceLevel = ZUGFeRDConformanceLevel.EXTENDED; protected PDFAConformanceLevel conformanceLevel = PDFAConformanceLevel.UNICODE; + /** Producer (attribute for PDF */ protected String producer = "mustangproject"; + /** Human creator (attribute for PDF) */ protected String creator = "mustangproject"; + /** Creator tool (attribute for PDF) */ + protected String creatorTool = null; protected int ZFVersion=ZUGFeRDExporter.DefaultZUGFeRDVersion; protected boolean ensurePDFisUpgraded=false; @@ -58,6 +62,8 @@ public class ZUGFeRDExporterFromA3Factory implements IExporterFactory { zugFeRDExporter.setZUGFeRDVersion(ZFVersion); zugFeRDExporter.setZUGFeRDConformanceLevel(zugferdConformanceLevel); zugFeRDExporter.setCreator(creator); + // Use creator as default for compatibility + zugFeRDExporter.setCreatorTool(creatorTool != null ? creatorTool : creator); zugFeRDExporter.setProducer(producer); zugFeRDExporter.setAttachZUGFeRDHeaders(attachZUGFeRDHeaders); zugFeRDExporter.setPDFA3(ensurePDFisUpgraded); @@ -190,6 +196,11 @@ public class ZUGFeRDExporterFromA3Factory implements IExporterFactory { this.creator = creator; return this; } + + public IExporterFactory setCreatorTool(String creatorTool) { + this.creatorTool = creatorTool; + return this; + } public IExporterFactory setProducer(String producer) { this.producer = producer;