first commit
This commit is contained in:
commit
4d332ef662
27586 changed files with 3281783 additions and 0 deletions
|
|
@ -0,0 +1,13 @@
|
|||
package com.itextpdf.text.pdf;
|
||||
|
||||
public final class AFRelationshipValue {
|
||||
public static final PdfName Source = new PdfName("Source");
|
||||
|
||||
public static final PdfName Data = new PdfName("Data");
|
||||
|
||||
public static final PdfName Alternative = new PdfName("Alternative");
|
||||
|
||||
public static final PdfName Supplement = new PdfName("Supplement");
|
||||
|
||||
public static final PdfName Unspecified = new PdfName("Unspecified");
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.itextpdf.text.pdf;
|
||||
|
||||
public class PdfAConformanceException extends PdfIsoConformanceException {
|
||||
private static final long serialVersionUID = 194425427686830283L;
|
||||
|
||||
protected Object object = null;
|
||||
|
||||
public PdfAConformanceException() {}
|
||||
|
||||
public PdfAConformanceException(String s) {
|
||||
super(s);
|
||||
}
|
||||
|
||||
public PdfAConformanceException(Object object, String message) {
|
||||
super(message);
|
||||
this.object = object;
|
||||
}
|
||||
|
||||
public Object getObject() {
|
||||
return this.object;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
package com.itextpdf.text.pdf;
|
||||
|
||||
public enum PdfAConformanceLevel {
|
||||
PDF_A_1A, PDF_A_1B, PDF_A_2A, PDF_A_2B, PDF_A_2U, PDF_A_3A, PDF_A_3B, PDF_A_3U, ZUGFeRD, ZUGFeRDBasic, ZUGFeRDComfort, ZUGFeRDExtended;
|
||||
}
|
||||
|
|
@ -0,0 +1,160 @@
|
|||
package com.itextpdf.text.pdf;
|
||||
|
||||
import com.itextpdf.text.Document;
|
||||
import com.itextpdf.text.DocumentException;
|
||||
import com.itextpdf.text.error_messages.MessageLocalization;
|
||||
import com.itextpdf.text.log.Counter;
|
||||
import com.itextpdf.text.log.CounterFactory;
|
||||
import com.itextpdf.text.pdf.interfaces.PdfAConformance;
|
||||
import com.itextpdf.text.pdf.interfaces.PdfIsoConformance;
|
||||
import com.itextpdf.text.pdf.internal.PdfAChecker;
|
||||
import com.itextpdf.text.pdf.internal.PdfAConformanceImp;
|
||||
import com.itextpdf.text.xml.xmp.PdfAXmpWriter;
|
||||
import com.itextpdf.text.xml.xmp.XmpWriter;
|
||||
import com.itextpdf.xmp.XMPMeta;
|
||||
import com.itextpdf.xmp.impl.XMPMetaParser;
|
||||
import com.itextpdf.xmp.properties.XMPProperty;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class PdfACopy extends PdfCopy {
|
||||
public PdfACopy(Document document, OutputStream os, PdfAConformanceLevel conformanceLevel) throws DocumentException {
|
||||
super(document, os);
|
||||
((PdfAConformance)this.pdfIsoConformance).setConformanceLevel(conformanceLevel);
|
||||
PdfAWriter.setPdfVersion((PdfWriter)this, conformanceLevel);
|
||||
}
|
||||
|
||||
protected Counter COUNTER = CounterFactory.getCounter(PdfACopy.class);
|
||||
|
||||
protected Counter getCounter() {
|
||||
return this.COUNTER;
|
||||
}
|
||||
|
||||
protected PdfIsoConformance initPdfIsoConformance() {
|
||||
return new PdfAConformanceImp((PdfWriter)this);
|
||||
}
|
||||
|
||||
protected void cacheObject(PdfIndirectObject iobj) {
|
||||
super.cacheObject(iobj);
|
||||
getPdfAChecker().cacheObject(iobj.getIndirectReference(), iobj.object);
|
||||
}
|
||||
|
||||
private PdfAChecker getPdfAChecker() {
|
||||
return ((PdfAConformanceImp)this.pdfIsoConformance).getPdfAChecker();
|
||||
}
|
||||
|
||||
public void addDocument(PdfReader reader) throws DocumentException, IOException {
|
||||
checkPdfAInfo(reader);
|
||||
super.addDocument(reader);
|
||||
}
|
||||
|
||||
public void addPage(PdfImportedPage iPage) throws IOException, BadPdfFormatException {
|
||||
checkPdfAInfo(iPage.readerInstance.getReader());
|
||||
super.addPage(iPage);
|
||||
}
|
||||
|
||||
public PdfCopy.PageStamp createPageStamp(PdfImportedPage iPage) {
|
||||
checkPdfAInfo(iPage.readerInstance.getReader());
|
||||
return super.createPageStamp(iPage);
|
||||
}
|
||||
|
||||
public void setOutputIntents(String outputConditionIdentifier, String outputCondition, String registryName, String info, ICC_Profile colorProfile) throws IOException {
|
||||
super.setOutputIntents(outputConditionIdentifier, outputCondition, registryName, info, colorProfile);
|
||||
PdfArray a = this.extraCatalog.getAsArray(PdfName.OUTPUTINTENTS);
|
||||
if (a != null) {
|
||||
PdfDictionary d = a.getAsDict(0);
|
||||
if (d != null)
|
||||
d.put(PdfName.S, (PdfObject)PdfName.GTS_PDFA1);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean setOutputIntents(PdfReader reader, boolean checkExistence) throws IOException {
|
||||
PdfDictionary catalog = reader.catalog;
|
||||
PdfArray outs = catalog.getAsArray(PdfName.OUTPUTINTENTS);
|
||||
if (outs == null)
|
||||
return false;
|
||||
if (outs.size() == 0)
|
||||
return false;
|
||||
PdfDictionary outa = outs.getAsDict(0);
|
||||
PdfObject obj = PdfReader.getPdfObject(outa.get(PdfName.S));
|
||||
if (obj == null || !PdfName.GTS_PDFA1.equals(obj))
|
||||
return false;
|
||||
if (checkExistence)
|
||||
return true;
|
||||
PRStream stream = (PRStream)PdfReader.getPdfObject(outa.get(PdfName.DESTOUTPUTPROFILE));
|
||||
byte[] destProfile = null;
|
||||
if (stream != null)
|
||||
destProfile = PdfReader.getStreamBytes(stream);
|
||||
setOutputIntents(getNameString(outa, PdfName.OUTPUTCONDITIONIDENTIFIER), getNameString(outa, PdfName.OUTPUTCONDITION),
|
||||
getNameString(outa, PdfName.REGISTRYNAME), getNameString(outa, PdfName.INFO), destProfile);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected XmpWriter createXmpWriter(ByteArrayOutputStream baos, PdfDictionary info) throws IOException {
|
||||
return new PdfAXmpWriter(baos, info, ((PdfAConformance)this.pdfIsoConformance).getConformanceLevel(), (PdfWriter)this);
|
||||
}
|
||||
|
||||
protected XmpWriter createXmpWriter(ByteArrayOutputStream baos, HashMap<String, String> info) throws IOException {
|
||||
return new PdfAXmpWriter(baos, info, ((PdfAConformance)this.pdfIsoConformance).getConformanceLevel(), (PdfWriter)this);
|
||||
}
|
||||
|
||||
protected TtfUnicodeWriter getTtfUnicodeWriter() {
|
||||
if (this.ttfUnicodeWriter == null)
|
||||
this.ttfUnicodeWriter = new PdfATtfUnicodeWriter((PdfWriter)this, ((PdfAConformance)this.pdfIsoConformance).getConformanceLevel());
|
||||
return this.ttfUnicodeWriter;
|
||||
}
|
||||
|
||||
public void close() {
|
||||
super.close();
|
||||
getPdfAChecker().close((PdfWriter)this);
|
||||
}
|
||||
|
||||
private void checkPdfAInfo(PdfReader reader) {
|
||||
XMPProperty pdfaidConformance, pdfaidPart;
|
||||
try {
|
||||
byte[] metadata = reader.getMetadata();
|
||||
XMPMeta xmpMeta = XMPMetaParser.parse(metadata, null);
|
||||
pdfaidConformance = xmpMeta.getProperty("http://www.aiim.org/pdfa/ns/id/", "pdfaid:conformance");
|
||||
pdfaidPart = xmpMeta.getProperty("http://www.aiim.org/pdfa/ns/id/", "pdfaid:part");
|
||||
} catch (Throwable e) {
|
||||
throw new PdfAConformanceException(MessageLocalization.getComposedMessage("only.pdfa.documents.can.be.added.in.PdfACopy", new Object[0]));
|
||||
}
|
||||
if (pdfaidConformance == null || pdfaidPart == null)
|
||||
throw new PdfAConformanceException(MessageLocalization.getComposedMessage("only.pdfa.documents.can.be.added.in.PdfACopy", new Object[0]));
|
||||
switch (((PdfAConformance)this.pdfIsoConformance).getConformanceLevel()) {
|
||||
case PDF_A_1A:
|
||||
case PDF_A_1B:
|
||||
if (!"1".equals(pdfaidPart.getValue()))
|
||||
throw new PdfAConformanceException(MessageLocalization.getComposedMessage("different.pdf.a.version", new Object[] { "1" }));
|
||||
break;
|
||||
case PDF_A_2A:
|
||||
case PDF_A_2B:
|
||||
case PDF_A_2U:
|
||||
if (!"2".equals(pdfaidPart.getValue()))
|
||||
throw new PdfAConformanceException(MessageLocalization.getComposedMessage("different.pdf.a.version", new Object[] { "2" }));
|
||||
break;
|
||||
case PDF_A_3A:
|
||||
case PDF_A_3B:
|
||||
case PDF_A_3U:
|
||||
case ZUGFeRD:
|
||||
if (!"3".equals(pdfaidPart.getValue()))
|
||||
throw new PdfAConformanceException(MessageLocalization.getComposedMessage("different.pdf.a.version", new Object[] { "3" }));
|
||||
break;
|
||||
}
|
||||
switch (((PdfAConformance)this.pdfIsoConformance).getConformanceLevel()) {
|
||||
case PDF_A_1A:
|
||||
case PDF_A_2A:
|
||||
case PDF_A_3A:
|
||||
if (!"A".equals(pdfaidConformance.getValue()))
|
||||
throw new PdfAConformanceException(MessageLocalization.getComposedMessage("incompatible.pdf.a.conformance.level", new Object[] { "a" }));
|
||||
break;
|
||||
case PDF_A_2U:
|
||||
case PDF_A_3U:
|
||||
if ("B".equals(pdfaidConformance.getValue()))
|
||||
throw new PdfAConformanceException(MessageLocalization.getComposedMessage("incompatible.pdf.a.conformance.level", new Object[] { "u" }));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
package com.itextpdf.text.pdf;
|
||||
|
||||
import com.itextpdf.text.DocumentException;
|
||||
import com.itextpdf.text.Rectangle;
|
||||
import java.io.IOException;
|
||||
|
||||
public class PdfARadioCheckField extends RadioCheckField {
|
||||
private static final PdfName off = new PdfName("Off");
|
||||
|
||||
protected static final String check = "0.8 0 0 0.8 0.3 0.5 cm 0 0 m\n0.066 -0.026 l\n0.137 -0.15 l\n0.259 0.081 0.46 0.391 0.553 0.461 c\n0.604 0.489 l\n0.703 0.492 l\n0.543 0.312 0.255 -0.205 0.154 -0.439 c\n0.069 -0.399 l\n0.035 -0.293 -0.039 -0.136 -0.091 -0.057 c\nh\nf\n";
|
||||
|
||||
protected static final String circle = "1 0 0 1 0.86 0.5 cm 0 0 m\n0 0.204 -0.166 0.371 -0.371 0.371 c\n-0.575 0.371 -0.741 0.204 -0.741 0 c\n-0.741 -0.204 -0.575 -0.371 -0.371 -0.371 c\n-0.166 -0.371 0 -0.204 0 0 c\nf\n";
|
||||
|
||||
protected static final String cross = "1 0 0 1 0.85 0.8 cm 0 0 m\n-0.172 -0.027 l\n-0.332 -0.184 l\n-0.443 -0.019 l\n-0.475 -0.009 l\n-0.568 -0.168 l\n-0.453 -0.324 l\n-0.58 -0.497 l\n-0.59 -0.641 l\n-0.549 -0.627 l\n-0.543 -0.612 -0.457 -0.519 -0.365 -0.419 c\n-0.163 -0.572 l\n-0.011 -0.536 l\n-0.004 -0.507 l\n-0.117 -0.441 l\n-0.246 -0.294 l\n-0.132 -0.181 l\n0.031 -0.04 l\nh\nf\n";
|
||||
|
||||
protected static final String diamond = "1 0 0 1 0.55 0.12 cm 0 0 m\n0.376 0.376 l\n0 0.751 l\n-0.376 0.376 l\nh\nf\n";
|
||||
|
||||
protected static final String square = "1 0 0 1 0.885 0.835 cm 0 0 -0.669 -0.67 re\nf\n";
|
||||
|
||||
protected static final String star = "0.95 0 0 0.95 0.9 0.6 cm 0 0 m\n-0.291 0 l\n-0.381 0.277 l\n-0.47 0 l\n-0.761 0 l\n-0.526 -0.171 l\n-0.616 -0.448 l\n-0.381 -0.277 l\n-0.145 -0.448 l\n-0.236 -0.171 l\nh\nf\n";
|
||||
|
||||
protected static String[] typeStreams = new String[] { "0.8 0 0 0.8 0.3 0.5 cm 0 0 m\n0.066 -0.026 l\n0.137 -0.15 l\n0.259 0.081 0.46 0.391 0.553 0.461 c\n0.604 0.489 l\n0.703 0.492 l\n0.543 0.312 0.255 -0.205 0.154 -0.439 c\n0.069 -0.399 l\n0.035 -0.293 -0.039 -0.136 -0.091 -0.057 c\nh\nf\n", "1 0 0 1 0.86 0.5 cm 0 0 m\n0 0.204 -0.166 0.371 -0.371 0.371 c\n-0.575 0.371 -0.741 0.204 -0.741 0 c\n-0.741 -0.204 -0.575 -0.371 -0.371 -0.371 c\n-0.166 -0.371 0 -0.204 0 0 c\nf\n", "1 0 0 1 0.85 0.8 cm 0 0 m\n-0.172 -0.027 l\n-0.332 -0.184 l\n-0.443 -0.019 l\n-0.475 -0.009 l\n-0.568 -0.168 l\n-0.453 -0.324 l\n-0.58 -0.497 l\n-0.59 -0.641 l\n-0.549 -0.627 l\n-0.543 -0.612 -0.457 -0.519 -0.365 -0.419 c\n-0.163 -0.572 l\n-0.011 -0.536 l\n-0.004 -0.507 l\n-0.117 -0.441 l\n-0.246 -0.294 l\n-0.132 -0.181 l\n0.031 -0.04 l\nh\nf\n", "1 0 0 1 0.55 0.12 cm 0 0 m\n0.376 0.376 l\n0 0.751 l\n-0.376 0.376 l\nh\nf\n", "1 0 0 1 0.885 0.835 cm 0 0 -0.669 -0.67 re\nf\n", "0.95 0 0 0.95 0.9 0.6 cm 0 0 m\n-0.291 0 l\n-0.381 0.277 l\n-0.47 0 l\n-0.761 0 l\n-0.526 -0.171 l\n-0.616 -0.448 l\n-0.381 -0.277 l\n-0.145 -0.448 l\n-0.236 -0.171 l\nh\nf\n" };
|
||||
|
||||
public PdfARadioCheckField(PdfWriter writer, Rectangle box, String fieldName, String onValue) {
|
||||
super(writer, box, fieldName, onValue);
|
||||
}
|
||||
|
||||
protected PdfFormField getField(boolean isRadio) throws IOException, DocumentException {
|
||||
PdfFormField field = super.getField(isRadio);
|
||||
PdfDictionary ap = field.getAsDict(PdfName.AP);
|
||||
if (ap != null) {
|
||||
PdfDictionary n = ap.getAsDict(PdfName.N);
|
||||
if (n != null) {
|
||||
PdfObject stream = null;
|
||||
if (isChecked()) {
|
||||
stream = n.get(new PdfName(getOnValue()));
|
||||
} else {
|
||||
stream = n.get(off);
|
||||
}
|
||||
if (stream != null)
|
||||
ap.put(PdfName.N, stream);
|
||||
}
|
||||
}
|
||||
return field;
|
||||
}
|
||||
|
||||
public void setCheckType(int checkType) {
|
||||
if (checkType < 1 || checkType > 6)
|
||||
checkType = 2;
|
||||
this.checkType = checkType;
|
||||
}
|
||||
|
||||
public PdfAppearance getAppearance(boolean isRadio, boolean on) throws IOException, DocumentException {
|
||||
if (isRadio && this.checkType == 2)
|
||||
return getAppearanceRadioCircle(on);
|
||||
PdfAppearance app = getBorderAppearance();
|
||||
if (!on)
|
||||
return app;
|
||||
boolean borderExtra = (this.borderStyle == 2 || this.borderStyle == 3);
|
||||
float bw2 = this.borderWidth;
|
||||
if (borderExtra)
|
||||
bw2 *= 2.0F;
|
||||
float offsetX = borderExtra ? (2.0F * this.borderWidth) : this.borderWidth;
|
||||
offsetX = Math.max(offsetX, 1.0F);
|
||||
float offX = Math.min(bw2, offsetX);
|
||||
float wt = this.box.getWidth() - 2.0F * offX;
|
||||
float ht = this.box.getHeight() - 2.0F * offX;
|
||||
app.saveState();
|
||||
app.rectangle(offX, offX, wt, ht);
|
||||
app.clip();
|
||||
app.newPath();
|
||||
if (this.textColor == null) {
|
||||
app.resetGrayFill();
|
||||
} else {
|
||||
app.setColorFill(this.textColor);
|
||||
}
|
||||
float size = Math.min(this.box.getWidth(), this.box.getHeight());
|
||||
app.concatCTM(size, 0.0F, 0.0F, size, 0.0F, 0.0F);
|
||||
app.getInternalBuffer().append(typeStreams[this.checkType - 1]);
|
||||
app.restoreState();
|
||||
return app;
|
||||
}
|
||||
|
||||
protected BaseFont getRealFont() throws IOException, DocumentException {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
package com.itextpdf.text.pdf;
|
||||
|
||||
import com.itextpdf.text.Document;
|
||||
import com.itextpdf.text.DocumentException;
|
||||
import com.itextpdf.text.error_messages.MessageLocalization;
|
||||
import com.itextpdf.text.log.Logger;
|
||||
import com.itextpdf.text.log.LoggerFactory;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class PdfASmartCopy extends PdfACopy {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(PdfSmartCopy.class);
|
||||
|
||||
private HashMap<PdfSmartCopy.ByteStore, PdfIndirectReference> streamMap = null;
|
||||
|
||||
private final HashMap<RefKey, Integer> serialized = new HashMap<RefKey, Integer>();
|
||||
|
||||
public PdfASmartCopy(Document document, OutputStream os, PdfAConformanceLevel conformanceLevel) throws DocumentException {
|
||||
super(document, os, conformanceLevel);
|
||||
this.streamMap = new HashMap<PdfSmartCopy.ByteStore, PdfIndirectReference>();
|
||||
}
|
||||
|
||||
protected PdfIndirectReference copyIndirect(PRIndirectReference in) throws IOException, BadPdfFormatException {
|
||||
PdfIndirectReference theRef;
|
||||
PdfObject srcObj = PdfReader.getPdfObjectRelease((PdfObject)in);
|
||||
PdfSmartCopy.ByteStore streamKey = null;
|
||||
boolean validStream = false;
|
||||
if (srcObj.isStream()) {
|
||||
streamKey = new PdfSmartCopy.ByteStore((PRStream)srcObj, this.serialized);
|
||||
validStream = true;
|
||||
PdfIndirectReference streamRef = this.streamMap.get(streamKey);
|
||||
if (streamRef != null)
|
||||
return streamRef;
|
||||
} else if (srcObj.isDictionary()) {
|
||||
streamKey = new PdfSmartCopy.ByteStore((PdfDictionary)srcObj, this.serialized);
|
||||
validStream = true;
|
||||
PdfIndirectReference streamRef = this.streamMap.get(streamKey);
|
||||
if (streamRef != null)
|
||||
return streamRef;
|
||||
}
|
||||
RefKey key = new RefKey(in);
|
||||
PdfCopy.IndirectReferences iRef = (PdfCopy.IndirectReferences)this.indirects.get(key);
|
||||
if (iRef != null) {
|
||||
theRef = iRef.getRef();
|
||||
if (iRef.getCopied())
|
||||
return theRef;
|
||||
} else {
|
||||
theRef = this.body.getPdfIndirectReference();
|
||||
iRef = new PdfCopy.IndirectReferences(theRef);
|
||||
this.indirects.put(key, iRef);
|
||||
}
|
||||
if (srcObj.isDictionary()) {
|
||||
PdfObject type = PdfReader.getPdfObjectRelease(((PdfDictionary)srcObj).get(PdfName.TYPE));
|
||||
if (type != null) {
|
||||
if (PdfName.PAGE.equals(type))
|
||||
return theRef;
|
||||
if (PdfName.CATALOG.equals(type)) {
|
||||
LOGGER.warn(MessageLocalization.getComposedMessage("make.copy.of.catalog.dictionary.is.forbidden", new Object[0]));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
iRef.setCopied();
|
||||
if (validStream)
|
||||
this.streamMap.put(streamKey, theRef);
|
||||
PdfObject obj = copyObject(srcObj);
|
||||
addToBody(obj, theRef);
|
||||
return theRef;
|
||||
}
|
||||
|
||||
public void freeReader(PdfReader reader) throws IOException {
|
||||
this.serialized.clear();
|
||||
super.freeReader(reader);
|
||||
}
|
||||
|
||||
public void addPage(PdfImportedPage iPage) throws IOException, BadPdfFormatException {
|
||||
if (this.currentPdfReaderInstance.getReader() != this.reader)
|
||||
this.serialized.clear();
|
||||
super.addPage(iPage);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
package com.itextpdf.text.pdf;
|
||||
|
||||
import com.itextpdf.text.DocumentException;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public class PdfAStamper extends PdfStamper {
|
||||
public PdfAStamper(PdfReader reader, OutputStream os, PdfAConformanceLevel conformanceLevel) throws DocumentException, IOException {
|
||||
this.stamper = new PdfAStamperImp(reader, os, '\000', false, conformanceLevel);
|
||||
}
|
||||
|
||||
public PdfAStamper(PdfReader reader, OutputStream os, char pdfVersion, PdfAConformanceLevel conformanceLevel) throws DocumentException, IOException {
|
||||
this.stamper = new PdfAStamperImp(reader, os, pdfVersion, false, conformanceLevel);
|
||||
}
|
||||
|
||||
public PdfAStamper(PdfReader reader, OutputStream os, char pdfVersion, boolean append, PdfAConformanceLevel conformanceLevel) throws DocumentException, IOException {
|
||||
this.stamper = new PdfAStamperImp(reader, os, pdfVersion, append, conformanceLevel);
|
||||
}
|
||||
|
||||
public static PdfAStamper createSignature(PdfReader reader, OutputStream os, char pdfVersion, File tempFile, boolean append, PdfAConformanceLevel conformanceLevel) throws DocumentException, IOException {
|
||||
PdfAStamper stp;
|
||||
if (tempFile == null) {
|
||||
ByteBuffer bout = new ByteBuffer();
|
||||
stp = new PdfAStamper(reader, (OutputStream)bout, pdfVersion, append, conformanceLevel);
|
||||
stp.sigApp = new PdfSignatureAppearance(stp.stamper);
|
||||
stp.sigApp.setSigout(bout);
|
||||
} else {
|
||||
if (tempFile.isDirectory())
|
||||
tempFile = File.createTempFile("pdf", null, tempFile);
|
||||
FileOutputStream fout = new FileOutputStream(tempFile);
|
||||
stp = new PdfAStamper(reader, fout, pdfVersion, append, conformanceLevel);
|
||||
stp.sigApp = new PdfSignatureAppearance(stp.stamper);
|
||||
stp.sigApp.setTempFile(tempFile);
|
||||
}
|
||||
stp.sigApp.setOriginalout(os);
|
||||
stp.sigApp.setStamper(stp);
|
||||
stp.hasSignature = true;
|
||||
PdfDictionary catalog = reader.getCatalog();
|
||||
PdfDictionary acroForm = (PdfDictionary)PdfReader.getPdfObject(catalog.get(PdfName.ACROFORM), (PdfObject)catalog);
|
||||
if (acroForm != null) {
|
||||
acroForm.remove(PdfName.NEEDAPPEARANCES);
|
||||
stp.stamper.markUsed((PdfObject)acroForm);
|
||||
}
|
||||
return stp;
|
||||
}
|
||||
|
||||
public static PdfAStamper createSignature(PdfReader reader, OutputStream os, char pdfVersion, PdfAConformanceLevel conformanceLevel) throws DocumentException, IOException {
|
||||
return createSignature(reader, os, pdfVersion, null, false, conformanceLevel);
|
||||
}
|
||||
|
||||
public static PdfAStamper createSignature(PdfReader reader, OutputStream os, char pdfVersion, File tempFile, PdfAConformanceLevel conformanceLevel) throws DocumentException, IOException {
|
||||
return createSignature(reader, os, pdfVersion, tempFile, false, conformanceLevel);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,169 @@
|
|||
package com.itextpdf.text.pdf;
|
||||
|
||||
import com.itextpdf.text.DocumentException;
|
||||
import com.itextpdf.text.ExceptionConverter;
|
||||
import com.itextpdf.text.Image;
|
||||
import com.itextpdf.text.Rectangle;
|
||||
import com.itextpdf.text.error_messages.MessageLocalization;
|
||||
import com.itextpdf.text.log.Counter;
|
||||
import com.itextpdf.text.log.CounterFactory;
|
||||
import com.itextpdf.text.pdf.interfaces.PdfAConformance;
|
||||
import com.itextpdf.text.pdf.interfaces.PdfIsoConformance;
|
||||
import com.itextpdf.text.pdf.internal.PdfAChecker;
|
||||
import com.itextpdf.text.pdf.internal.PdfAConformanceImp;
|
||||
import com.itextpdf.text.xml.xmp.PdfAXmpWriter;
|
||||
import com.itextpdf.text.xml.xmp.XmpWriter;
|
||||
import com.itextpdf.xmp.XMPMeta;
|
||||
import com.itextpdf.xmp.impl.XMPMetaParser;
|
||||
import com.itextpdf.xmp.properties.XMPProperty;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class PdfAStamperImp extends PdfStamperImp {
|
||||
protected Counter COUNTER = CounterFactory.getCounter(PdfAStamper.class);
|
||||
|
||||
XMPMeta xmpMeta = null;
|
||||
|
||||
PdfAStamperImp(PdfReader reader, OutputStream os, char pdfVersion, boolean append, PdfAConformanceLevel conformanceLevel) throws DocumentException, IOException {
|
||||
super(reader, os, pdfVersion, append);
|
||||
((PdfAConformance)this.pdfIsoConformance).setConformanceLevel(conformanceLevel);
|
||||
PdfAWriter.setPdfVersion((PdfWriter)this, conformanceLevel);
|
||||
readPdfAInfo();
|
||||
}
|
||||
|
||||
protected void readColorProfile() {
|
||||
PdfArray pdfArray = this.reader.getCatalog().getAsArray(PdfName.OUTPUTINTENTS);
|
||||
if (pdfArray != null && pdfArray.size() > 0) {
|
||||
PdfStream iccProfileStream = null;
|
||||
for (int i = 0; i < pdfArray.size(); i++) {
|
||||
PdfDictionary outputIntentDictionary = pdfArray.getAsDict(i);
|
||||
if (outputIntentDictionary != null) {
|
||||
PdfName gts = outputIntentDictionary.getAsName(PdfName.S);
|
||||
if (iccProfileStream == null || PdfName.GTS_PDFA1.equals(gts)) {
|
||||
iccProfileStream = outputIntentDictionary.getAsStream(PdfName.DESTOUTPUTPROFILE);
|
||||
if (iccProfileStream != null && PdfName.GTS_PDFA1.equals(gts))
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (iccProfileStream instanceof PRStream)
|
||||
try {
|
||||
this.colorProfile = ICC_Profile.getInstance(PdfReader.getStreamBytes((PRStream)iccProfileStream));
|
||||
} catch (IOException exc) {
|
||||
throw new ExceptionConverter(exc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setOutputIntents(String outputConditionIdentifier, String outputCondition, String registryName, String info, ICC_Profile colorProfile) throws IOException {
|
||||
super.setOutputIntents(outputConditionIdentifier, outputCondition, registryName, info, colorProfile);
|
||||
PdfArray a = this.extraCatalog.getAsArray(PdfName.OUTPUTINTENTS);
|
||||
if (a != null) {
|
||||
PdfDictionary d = a.getAsDict(0);
|
||||
if (d != null)
|
||||
d.put(PdfName.S, (PdfObject)PdfName.GTS_PDFA1);
|
||||
}
|
||||
}
|
||||
|
||||
public void setPDFXConformance(int pdfx) {
|
||||
throw new PdfAConformanceException(MessageLocalization.getComposedMessage("pdfx.conformance.cannot.be.set.for.PdfAStamperImp.instance", new Object[0]));
|
||||
}
|
||||
|
||||
protected TtfUnicodeWriter getTtfUnicodeWriter() {
|
||||
if (this.ttfUnicodeWriter == null)
|
||||
this.ttfUnicodeWriter = new PdfATtfUnicodeWriter((PdfWriter)this, ((PdfAConformance)this.pdfIsoConformance).getConformanceLevel());
|
||||
return this.ttfUnicodeWriter;
|
||||
}
|
||||
|
||||
protected XmpWriter createXmpWriter(ByteArrayOutputStream baos, PdfDictionary info) throws IOException {
|
||||
return new PdfAXmpWriter(baos, info, ((PdfAConformance)this.pdfIsoConformance).getConformanceLevel(), (PdfWriter)this);
|
||||
}
|
||||
|
||||
protected XmpWriter createXmpWriter(ByteArrayOutputStream baos, HashMap<String, String> info) throws IOException {
|
||||
return new PdfAXmpWriter(baos, info, ((PdfAConformance)this.pdfIsoConformance).getConformanceLevel(), (PdfWriter)this);
|
||||
}
|
||||
|
||||
protected PdfIsoConformance initPdfIsoConformance() {
|
||||
return new PdfAConformanceImp((PdfWriter)this);
|
||||
}
|
||||
|
||||
protected Counter getCounter() {
|
||||
return this.COUNTER;
|
||||
}
|
||||
|
||||
private void readPdfAInfo() {
|
||||
byte[] metadata = null;
|
||||
XMPProperty pdfaidConformance = null;
|
||||
XMPProperty pdfaidPart = null;
|
||||
try {
|
||||
metadata = this.reader.getMetadata();
|
||||
this.xmpMeta = XMPMetaParser.parse(metadata, null);
|
||||
pdfaidConformance = this.xmpMeta.getProperty("http://www.aiim.org/pdfa/ns/id/", "pdfaid:conformance");
|
||||
pdfaidPart = this.xmpMeta.getProperty("http://www.aiim.org/pdfa/ns/id/", "pdfaid:part");
|
||||
} catch (Throwable e) {
|
||||
throw new PdfAConformanceException(MessageLocalization.getComposedMessage("only.pdfa.documents.can.be.opened.in.PdfAStamper", new Object[0]));
|
||||
}
|
||||
if (pdfaidConformance == null || pdfaidPart == null)
|
||||
throw new PdfAConformanceException(MessageLocalization.getComposedMessage("only.pdfa.documents.can.be.opened.in.PdfAStamper", new Object[0]));
|
||||
switch (((PdfAConformance)this.pdfIsoConformance).getConformanceLevel()) {
|
||||
case PDF_A_1A:
|
||||
case PDF_A_1B:
|
||||
if (!"1".equals(pdfaidPart.getValue()))
|
||||
throw new PdfAConformanceException(MessageLocalization.getComposedMessage("only.pdfa.1.documents.can.be.opened.in.PdfAStamper", new Object[] { "1" }));
|
||||
break;
|
||||
case PDF_A_2A:
|
||||
case PDF_A_2B:
|
||||
case PDF_A_2U:
|
||||
if (!"2".equals(pdfaidPart.getValue()))
|
||||
throw new PdfAConformanceException(MessageLocalization.getComposedMessage("only.pdfa.1.documents.can.be.opened.in.PdfAStamper", new Object[] { "2" }));
|
||||
break;
|
||||
case PDF_A_3A:
|
||||
case PDF_A_3B:
|
||||
case PDF_A_3U:
|
||||
if (!"3".equals(pdfaidPart.getValue()))
|
||||
throw new PdfAConformanceException(MessageLocalization.getComposedMessage("only.pdfa.1.documents.can.be.opened.in.PdfAStamper", new Object[] { "3" }));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected void cacheObject(PdfIndirectObject iobj) {
|
||||
getPdfAChecker().cacheObject(iobj.getIndirectReference(), iobj.object);
|
||||
}
|
||||
|
||||
private PdfAChecker getPdfAChecker() {
|
||||
return ((PdfAConformanceImp)this.pdfIsoConformance).getPdfAChecker();
|
||||
}
|
||||
|
||||
protected void close(Map<String, String> moreInfo) throws IOException {
|
||||
super.close(moreInfo);
|
||||
getPdfAChecker().close((PdfWriter)this);
|
||||
}
|
||||
|
||||
public PdfAnnotation createAnnotation(Rectangle rect, PdfName subtype) {
|
||||
PdfAnnotation a = super.createAnnotation(rect, subtype);
|
||||
if (!PdfName.POPUP.equals(subtype))
|
||||
a.put(PdfName.F, new PdfNumber(4));
|
||||
return a;
|
||||
}
|
||||
|
||||
public PdfAnnotation createAnnotation(float llx, float lly, float urx, float ury, PdfString title, PdfString content, PdfName subtype) {
|
||||
PdfAnnotation a = super.createAnnotation(llx, lly, urx, ury, title, content, subtype);
|
||||
if (!PdfName.POPUP.equals(subtype))
|
||||
a.put(PdfName.F, new PdfNumber(4));
|
||||
return a;
|
||||
}
|
||||
|
||||
public PdfAnnotation createAnnotation(float llx, float lly, float urx, float ury, PdfAction action, PdfName subtype) {
|
||||
PdfAnnotation a = super.createAnnotation(llx, lly, urx, ury, action, subtype);
|
||||
if (!PdfName.POPUP.equals(subtype))
|
||||
a.put(PdfName.F, new PdfNumber(4));
|
||||
return a;
|
||||
}
|
||||
|
||||
public XMPMeta getXmpMeta() {
|
||||
return this.xmpMeta;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
package com.itextpdf.text.pdf;
|
||||
|
||||
import com.itextpdf.text.DocumentException;
|
||||
import com.itextpdf.text.log.LoggerFactory;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class PdfATtfUnicodeWriter extends TtfUnicodeWriter {
|
||||
protected final PdfAConformanceLevel pdfAConformanceLevel;
|
||||
|
||||
public PdfATtfUnicodeWriter(PdfWriter writer, PdfAConformanceLevel pdfAConformanceLevel) {
|
||||
super(writer);
|
||||
this.pdfAConformanceLevel = pdfAConformanceLevel;
|
||||
}
|
||||
|
||||
public void writeFont(TrueTypeFontUnicode font, PdfIndirectReference ref, Object[] params, byte[] rotbits) throws DocumentException, IOException {
|
||||
HashMap<Integer, int[]> longTag = (HashMap<Integer, int[]>)params[0];
|
||||
font.addRangeUni(longTag, true, font.subset);
|
||||
int[][] metrics = (int[][])longTag.values().toArray(new int[0][]);
|
||||
Arrays.<int[]>sort(metrics, font);
|
||||
if (font.cff) {
|
||||
byte[] b = font.readCffFont();
|
||||
if (font.subset || font.subsetRanges != null) {
|
||||
CFFFontSubset cff = new CFFFontSubset(new RandomAccessFileOrArray(b), longTag);
|
||||
try {
|
||||
b = cff.Process(cff.getNames()[0]);
|
||||
} catch (Exception e) {
|
||||
LoggerFactory.getLogger(PdfATtfUnicodeWriter.class).error("Issue in CFF font subsetting.Subsetting was disabled", e);
|
||||
font.setSubset(false);
|
||||
font.addRangeUni(longTag, true, font.subset);
|
||||
metrics = (int[][])longTag.values().toArray(new int[0][]);
|
||||
Arrays.<int[]>sort(metrics, font);
|
||||
}
|
||||
}
|
||||
BaseFont.StreamFont streamFont = new BaseFont.StreamFont(b, "CIDFontType0C", font.compressionLevel);
|
||||
PdfIndirectObject obj = this.writer.addToBody((PdfObject)streamFont);
|
||||
ind_font = obj.getIndirectReference();
|
||||
} else {
|
||||
byte[] b;
|
||||
if (font.subset || font.directoryOffset != 0) {
|
||||
synchronized (font.rf) {
|
||||
TrueTypeFontSubSet sb = new TrueTypeFontSubSet(font.fileName, new RandomAccessFileOrArray(font.rf), new HashSet(longTag.keySet()), font.directoryOffset, false, false);
|
||||
b = sb.process();
|
||||
}
|
||||
} else {
|
||||
b = font.getFullFont();
|
||||
}
|
||||
int[] lengths = { b.length };
|
||||
BaseFont.StreamFont streamFont = new BaseFont.StreamFont(b, lengths, font.compressionLevel);
|
||||
PdfIndirectObject obj = this.writer.addToBody((PdfObject)streamFont);
|
||||
ind_font = obj.getIndirectReference();
|
||||
}
|
||||
byte[] cidSetBytes = new byte[font.maxGlyphId / 8 + 1];
|
||||
for (int j = 0; j < font.maxGlyphId / 8; j++)
|
||||
cidSetBytes[j] = (byte)(cidSetBytes[j] | 0xFF);
|
||||
for (int i = 0; i < font.maxGlyphId % 8; i++)
|
||||
cidSetBytes[cidSetBytes.length - 1] = (byte)(cidSetBytes[cidSetBytes.length - 1] | rotbits[i]);
|
||||
PdfStream stream = new PdfStream(cidSetBytes);
|
||||
stream.flateCompress(font.compressionLevel);
|
||||
PdfIndirectReference cidset = this.writer.addToBody((PdfObject)stream).getIndirectReference();
|
||||
String subsetPrefix = "";
|
||||
if (font.subset)
|
||||
subsetPrefix = BaseFont.createSubsetPrefix();
|
||||
PdfDictionary dic = font.getFontDescriptor(ind_font, subsetPrefix, cidset);
|
||||
PdfIndirectObject pdfIndirectObject = this.writer.addToBody((PdfObject)dic);
|
||||
PdfIndirectReference ind_font = pdfIndirectObject.getIndirectReference();
|
||||
PdfDictionary pdfDictionary2 = font.getCIDFontType2(ind_font, subsetPrefix, (Object[])metrics);
|
||||
pdfIndirectObject = this.writer.addToBody((PdfObject)pdfDictionary2);
|
||||
ind_font = pdfIndirectObject.getIndirectReference();
|
||||
PdfStream pdfStream1 = font.getToUnicode((Object[])metrics);
|
||||
PdfIndirectReference toUnicodeRef = null;
|
||||
if (pdfStream1 != null) {
|
||||
pdfIndirectObject = this.writer.addToBody((PdfObject)pdfStream1);
|
||||
toUnicodeRef = pdfIndirectObject.getIndirectReference();
|
||||
}
|
||||
PdfDictionary pdfDictionary1 = font.getFontBaseType(ind_font, subsetPrefix, toUnicodeRef);
|
||||
this.writer.addToBody((PdfObject)pdfDictionary1, ref);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,206 @@
|
|||
package com.itextpdf.text.pdf;
|
||||
|
||||
import com.itextpdf.text.DocListener;
|
||||
import com.itextpdf.text.Document;
|
||||
import com.itextpdf.text.DocumentException;
|
||||
import com.itextpdf.text.Rectangle;
|
||||
import com.itextpdf.text.error_messages.MessageLocalization;
|
||||
import com.itextpdf.text.io.TempFileCache;
|
||||
import com.itextpdf.text.log.Counter;
|
||||
import com.itextpdf.text.log.CounterFactory;
|
||||
import com.itextpdf.text.pdf.interfaces.PdfAConformance;
|
||||
import com.itextpdf.text.pdf.interfaces.PdfIsoConformance;
|
||||
import com.itextpdf.text.pdf.internal.PdfAChecker;
|
||||
import com.itextpdf.text.pdf.internal.PdfAConformanceImp;
|
||||
import com.itextpdf.text.xml.xmp.PdfAXmpWriter;
|
||||
import com.itextpdf.text.xml.xmp.XmpWriter;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class PdfAWriter extends PdfWriter {
|
||||
public static String MimeTypePdf = "application/pdf";
|
||||
|
||||
public static String MimeTypeOctetStream = "application/octet-stream";
|
||||
|
||||
public static PdfAWriter getInstance(Document document, OutputStream os, PdfAConformanceLevel conformanceLevel) throws DocumentException {
|
||||
PdfDocument pdf = new PdfDocument();
|
||||
document.addDocListener((DocListener)pdf);
|
||||
PdfAWriter writer = new PdfAWriter(pdf, os, conformanceLevel);
|
||||
pdf.addWriter(writer);
|
||||
return writer;
|
||||
}
|
||||
|
||||
public static PdfAWriter getInstance(Document document, OutputStream os, DocListener listener, PdfAConformanceLevel conformanceLevel) throws DocumentException {
|
||||
PdfDocument pdf = new PdfDocument();
|
||||
pdf.addDocListener(listener);
|
||||
document.addDocListener((DocListener)pdf);
|
||||
PdfAWriter writer = new PdfAWriter(pdf, os, conformanceLevel);
|
||||
pdf.addWriter(writer);
|
||||
return writer;
|
||||
}
|
||||
|
||||
public static void setPdfVersion(PdfWriter writer, PdfAConformanceLevel conformanceLevel) {
|
||||
switch (conformanceLevel) {
|
||||
case PDF_A_1A:
|
||||
case PDF_A_1B:
|
||||
writer.setPdfVersion('4');
|
||||
break;
|
||||
case PDF_A_2A:
|
||||
case PDF_A_2B:
|
||||
case PDF_A_2U:
|
||||
writer.setPdfVersion('7');
|
||||
break;
|
||||
case PDF_A_3A:
|
||||
case PDF_A_3B:
|
||||
case PDF_A_3U:
|
||||
writer.setPdfVersion('7');
|
||||
break;
|
||||
default:
|
||||
writer.setPdfVersion('4');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void setOutputIntents(String outputConditionIdentifier, String outputCondition, String registryName, String info, ICC_Profile colorProfile) throws IOException {
|
||||
super.setOutputIntents(outputConditionIdentifier, outputCondition, registryName, info, colorProfile);
|
||||
PdfArray a = this.extraCatalog.getAsArray(PdfName.OUTPUTINTENTS);
|
||||
if (a != null) {
|
||||
PdfDictionary d = a.getAsDict(0);
|
||||
if (d != null)
|
||||
d.put(PdfName.S, (PdfObject)PdfName.GTS_PDFA1);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean setOutputIntents(PdfReader reader, boolean checkExistence) throws IOException {
|
||||
PdfDictionary catalog = reader.catalog;
|
||||
PdfArray outs = catalog.getAsArray(PdfName.OUTPUTINTENTS);
|
||||
if (outs == null)
|
||||
return false;
|
||||
if (outs.size() == 0)
|
||||
return false;
|
||||
PdfDictionary outa = outs.getAsDict(0);
|
||||
PdfObject obj = PdfReader.getPdfObject(outa.get(PdfName.S));
|
||||
if (obj == null || !PdfName.GTS_PDFA1.equals(obj))
|
||||
return false;
|
||||
if (checkExistence)
|
||||
return true;
|
||||
PRStream stream = (PRStream)PdfReader.getPdfObject(outa.get(PdfName.DESTOUTPUTPROFILE));
|
||||
byte[] destProfile = null;
|
||||
if (stream != null)
|
||||
destProfile = PdfReader.getStreamBytes(stream);
|
||||
setOutputIntents(getNameString(outa, PdfName.OUTPUTCONDITIONIDENTIFIER), getNameString(outa, PdfName.OUTPUTCONDITION),
|
||||
getNameString(outa, PdfName.REGISTRYNAME), getNameString(outa, PdfName.INFO), destProfile);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setPDFXConformance(int pdfx) {
|
||||
throw new PdfXConformanceException(MessageLocalization.getComposedMessage("pdfx.conformance.cannot.be.set.for.PdfAWriter.instance", new Object[0]));
|
||||
}
|
||||
|
||||
protected PdfAWriter(PdfAConformanceLevel conformanceLevel) {
|
||||
((PdfAConformance)this.pdfIsoConformance).setConformanceLevel(conformanceLevel);
|
||||
setPdfVersion(this, conformanceLevel);
|
||||
}
|
||||
|
||||
protected PdfAWriter(PdfDocument document, OutputStream os, PdfAConformanceLevel conformanceLevel) {
|
||||
super(document, os);
|
||||
((PdfAConformance)this.pdfIsoConformance).setConformanceLevel(conformanceLevel);
|
||||
setPdfVersion(this, conformanceLevel);
|
||||
}
|
||||
|
||||
protected TtfUnicodeWriter getTtfUnicodeWriter() {
|
||||
if (this.ttfUnicodeWriter == null)
|
||||
this.ttfUnicodeWriter = new PdfATtfUnicodeWriter(this, ((PdfAConformance)this.pdfIsoConformance).getConformanceLevel());
|
||||
return this.ttfUnicodeWriter;
|
||||
}
|
||||
|
||||
protected XmpWriter createXmpWriter(ByteArrayOutputStream baos, PdfDictionary info) throws IOException {
|
||||
return this.xmpWriter = new PdfAXmpWriter(baos, info, ((PdfAConformance)this.pdfIsoConformance).getConformanceLevel(), this);
|
||||
}
|
||||
|
||||
protected XmpWriter createXmpWriter(ByteArrayOutputStream baos, HashMap<String, String> info) throws IOException {
|
||||
return this.xmpWriter = new PdfAXmpWriter(baos, info, ((PdfAConformance)this.pdfIsoConformance).getConformanceLevel(), this);
|
||||
}
|
||||
|
||||
protected PdfIsoConformance initPdfIsoConformance() {
|
||||
return new PdfAConformanceImp(this);
|
||||
}
|
||||
|
||||
protected Counter COUNTER = CounterFactory.getCounter(PdfAWriter.class);
|
||||
|
||||
protected Counter getCounter() {
|
||||
return this.COUNTER;
|
||||
}
|
||||
|
||||
protected void cacheObject(PdfIndirectObject iobj) {
|
||||
getPdfAChecker().cacheObject(iobj.getIndirectReference(), iobj.object);
|
||||
}
|
||||
|
||||
private PdfAChecker getPdfAChecker() {
|
||||
return ((PdfAConformanceImp)this.pdfIsoConformance).getPdfAChecker();
|
||||
}
|
||||
|
||||
public PdfFileSpecification addFileAttachment(String description, byte[] fileStore, String file, String fileDisplay, String mimeType, PdfName afRelationshipValue, PdfDictionary fileParameter) throws IOException {
|
||||
PdfFileSpecification pdfFileSpecification = PdfFileSpecification.fileEmbedded(this, file, fileDisplay, fileStore, mimeType, fileParameter, 9);
|
||||
if (afRelationshipValue != null) {
|
||||
pdfFileSpecification.put(PdfName.AFRELATIONSHIP, (PdfObject)afRelationshipValue);
|
||||
} else {
|
||||
pdfFileSpecification.put(PdfName.AFRELATIONSHIP, (PdfObject)AFRelationshipValue.Unspecified);
|
||||
}
|
||||
addFileAttachment(description, pdfFileSpecification);
|
||||
return pdfFileSpecification;
|
||||
}
|
||||
|
||||
public PdfFileSpecification addFileAttachment(String description, byte[] fileStore, String file, String fileDisplay, String mimeType, PdfName afRelationshipValue) throws IOException {
|
||||
return addFileAttachment(description, fileStore, file, fileDisplay, mimeType, afRelationshipValue, null);
|
||||
}
|
||||
|
||||
public void addFileAttachment(String description, byte[] fileStore, String file, String fileDisplay, PdfName afRelationshipValue) throws IOException {
|
||||
addFileAttachment(description, fileStore, file, fileDisplay, MimeTypeOctetStream, afRelationshipValue);
|
||||
}
|
||||
|
||||
public void addFileAttachment(String description, byte[] fileStore, String file, String fileDisplay) throws IOException {
|
||||
addFileAttachment(description, fileStore, file, fileDisplay, AFRelationshipValue.Unspecified);
|
||||
}
|
||||
|
||||
public void addPdfAttachment(String description, byte[] fileStore, String file, String fileDisplay) throws IOException {
|
||||
addPdfAttachment(description, fileStore, file, fileDisplay, AFRelationshipValue.Unspecified);
|
||||
}
|
||||
|
||||
public void addPdfAttachment(String description, byte[] fileStore, String file, String fileDisplay, PdfName afRelationshipValue) throws IOException {
|
||||
addFileAttachment(description, fileStore, file, fileDisplay, MimeTypePdf, afRelationshipValue);
|
||||
}
|
||||
|
||||
public void close() {
|
||||
super.close();
|
||||
getPdfAChecker().close(this);
|
||||
}
|
||||
|
||||
public PdfAnnotation createAnnotation(Rectangle rect, PdfName subtype) {
|
||||
PdfAnnotation a = super.createAnnotation(rect, subtype);
|
||||
if (!PdfName.POPUP.equals(subtype))
|
||||
a.put(PdfName.F, new PdfNumber(4));
|
||||
return a;
|
||||
}
|
||||
|
||||
public PdfAnnotation createAnnotation(float llx, float lly, float urx, float ury, PdfString title, PdfString content, PdfName subtype) {
|
||||
PdfAnnotation a = super.createAnnotation(llx, lly, urx, ury, title, content, subtype);
|
||||
if (!PdfName.POPUP.equals(subtype))
|
||||
a.put(PdfName.F, new PdfNumber(4));
|
||||
return a;
|
||||
}
|
||||
|
||||
public PdfAnnotation createAnnotation(float llx, float lly, float urx, float ury, PdfAction action, PdfName subtype) {
|
||||
PdfAnnotation a = super.createAnnotation(llx, lly, urx, ury, action, subtype);
|
||||
if (!PdfName.POPUP.equals(subtype))
|
||||
a.put(PdfName.F, new PdfNumber(4));
|
||||
return a;
|
||||
}
|
||||
|
||||
public void useExternalCacheForPdfA(TempFileCache fileCache) {
|
||||
if (this.pdfIsoConformance instanceof PdfAConformanceImp)
|
||||
((PdfAConformanceImp)this.pdfIsoConformance).getPdfAChecker().useExternalCache(fileCache);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.itextpdf.text.pdf.interfaces;
|
||||
|
||||
import com.itextpdf.text.pdf.PdfAConformanceLevel;
|
||||
|
||||
public interface PdfAConformance extends PdfIsoConformance {
|
||||
PdfAConformanceLevel getConformanceLevel();
|
||||
|
||||
void setConformanceLevel(PdfAConformanceLevel paramPdfAConformanceLevel);
|
||||
}
|
||||
|
|
@ -0,0 +1,439 @@
|
|||
package com.itextpdf.text.pdf.internal;
|
||||
|
||||
import com.itextpdf.text.ExceptionConverter;
|
||||
import com.itextpdf.text.error_messages.MessageLocalization;
|
||||
import com.itextpdf.text.pdf.BaseFont;
|
||||
import com.itextpdf.text.pdf.DocumentFont;
|
||||
import com.itextpdf.text.pdf.ExtendedColor;
|
||||
import com.itextpdf.text.pdf.ICC_Profile;
|
||||
import com.itextpdf.text.pdf.PatternColor;
|
||||
import com.itextpdf.text.pdf.PdfAConformanceException;
|
||||
import com.itextpdf.text.pdf.PdfAConformanceLevel;
|
||||
import com.itextpdf.text.pdf.PdfAWriter;
|
||||
import com.itextpdf.text.pdf.PdfAcroForm;
|
||||
import com.itextpdf.text.pdf.PdfAction;
|
||||
import com.itextpdf.text.pdf.PdfAnnotation;
|
||||
import com.itextpdf.text.pdf.PdfArray;
|
||||
import com.itextpdf.text.pdf.PdfBoolean;
|
||||
import com.itextpdf.text.pdf.PdfDictionary;
|
||||
import com.itextpdf.text.pdf.PdfFileSpecification;
|
||||
import com.itextpdf.text.pdf.PdfFormField;
|
||||
import com.itextpdf.text.pdf.PdfGState;
|
||||
import com.itextpdf.text.pdf.PdfImage;
|
||||
import com.itextpdf.text.pdf.PdfName;
|
||||
import com.itextpdf.text.pdf.PdfNumber;
|
||||
import com.itextpdf.text.pdf.PdfObject;
|
||||
import com.itextpdf.text.pdf.PdfStream;
|
||||
import com.itextpdf.text.pdf.PdfString;
|
||||
import com.itextpdf.text.pdf.PdfStructureElement;
|
||||
import com.itextpdf.text.pdf.PdfWriter;
|
||||
import com.itextpdf.text.pdf.ShadingColor;
|
||||
import com.itextpdf.text.pdf.SpotColor;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class PdfA1Checker extends PdfAChecker {
|
||||
public static final PdfName setState = new PdfName("SetState");
|
||||
|
||||
public static final PdfName noOp = new PdfName("NoOp");
|
||||
|
||||
private static HashSet<PdfName> allowedAnnotTypes = new HashSet<PdfName>(Arrays.<PdfName>asList(PdfName.TEXT, PdfName.LINK, PdfName.FREETEXT, PdfName.LINE, PdfName.SQUARE, PdfName.CIRCLE, PdfName.HIGHLIGHT, PdfName.UNDERLINE, PdfName.SQUIGGLY, PdfName.STRIKEOUT, PdfName.STAMP, PdfName.INK, PdfName.POPUP, PdfName.WIDGET, PdfName.PRINTERMARK, PdfName.TRAPNET));
|
||||
|
||||
public static final HashSet<PdfName> allowedNamedActions = new HashSet<PdfName>(Arrays.<PdfName>asList(PdfName.NEXTPAGE, PdfName.PREVPAGE, PdfName.FIRSTPAGE, PdfName.LASTPAGE));
|
||||
|
||||
private static HashSet<PdfName> restrictedActions = new HashSet<PdfName>(Arrays.<PdfName>asList(PdfName.LAUNCH, PdfName.SOUND, PdfName.MOVIE, PdfName.RESETFORM, PdfName.IMPORTDATA, PdfName.JAVASCRIPT));
|
||||
|
||||
public static final HashSet<PdfName> contentAnnotations = new HashSet<PdfName>(Arrays.<PdfName>asList(PdfName.TEXT, PdfName.FREETEXT, PdfName.LINE, PdfName.SQUARE, PdfName.CIRCLE, PdfName.STAMP, PdfName.INK, PdfName.POPUP));
|
||||
|
||||
private static final HashSet<PdfName> keysForCheck = new HashSet<PdfName>(Arrays.<PdfName>asList(PdfName.FONTDESCRIPTOR, PdfName.FONTFILE, PdfName.FONTFILE2, PdfName.FONTFILE3, PdfName.FILTER, PdfName.GROUP, PdfName.S, PdfName.EMBEDDEDFILES, PdfName.MARKED, PdfName.DESTOUTPUTPROFILE));
|
||||
|
||||
public static final double maxRealValue = 32767.0D;
|
||||
|
||||
public static final int maxStringLength = 65535;
|
||||
|
||||
public static final int maxArrayLength = 8191;
|
||||
|
||||
public static final int maxDictionaryLength = 4095;
|
||||
|
||||
public static final int maxGsStackDepth = 28;
|
||||
|
||||
protected int gsStackDepth = 0;
|
||||
|
||||
protected boolean rgbUsed = false;
|
||||
|
||||
protected boolean cmykUsed = false;
|
||||
|
||||
protected boolean grayUsed = false;
|
||||
|
||||
PdfA1Checker(PdfAConformanceLevel conformanceLevel) {
|
||||
super(conformanceLevel);
|
||||
}
|
||||
|
||||
protected HashSet<PdfName> initKeysForCheck() {
|
||||
return keysForCheck;
|
||||
}
|
||||
|
||||
protected void checkFont(PdfWriter writer, int key, Object obj1) {
|
||||
BaseFont bf = (BaseFont)obj1;
|
||||
if (bf.getFontType() == 4) {
|
||||
PdfStream prs = null;
|
||||
PdfDictionary fontDictionary = ((DocumentFont)bf).getFontDictionary();
|
||||
PdfDictionary fontDescriptor = getDirectDictionary(fontDictionary.get(PdfName.FONTDESCRIPTOR));
|
||||
if (fontDescriptor != null) {
|
||||
prs = getDirectStream(fontDescriptor.get(PdfName.FONTFILE));
|
||||
if (prs == null)
|
||||
prs = getDirectStream(fontDescriptor.get(PdfName.FONTFILE2));
|
||||
if (prs == null)
|
||||
prs = getDirectStream(fontDescriptor.get(PdfName.FONTFILE3));
|
||||
}
|
||||
if (prs == null)
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("all.the.fonts.must.be.embedded.this.one.isn.t.1", new Object[] { ((BaseFont)obj1).getPostscriptFontName() }));
|
||||
} else if (!bf.isEmbedded()) {
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("all.the.fonts.must.be.embedded.this.one.isn.t.1", new Object[] { ((BaseFont)obj1).getPostscriptFontName() }));
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkImage(PdfWriter writer, int key, Object obj1) {
|
||||
PdfImage image = (PdfImage)obj1;
|
||||
if (image.get(PdfName.SMASK) != null && !PdfName.NONE.equals(image.getAsName(PdfName.SMASK)))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("the.smask.key.is.not.allowed.in.images", new Object[0]));
|
||||
if (image.contains(PdfName.ALTERNATES))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("an.image.dictionary.shall.not.contain.alternates.key", new Object[0]));
|
||||
if (image.contains(PdfName.OPI))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("an.image.dictionary.shall.not.contain.opi.key", new Object[0]));
|
||||
PdfBoolean interpolate = image.getAsBoolean(PdfName.INTERPOLATE);
|
||||
if (interpolate != null && interpolate.booleanValue())
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("the.value.of.interpolate.key.shall.not.be.true", new Object[0]));
|
||||
PdfName intent = image.getAsName(PdfName.INTENT);
|
||||
if (intent != null && !PdfName.RELATIVECOLORIMETRIC.equals(intent) && !PdfName.ABSOLUTECOLORIMETRIC.equals(intent) && !PdfName.PERCEPTUAL.equals(intent) && !PdfName.SATURATION.equals(intent))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("1.value.of.intent.key.is.not.allowed", new Object[] { intent.toString() }));
|
||||
}
|
||||
|
||||
protected void checkFormXObj(PdfWriter writer, int key, Object obj1) {}
|
||||
|
||||
protected void checkInlineImage(PdfWriter writer, int key, Object obj1) {}
|
||||
|
||||
protected void checkGState(PdfWriter writer, int key, Object obj1) {
|
||||
if (obj1 instanceof PdfDictionary) {
|
||||
PdfDictionary gs = (PdfDictionary)obj1;
|
||||
PdfObject obj = gs.get(PdfName.BM);
|
||||
if (obj != null && !PdfGState.BM_NORMAL.equals(obj) && !PdfGState.BM_COMPATIBLE.equals(obj))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("blend.mode.1.not.allowed", new Object[] { obj.toString() }));
|
||||
obj = gs.get(PdfName.CA);
|
||||
double v = 0.0D;
|
||||
if (obj != null && (v = ((PdfNumber)obj).doubleValue()) != 1.0D)
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("transparency.is.not.allowed.ca.eq.1", new Object[] { String.valueOf(v) }));
|
||||
obj = gs.get(PdfName.ca);
|
||||
v = 0.0D;
|
||||
if (obj != null && (v = ((PdfNumber)obj).doubleValue()) != 1.0D)
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("transparency.is.not.allowed.ca.eq.1", new Object[] { String.valueOf(v) }));
|
||||
if (gs.contains(PdfName.TR))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("an.extgstate.dictionary.shall.not.contain.the.tr.key", new Object[0]));
|
||||
PdfName tr2 = gs.getAsName(PdfName.TR2);
|
||||
if (tr2 != null && !tr2.equals(PdfName.DEFAULT))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("an.extgstate.dictionary.shall.not.contain.the.TR2.key.with.a.value.other.than.default", new Object[0]));
|
||||
PdfName ri = gs.getAsName(PdfName.RI);
|
||||
if (ri != null && !PdfName.RELATIVECOLORIMETRIC.equals(ri) && !PdfName.ABSOLUTECOLORIMETRIC.equals(ri) && !PdfName.PERCEPTUAL.equals(ri) && !PdfName.SATURATION.equals(ri))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("1.value.of.ri.key.is.not.allowed", new Object[] { ri.toString() }));
|
||||
if (gs.get(PdfName.SMASK) != null && !PdfName.NONE.equals(gs.getAsName(PdfName.SMASK)))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("the.smask.key.is.not.allowed.in.extgstate", new Object[0]));
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkLayer(PdfWriter writer, int key, Object obj1) {
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("layers.are.not.allowed", new Object[0]));
|
||||
}
|
||||
|
||||
protected void checkTrailer(PdfWriter writer, int key, Object obj1) {
|
||||
if (obj1 instanceof PdfWriter.PdfTrailer) {
|
||||
PdfWriter.PdfTrailer trailer = (PdfWriter.PdfTrailer)obj1;
|
||||
if (trailer.get(PdfName.ENCRYPT) != null)
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("keyword.encrypt.shall.not.be.used.in.the.trailer.dictionary", new Object[0]));
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkStream(PdfWriter writer, int key, Object obj1) {
|
||||
if (obj1 instanceof PdfStream) {
|
||||
PdfStream stream = (PdfStream)obj1;
|
||||
if (stream.contains(PdfName.F) || stream.contains(PdfName.FFILTER) || stream.contains(PdfName.FDECODEPARMS))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("stream.object.dictionary.shall.not.contain.the.f.ffilter.or.fdecodeparams.keys", new Object[0]));
|
||||
PdfObject filter = getDirectObject(stream.get(PdfName.FILTER));
|
||||
if (filter instanceof PdfName) {
|
||||
if (filter.equals(PdfName.LZWDECODE))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("lzwdecode.filter.is.not.permitted", new Object[0]));
|
||||
} else if (filter instanceof PdfArray) {
|
||||
for (PdfObject f : (Iterable<PdfObject>)filter) {
|
||||
if (f.equals(PdfName.LZWDECODE))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("lzwdecode.filter.is.not.permitted", new Object[0]));
|
||||
}
|
||||
}
|
||||
if (PdfName.FORM.equals(stream.getAsName(PdfName.SUBTYPE))) {
|
||||
if (stream.contains(PdfName.OPI))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("a.form.xobject.dictionary.shall.not.contain.opi.key", new Object[0]));
|
||||
if (stream.contains(PdfName.PS))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("a.form.xobject.dictionary.shall.not.contain.ps.key", new Object[0]));
|
||||
PdfDictionary group = getDirectDictionary(stream.get(PdfName.GROUP));
|
||||
if (group != null) {
|
||||
PdfName s = group.getAsName(PdfName.S);
|
||||
if (PdfName.TRANSPARENCY.equals(s))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("a.group.object.with.an.s.key.with.a.value.of.transparency.shall.not.be.included.in.a.form.xobject", new Object[0]));
|
||||
}
|
||||
}
|
||||
if (PdfName.PS.equals(stream.getAsName(PdfName.SUBTYPE)))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("postscript.xobjects.are.not.allowed", new Object[0]));
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkFileSpec(PdfWriter writer, int key, Object obj1) {
|
||||
if (obj1 instanceof PdfFileSpecification) {
|
||||
PdfFileSpecification fileSpec = (PdfFileSpecification)obj1;
|
||||
if (fileSpec.contains(PdfName.EF))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("embedded.files.are.not.permitted", new Object[0]));
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkPdfObject(PdfWriter writer, int key, Object obj1) {
|
||||
if (obj1 instanceof PdfNumber) {
|
||||
PdfNumber number = (PdfNumber)obj1;
|
||||
if (Math.abs(number.doubleValue()) > 32767.0D && number.toString().contains("."))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("real.number.is.out.of.range", new Object[0]));
|
||||
} else if (obj1 instanceof PdfString) {
|
||||
PdfString string = (PdfString)obj1;
|
||||
if ((string.getBytes()).length > 65535)
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("pdf.string.is.too.long", new Object[0]));
|
||||
} else if (obj1 instanceof PdfArray) {
|
||||
PdfArray array = (PdfArray)obj1;
|
||||
if (array.size() > 8191)
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("pdf.array.exceeds.length.set.by.PDFA1.standard", new Object[] { Integer.toString(array.size()) }));
|
||||
} else if (obj1 instanceof PdfDictionary) {
|
||||
PdfDictionary dictionary = (PdfDictionary)obj1;
|
||||
if (dictionary.size() > 4095)
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("pdf.dictionary.is.out.of.bounds", new Object[0]));
|
||||
PdfName type = dictionary.getAsName(PdfName.TYPE);
|
||||
if (PdfName.CATALOG.equals(type)) {
|
||||
if (!dictionary.contains(PdfName.METADATA))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("the.document.catalog.dictionary.shall.contain.metadata", new Object[0]));
|
||||
if (dictionary.contains(PdfName.AA))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("the.document.catalog.dictionary.shall.not.include.an.aa.entry", new Object[0]));
|
||||
if (dictionary.contains(PdfName.NAMES)) {
|
||||
PdfDictionary names = getDirectDictionary(dictionary.get(PdfName.NAMES));
|
||||
if (names != null && names.contains(PdfName.EMBEDDEDFILES))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("the.document.catalog.dictionary.shall.not.include.embeddedfiles.names.entry", new Object[0]));
|
||||
}
|
||||
if (checkStructure(this.conformanceLevel)) {
|
||||
PdfDictionary markInfo = getDirectDictionary(dictionary.get(PdfName.MARKINFO));
|
||||
if (markInfo == null || markInfo.getAsBoolean(PdfName.MARKED) == null || !markInfo.getAsBoolean(PdfName.MARKED).booleanValue())
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("document.catalog.dictionary.shall.include.a.markinfo.dictionary.whose.entry.marked.shall.have.a.value.of.true", new Object[0]));
|
||||
if (!dictionary.contains(PdfName.LANG))
|
||||
this.LOGGER.warning(MessageLocalization.getComposedMessage("document.catalog.dictionary.should.contain.lang.entry", new Object[0]));
|
||||
}
|
||||
} else if (PdfName.PAGE.equals(type)) {
|
||||
if (dictionary.contains(PdfName.AA))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("page.dictionary.shall.not.include.aa.entry", new Object[0]));
|
||||
} else if (PdfName.OUTPUTINTENT.equals(type)) {
|
||||
this.isCheckOutputIntent = true;
|
||||
PdfObject destOutputIntent = dictionary.get(PdfName.DESTOUTPUTPROFILE);
|
||||
if (destOutputIntent != null && this.pdfaDestOutputIntent != null) {
|
||||
if (this.pdfaDestOutputIntent.getIndRef() != destOutputIntent.getIndRef())
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("if.outputintents.array.more.than.one.entry.the.same.indirect.object", new Object[0]));
|
||||
} else {
|
||||
this.pdfaDestOutputIntent = destOutputIntent;
|
||||
}
|
||||
PdfName gts = dictionary.getAsName(PdfName.S);
|
||||
if (this.pdfaDestOutputIntent != null) {
|
||||
if (PdfName.GTS_PDFA1.equals(gts)) {
|
||||
if (this.pdfaOutputIntentColorSpace != null)
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("a.pdfa.file.may.have.only.one.pdfa.outputintent", new Object[0]));
|
||||
this.pdfaOutputIntentColorSpace = "";
|
||||
ICC_Profile icc_profile = writer.getColorProfile();
|
||||
try {
|
||||
this.pdfaOutputIntentColorSpace = new String(icc_profile.getData(), 16, 4, "US-ASCII");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new ExceptionConverter(e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("outputintent.shall.have.gtspdfa1.and.destoutputintent", new Object[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkCanvas(PdfWriter writer, int key, Object obj1) {
|
||||
if (obj1 instanceof String)
|
||||
if ("q".equals(obj1)) {
|
||||
if (++this.gsStackDepth > 28)
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("graphics.state.stack.depth.is.greater.than.28", new Object[0]));
|
||||
} else if ("Q".equals(obj1)) {
|
||||
this.gsStackDepth--;
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkColor(PdfWriter writer, int key, Object obj1) {
|
||||
switch (key) {
|
||||
case 1:
|
||||
if (obj1 instanceof ExtendedColor) {
|
||||
SpotColor sc;
|
||||
ShadingColor xc;
|
||||
PatternColor pc;
|
||||
ExtendedColor ec = (ExtendedColor)obj1;
|
||||
switch (ec.getType()) {
|
||||
case 2:
|
||||
checkColor(writer, 2, obj1);
|
||||
break;
|
||||
case 1:
|
||||
checkColor(writer, 18, obj1);
|
||||
return;
|
||||
case 0:
|
||||
checkColor(writer, 3, obj1);
|
||||
break;
|
||||
case 3:
|
||||
sc = (SpotColor)ec;
|
||||
checkColor(writer, 1, sc.getPdfSpotColor().getAlternativeCS());
|
||||
break;
|
||||
case 5:
|
||||
xc = (ShadingColor)ec;
|
||||
checkColor(writer, 1, xc.getPdfShadingPattern().getShading().getColorSpace());
|
||||
break;
|
||||
case 4:
|
||||
pc = (PatternColor)ec;
|
||||
checkColor(writer, 1, pc.getPainter().getDefaultColor());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (obj1 instanceof com.itextpdf.text.BaseColor)
|
||||
checkColor(writer, 3, obj1);
|
||||
break;
|
||||
case 2:
|
||||
if (this.rgbUsed)
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("devicergb.and.devicecmyk.colorspaces.cannot.be.used.both.in.one.file", new Object[0]));
|
||||
this.cmykUsed = true;
|
||||
break;
|
||||
case 3:
|
||||
if (this.cmykUsed)
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("devicergb.and.devicecmyk.colorspaces.cannot.be.used.both.in.one.file", new Object[0]));
|
||||
this.rgbUsed = true;
|
||||
break;
|
||||
case 18:
|
||||
this.grayUsed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkAnnotation(PdfWriter writer, int key, Object obj1) {
|
||||
if (obj1 instanceof PdfFormField) {
|
||||
PdfFormField field = (PdfFormField)obj1;
|
||||
if (!field.contains(PdfName.SUBTYPE))
|
||||
return;
|
||||
if (field.contains(PdfName.AA) || field.contains(PdfName.A))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("widget.annotation.dictionary.or.field.dictionary.shall.not.include.a.or.aa.entry", new Object[0]));
|
||||
}
|
||||
if (obj1 instanceof PdfAnnotation) {
|
||||
PdfAnnotation annot = (PdfAnnotation)obj1;
|
||||
PdfObject subtype = annot.get(PdfName.SUBTYPE);
|
||||
if (subtype == null)
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("annotation.type.1.not.allowed", new Object[] { "null" }));
|
||||
if (subtype != null && !allowedAnnotTypes.contains(subtype))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("annotation.type.1.not.allowed", new Object[] { subtype.toString() }));
|
||||
PdfNumber ca = annot.getAsNumber(PdfName.CA);
|
||||
if (ca != null && (double)ca.floatValue() != 1.0D)
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("an.annotation.dictionary.shall.not.contain.the.ca.key.with.a.value.other.than.1", new Object[0]));
|
||||
PdfNumber f = annot.getAsNumber(PdfName.F);
|
||||
if (f == null)
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("an.annotation.dictionary.shall.contain.the.f.key", new Object[0]));
|
||||
int flags = f.intValue();
|
||||
if (!checkFlag(flags, 4) || checkFlag(flags, 2) == true ||
|
||||
checkFlag(flags, 1) == true || checkFlag(flags, 32) == true)
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("the.f.keys.print.flag.bit.shall.be.set.to.1.and.its.hidden.invisible.and.noview.flag.bits.shall.be.set.to.0", new Object[0]));
|
||||
if (PdfName.TEXT.equals(annot.getAsName(PdfName.SUBTYPE)) && (
|
||||
!checkFlag(flags, 8) || !checkFlag(flags, 16)))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("text.annotations.should.set.the.nozoom.and.norotate.flag.bits.of.the.f.key.to.1", new Object[0]));
|
||||
if (annot.contains(PdfName.C) || annot.contains(PdfName.IC)) {
|
||||
ICC_Profile colorProfile = ((PdfAWriter)writer).getColorProfile();
|
||||
String cs = "";
|
||||
try {
|
||||
cs = new String(colorProfile.getData(), 16, 4, "US-ASCII");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new ExceptionConverter(e);
|
||||
}
|
||||
if (!"RGB ".equalsIgnoreCase(cs))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("destoutputprofile.in.the.pdfa1.outputintent.dictionary.shall.be.rgb", new Object[0]));
|
||||
}
|
||||
PdfDictionary ap = getDirectDictionary(annot.get(PdfName.AP));
|
||||
if (ap != null) {
|
||||
if (ap.contains(PdfName.R) || ap.contains(PdfName.D))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("appearance.dictionary.shall.contain.only.the.n.key.with.stream.value", new Object[0]));
|
||||
PdfObject n = ap.get(PdfName.N);
|
||||
if (!(n instanceof com.itextpdf.text.pdf.PdfIndirectReference))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("appearance.dictionary.shall.contain.only.the.n.key.with.stream.value", new Object[0]));
|
||||
}
|
||||
if (PdfName.WIDGET.equals(annot.getAsName(PdfName.SUBTYPE)) && (annot.contains(PdfName.AA) || annot.contains(PdfName.A)))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("widget.annotation.dictionary.or.field.dictionary.shall.not.include.a.or.aa.entry", new Object[0]));
|
||||
if (checkStructure(this.conformanceLevel) &&
|
||||
contentAnnotations.contains(subtype) && !annot.contains(PdfName.CONTENTS))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("annotation.of.type.1.should.have.contents.key", new Object[] { subtype.toString() }));
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkAction(PdfWriter writer, int key, Object obj1) {
|
||||
if (obj1 instanceof PdfAction) {
|
||||
PdfAction action = (PdfAction)obj1;
|
||||
PdfName s = action.getAsName(PdfName.S);
|
||||
if (setState.equals(s) || noOp.equals(s))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("deprecated.setstate.and.noop.actions.are.not.allowed", new Object[0]));
|
||||
if (restrictedActions.contains(s))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("launch.sound.movie.resetform.importdata.and.javascript.actions.are.not.allowed", new Object[0]));
|
||||
if (PdfName.NAMED.equals(s)) {
|
||||
PdfName n = action.getAsName(PdfName.N);
|
||||
if (n != null && !allowedNamedActions.contains(n))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("named.action.type.1.not.allowed", new Object[] { n.toString() }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkForm(PdfWriter writer, int key, Object obj1) {
|
||||
if (obj1 instanceof PdfAcroForm) {
|
||||
PdfAcroForm form = (PdfAcroForm)obj1;
|
||||
PdfBoolean needAppearances = form.getAsBoolean(PdfName.NEEDAPPEARANCES);
|
||||
if (needAppearances != null && needAppearances.booleanValue())
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("needappearances.flag.of.the.interactive.form.dictionary.shall.either.not.be.present.or.shall.be.false", new Object[0]));
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkStructElem(PdfWriter writer, int key, Object obj1) {
|
||||
if (obj1 instanceof PdfStructureElement) {
|
||||
PdfStructureElement structElem = (PdfStructureElement)obj1;
|
||||
PdfName role = structElem.getStructureType();
|
||||
if (PdfName.FIGURE.equals(role) || PdfName.FORMULA.equals(role) || PdfName.FORM.equals(role)) {
|
||||
PdfObject o = structElem.get(PdfName.ALT);
|
||||
if (!(o instanceof PdfString) || o.toString().length() <= 0)
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("alt.entry.should.specify.alternate.description.for.1.element", new Object[] { role.toString() }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkOutputIntent(PdfWriter writer, int key, Object obj1) {
|
||||
if (writer instanceof com.itextpdf.text.pdf.PdfAStamperImp && writer.getColorProfile() != null)
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("outputintent.shall.not.be.updated", new Object[0]));
|
||||
}
|
||||
|
||||
public void close(PdfWriter writer) {
|
||||
checkOutputIntentsInStamperMode(writer);
|
||||
if ((this.rgbUsed || this.cmykUsed || this.grayUsed) && this.pdfaOutputIntentColorSpace == null)
|
||||
throw new PdfAConformanceException(null, MessageLocalization.getComposedMessage("if.device.rgb.cmyk.gray.used.in.file.that.file.shall.contain.pdfa.outputintent", new Object[0]));
|
||||
if ("RGB ".equals(this.pdfaOutputIntentColorSpace)) {
|
||||
if (this.cmykUsed)
|
||||
throw new PdfAConformanceException(null, MessageLocalization.getComposedMessage("devicecmyk.may.be.used.only.if.the.file.has.a.cmyk.pdfa.outputIntent", new Object[0]));
|
||||
} else if ("CMYK".equals(this.pdfaOutputIntentColorSpace)) {
|
||||
if (this.rgbUsed)
|
||||
throw new PdfAConformanceException(null, MessageLocalization.getComposedMessage("devicergb.may.be.used.only.if.the.file.has.a.rgb.pdfa.outputIntent", new Object[0]));
|
||||
} else {
|
||||
if (this.cmykUsed)
|
||||
throw new PdfAConformanceException(null, MessageLocalization.getComposedMessage("devicecmyk.may.be.used.only.if.the.file.has.a.cmyk.pdfa.outputIntent", new Object[0]));
|
||||
if (this.rgbUsed)
|
||||
throw new PdfAConformanceException(null, MessageLocalization.getComposedMessage("devicergb.may.be.used.only.if.the.file.has.a.rgb.pdfa.outputIntent", new Object[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,676 @@
|
|||
package com.itextpdf.text.pdf.internal;
|
||||
|
||||
import com.itextpdf.text.ExceptionConverter;
|
||||
import com.itextpdf.text.Jpeg2000;
|
||||
import com.itextpdf.text.error_messages.MessageLocalization;
|
||||
import com.itextpdf.text.pdf.BaseFont;
|
||||
import com.itextpdf.text.pdf.DocumentFont;
|
||||
import com.itextpdf.text.pdf.ExtendedColor;
|
||||
import com.itextpdf.text.pdf.ICC_Profile;
|
||||
import com.itextpdf.text.pdf.PatternColor;
|
||||
import com.itextpdf.text.pdf.PdfAConformanceException;
|
||||
import com.itextpdf.text.pdf.PdfAConformanceLevel;
|
||||
import com.itextpdf.text.pdf.PdfAWriter;
|
||||
import com.itextpdf.text.pdf.PdfAcroForm;
|
||||
import com.itextpdf.text.pdf.PdfAction;
|
||||
import com.itextpdf.text.pdf.PdfAnnotation;
|
||||
import com.itextpdf.text.pdf.PdfArray;
|
||||
import com.itextpdf.text.pdf.PdfBoolean;
|
||||
import com.itextpdf.text.pdf.PdfDictionary;
|
||||
import com.itextpdf.text.pdf.PdfFileSpecification;
|
||||
import com.itextpdf.text.pdf.PdfFormField;
|
||||
import com.itextpdf.text.pdf.PdfGState;
|
||||
import com.itextpdf.text.pdf.PdfImage;
|
||||
import com.itextpdf.text.pdf.PdfName;
|
||||
import com.itextpdf.text.pdf.PdfNumber;
|
||||
import com.itextpdf.text.pdf.PdfOCProperties;
|
||||
import com.itextpdf.text.pdf.PdfObject;
|
||||
import com.itextpdf.text.pdf.PdfRectangle;
|
||||
import com.itextpdf.text.pdf.PdfStream;
|
||||
import com.itextpdf.text.pdf.PdfString;
|
||||
import com.itextpdf.text.pdf.PdfStructureElement;
|
||||
import com.itextpdf.text.pdf.PdfTemplate;
|
||||
import com.itextpdf.text.pdf.PdfWriter;
|
||||
import com.itextpdf.text.pdf.ShadingColor;
|
||||
import com.itextpdf.text.pdf.SpotColor;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class PdfA2Checker extends PdfAChecker {
|
||||
public static final HashSet<PdfName> allowedBlendModes = new HashSet<PdfName>(Arrays.<PdfName>asList(PdfGState.BM_NORMAL, PdfGState.BM_COMPATIBLE, PdfGState.BM_MULTIPLY, PdfGState.BM_SCREEN, PdfGState.BM_OVERLAY, PdfGState.BM_DARKEN, PdfGState.BM_LIGHTEN, PdfGState.BM_COLORDODGE, PdfGState.BM_COLORBURN, PdfGState.BM_HARDLIGHT, PdfGState.BM_SOFTLIGHT, PdfGState.BM_DIFFERENCE, PdfGState.BM_EXCLUSION));
|
||||
|
||||
public static final HashSet<PdfName> restrictedActions = new HashSet<PdfName>(Arrays.<PdfName>asList(PdfName.LAUNCH, PdfName.SOUND, PdfName.MOVIE, PdfName.RESETFORM, PdfName.IMPORTDATA, PdfName.HIDE, PdfName.SETOCGSTATE, PdfName.RENDITION, PdfName.TRANS, PdfName.GOTO3DVIEW, PdfName.JAVASCRIPT));
|
||||
|
||||
private static HashSet<PdfName> allowedAnnotTypes = new HashSet<PdfName>(Arrays.<PdfName>asList(PdfName.TEXT, PdfName.LINK, PdfName.FREETEXT, PdfName.LINE, PdfName.SQUARE, PdfName.CIRCLE, PdfName.POLYGON, PdfName.POLYLINE, PdfName.HIGHLIGHT, PdfName.UNDERLINE, PdfName.SQUIGGLY, PdfName.STRIKEOUT, PdfName.STAMP, PdfName.CARET, PdfName.INK, PdfName.POPUP, PdfName.FILEATTACHMENT, PdfName.WIDGET, PdfName.PRINTERMARK, PdfName.TRAPNET, PdfName.WATERMARK, PdfName.REDACT));
|
||||
|
||||
public static final HashSet<PdfName> contentAnnotations = new HashSet<PdfName>(Arrays.<PdfName>asList(PdfName.TEXT, PdfName.FREETEXT, PdfName.LINE, PdfName.SQUARE, PdfName.CIRCLE, PdfName.STAMP, PdfName.INK, PdfName.POPUP));
|
||||
|
||||
private static final HashSet<PdfName> keysForCheck = new HashSet<PdfName>(Arrays.<PdfName>asList(PdfName.AP, PdfName.N, PdfName.R, PdfName.D, PdfName.FONTFILE, PdfName.FONTFILE2, PdfName.FONTFILE3, PdfName.NAME, PdfName.XFA, PdfName.ALTERNATEPRESENTATION, PdfName.DOCMDP, PdfName.REFERENCE, new PdfName("DigestLocation"), new PdfName("DigestMethod"), new PdfName("DigestValue"), PdfName.MARKED, PdfName.S, PdfName.SUBTYPE, PdfName.F));
|
||||
|
||||
public static final PdfName DIGESTLOCATION = new PdfName("DigestLocation");
|
||||
|
||||
public static final PdfName DIGESTMETHOD = new PdfName("DigestMethod");
|
||||
|
||||
public static final PdfName DIGESTVALUE = new PdfName("DigestValue");
|
||||
|
||||
static final int maxPageSize = 14400;
|
||||
|
||||
static final int minPageSize = 3;
|
||||
|
||||
protected int gsStackDepth = 0;
|
||||
|
||||
protected boolean rgbUsed = false;
|
||||
|
||||
protected boolean cmykUsed = false;
|
||||
|
||||
protected boolean grayUsed = false;
|
||||
|
||||
protected boolean transparencyWithoutPageGroupDetected = false;
|
||||
|
||||
protected boolean transparencyDetectedOnThePage = false;
|
||||
|
||||
public static final int maxStringLength = 32767;
|
||||
|
||||
PdfA2Checker(PdfAConformanceLevel conformanceLevel) {
|
||||
super(conformanceLevel);
|
||||
}
|
||||
|
||||
protected HashSet<PdfName> initKeysForCheck() {
|
||||
return keysForCheck;
|
||||
}
|
||||
|
||||
protected void checkFont(PdfWriter writer, int key, Object obj1) {
|
||||
BaseFont bf = (BaseFont)obj1;
|
||||
if (bf.getFontType() == 4) {
|
||||
PdfStream prs = null;
|
||||
PdfDictionary fontDictionary = ((DocumentFont)bf).getFontDictionary();
|
||||
PdfDictionary fontDescriptor = getDirectDictionary(fontDictionary.get(PdfName.FONTDESCRIPTOR));
|
||||
if (fontDescriptor != null) {
|
||||
prs = getDirectStream(fontDescriptor.get(PdfName.FONTFILE));
|
||||
if (prs == null)
|
||||
prs = getDirectStream(fontDescriptor.get(PdfName.FONTFILE2));
|
||||
if (prs == null)
|
||||
prs = getDirectStream(fontDescriptor.get(PdfName.FONTFILE3));
|
||||
}
|
||||
if (prs == null)
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("all.the.fonts.must.be.embedded.this.one.isn.t.1", new Object[] { ((BaseFont)obj1).getPostscriptFontName() }));
|
||||
} else if (!bf.isEmbedded()) {
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("all.the.fonts.must.be.embedded.this.one.isn.t.1", new Object[] { ((BaseFont)obj1).getPostscriptFontName() }));
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkGState(PdfWriter writer, int key, Object obj1) {
|
||||
if (obj1 instanceof PdfObject) {
|
||||
PdfDictionary gs = getDirectDictionary((PdfObject)obj1);
|
||||
PdfObject obj = gs.get(PdfName.BM);
|
||||
if (obj != null) {
|
||||
if (!allowedBlendModes.contains(obj))
|
||||
throw new PdfAConformanceException(MessageLocalization.getComposedMessage("blend.mode.1.not.allowed", new Object[] { obj.toString() }));
|
||||
if (!PdfGState.BM_NORMAL.equals(obj))
|
||||
this.transparencyDetectedOnThePage = true;
|
||||
}
|
||||
PdfNumber ca = gs.getAsNumber(PdfName.ca);
|
||||
if (ca != null && ca.floatValue() < 1.0F)
|
||||
this.transparencyDetectedOnThePage = true;
|
||||
ca = gs.getAsNumber(PdfName.CA);
|
||||
if (ca != null && ca.floatValue() < 1.0F)
|
||||
this.transparencyDetectedOnThePage = true;
|
||||
PdfDictionary smask = getDirectDictionary(gs.get(PdfName.SMASK));
|
||||
if (smask != null)
|
||||
this.transparencyDetectedOnThePage = true;
|
||||
if (gs.contains(PdfName.TR))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("an.extgstate.dictionary.shall.not.contain.the.tr.key", new Object[0]));
|
||||
PdfName tr2 = gs.getAsName(PdfName.TR2);
|
||||
if (tr2 != null && !tr2.equals(PdfName.DEFAULT))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("an.extgstate.dictionary.shall.not.contain.the.TR2.key.with.a.value.other.than.default", new Object[0]));
|
||||
if (gs.contains(PdfName.HTP))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("an.extgstate.dictionary.shall.not.contain.the.htp.key", new Object[0]));
|
||||
PdfDictionary halfTone = getDirectDictionary(gs.get(PdfName.HT));
|
||||
if (halfTone != null) {
|
||||
if (halfTone.contains(PdfName.HALFTONENAME))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("halftones.shall.not.contains.halftonename", new Object[0]));
|
||||
PdfNumber halftoneType = halfTone.getAsNumber(PdfName.HALFTONETYPE);
|
||||
if (halftoneType == null || (halftoneType.intValue() != 1 && halftoneType.intValue() != 5))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("all.halftones.shall.have.halftonetype.1.or.5", new Object[0]));
|
||||
}
|
||||
PdfName ri = gs.getAsName(PdfName.RI);
|
||||
if (ri != null && !PdfName.RELATIVECOLORIMETRIC.equals(ri) && !PdfName.ABSOLUTECOLORIMETRIC.equals(ri) && !PdfName.PERCEPTUAL.equals(ri) && !PdfName.SATURATION.equals(ri))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("1.value.of.ri.key.is.not.allowed", new Object[] { ri.toString() }));
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkImage(PdfWriter writer, int key, Object obj1) {
|
||||
PdfImage pdfImage = (PdfImage)obj1;
|
||||
if (getDirectStream(pdfImage.get(PdfName.SMASK)) != null)
|
||||
this.transparencyDetectedOnThePage = true;
|
||||
PdfNumber smaskInData = pdfImage.getAsNumber(PdfName.SMASKINDATA);
|
||||
if (smaskInData != null && smaskInData.floatValue() > 0.0F)
|
||||
this.transparencyDetectedOnThePage = true;
|
||||
if (pdfImage.contains(PdfName.OPI))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("an.image.dictionary.shall.not.contain.opi.key", new Object[0]));
|
||||
PdfBoolean interpolate = pdfImage.getAsBoolean(PdfName.INTERPOLATE);
|
||||
if (interpolate != null && interpolate.booleanValue())
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("the.value.of.interpolate.key.shall.not.be.true", new Object[0]));
|
||||
if (pdfImage != null && pdfImage.getImage() instanceof Jpeg2000) {
|
||||
Jpeg2000 jpeg2000 = (Jpeg2000)pdfImage.getImage();
|
||||
if (!jpeg2000.isJp2())
|
||||
throw new PdfAConformanceException(MessageLocalization.getComposedMessage("only.jpx.baseline.set.of.features.shall.be.used", new Object[0]));
|
||||
if (jpeg2000.getNumOfComps() != 1 && jpeg2000.getNumOfComps() != 3 && jpeg2000.getNumOfComps() != 4)
|
||||
throw new PdfAConformanceException(MessageLocalization.getComposedMessage("the.number.of.colour.channels.in.the.jpeg2000.data.shall.be.123", new Object[0]));
|
||||
if (jpeg2000.getBpc() < 1 || jpeg2000.getBpc() > 38)
|
||||
throw new PdfAConformanceException(MessageLocalization.getComposedMessage("the.bit-depth.of.the.jpeg2000.data.shall.have.a.value.in.the.range.1to38", new Object[0]));
|
||||
if (jpeg2000.getBpcBoxData() != null)
|
||||
throw new PdfAConformanceException(MessageLocalization.getComposedMessage("all.colour.channels.in.the.jpeg2000.data.shall.have.the.same.bit-depth", new Object[0]));
|
||||
ArrayList<Jpeg2000.ColorSpecBox> colorSpecBoxes = jpeg2000.getColorSpecBoxes();
|
||||
if (colorSpecBoxes != null) {
|
||||
if (colorSpecBoxes.size() > 1) {
|
||||
int approx0x01 = 0;
|
||||
for (Jpeg2000.ColorSpecBox colorSpecBox : colorSpecBoxes) {
|
||||
if (colorSpecBox.getApprox() == 1)
|
||||
approx0x01++;
|
||||
}
|
||||
if (approx0x01 != 1)
|
||||
throw new PdfAConformanceException(MessageLocalization.getComposedMessage("exactly.one.colour.space.specification.shall.have.the.value.0x01.in.the.approx.field", new Object[0]));
|
||||
}
|
||||
for (Jpeg2000.ColorSpecBox colorSpecBox : colorSpecBoxes) {
|
||||
if (colorSpecBox.getMeth() != 1 && colorSpecBox.getMeth() != 2 && colorSpecBox.getMeth() != 3)
|
||||
throw new PdfAConformanceException(MessageLocalization.getComposedMessage("the.value.of.the.meth.entry.in.colr.box.shall.be.123", new Object[0]));
|
||||
if (colorSpecBox.getEnumCs() == 19)
|
||||
throw new PdfAConformanceException(MessageLocalization.getComposedMessage("jpeg2000.enumerated.colour.space.19.(CIEJab).shall.not.be.used", new Object[0]));
|
||||
byte[] colorProfileBytes = colorSpecBox.getColorProfile();
|
||||
if (colorProfileBytes != null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkFormXObj(PdfWriter writer, int key, Object obj1) {
|
||||
if (obj1 instanceof PdfTemplate && (
|
||||
(PdfTemplate)obj1).getGroup() != null)
|
||||
this.transparencyDetectedOnThePage = true;
|
||||
}
|
||||
|
||||
protected void checkInlineImage(PdfWriter writer, int key, Object obj1) {
|
||||
PdfImage pdfImage = (PdfImage)obj1;
|
||||
PdfBoolean interpolate = pdfImage.getAsBoolean(PdfName.INTERPOLATE);
|
||||
if (interpolate != null && interpolate.booleanValue())
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("the.value.of.interpolate.key.shall.not.be.true", new Object[0]));
|
||||
PdfObject filter = pdfImage.getDirectObject(PdfName.FILTER);
|
||||
if (filter instanceof PdfName) {
|
||||
if (filter.equals(PdfName.LZWDECODE))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("lzwdecode.filter.is.not.permitted", new Object[0]));
|
||||
if (filter.equals(PdfName.CRYPT))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("crypt.filter.is.not.permitted.inline.image", new Object[0]));
|
||||
} else if (filter instanceof PdfArray) {
|
||||
for (int i = 0; i < ((PdfArray)filter).size(); i++) {
|
||||
PdfName f = ((PdfArray)filter).getAsName(i);
|
||||
if (f.equals(PdfName.LZWDECODE))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("lzwdecode.filter.is.not.permitted", new Object[0]));
|
||||
if (f.equals(PdfName.CRYPT))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("crypt.filter.is.not.permitted.inline.image", new Object[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkLayer(PdfWriter writer, int key, Object obj1) {
|
||||
if (!(obj1 instanceof com.itextpdf.text.pdf.PdfOCG))
|
||||
if (obj1 instanceof PdfOCProperties) {
|
||||
PdfOCProperties properties = (PdfOCProperties)obj1;
|
||||
ArrayList<PdfDictionary> configsList = new ArrayList<PdfDictionary>();
|
||||
PdfDictionary d = getDirectDictionary(properties.get(PdfName.D));
|
||||
if (d != null)
|
||||
configsList.add(d);
|
||||
PdfArray configs = getDirectArray(properties.get(PdfName.CONFIGS));
|
||||
if (configs != null)
|
||||
for (int i = 0; i < configs.size(); i++) {
|
||||
PdfDictionary config = getDirectDictionary(configs.getPdfObject(i));
|
||||
if (config != null)
|
||||
configsList.add(config);
|
||||
}
|
||||
HashSet<PdfObject> ocgs = new HashSet<PdfObject>();
|
||||
PdfArray ocgsArray = getDirectArray(properties.get(PdfName.OCGS));
|
||||
if (ocgsArray != null)
|
||||
for (int i = 0; i < ocgsArray.size(); i++)
|
||||
ocgs.add(ocgsArray.getPdfObject(i));
|
||||
HashSet<String> names = new HashSet<String>();
|
||||
HashSet<PdfObject> order = new HashSet<PdfObject>();
|
||||
for (PdfDictionary config : configsList) {
|
||||
PdfString name = config.getAsString(PdfName.NAME);
|
||||
if (name == null)
|
||||
throw new PdfAConformanceException(MessageLocalization.getComposedMessage("optional.content.configuration.dictionary.shall.contain.name.entry", new Object[0]));
|
||||
String name1 = name.toUnicodeString();
|
||||
if (names.contains(name1))
|
||||
throw new PdfAConformanceException(MessageLocalization.getComposedMessage("value.of.name.entry.shall.be.unique.amongst.all.optional.content.configuration.dictionaries", new Object[0]));
|
||||
names.add(name1);
|
||||
if (config.contains(PdfName.AS))
|
||||
throw new PdfAConformanceException(MessageLocalization.getComposedMessage("the.as.key.shall.not.appear.in.any.optional.content.configuration.dictionary", new Object[0]));
|
||||
PdfArray orderArray = getDirectArray(config.get(PdfName.ORDER));
|
||||
if (orderArray != null)
|
||||
fillOrderRecursively(orderArray, order);
|
||||
}
|
||||
if (order.size() != ocgs.size())
|
||||
throw new PdfAConformanceException(MessageLocalization.getComposedMessage("order.array.shall.contain.references.to.all.ocgs", new Object[0]));
|
||||
ocgs.retainAll(order);
|
||||
if (order.size() != ocgs.size())
|
||||
throw new PdfAConformanceException(MessageLocalization.getComposedMessage("order.array.shall.contain.references.to.all.ocgs", new Object[0]));
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkTrailer(PdfWriter writer, int key, Object obj1) {
|
||||
if (obj1 instanceof PdfWriter.PdfTrailer) {
|
||||
PdfWriter.PdfTrailer trailer = (PdfWriter.PdfTrailer)obj1;
|
||||
if (trailer.get(PdfName.ENCRYPT) != null)
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("keyword.encrypt.shall.not.be.used.in.the.trailer.dictionary", new Object[0]));
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkStream(PdfWriter writer, int key, Object obj1) {
|
||||
if (obj1 instanceof PdfStream) {
|
||||
PdfStream stream = (PdfStream)obj1;
|
||||
if (stream.contains(PdfName.F) || stream.contains(PdfName.FFILTER) || stream.contains(PdfName.FDECODEPARMS))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("stream.object.dictionary.shall.not.contain.the.f.ffilter.or.fdecodeparams.keys", new Object[0]));
|
||||
PdfObject filter = stream.getDirectObject(PdfName.FILTER);
|
||||
if (filter instanceof PdfName) {
|
||||
if (filter.equals(PdfName.LZWDECODE))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("lzwdecode.filter.is.not.permitted", new Object[0]));
|
||||
if (filter.equals(PdfName.CRYPT)) {
|
||||
PdfDictionary decodeParams = getDirectDictionary(stream.get(PdfName.DECODEPARMS));
|
||||
if (decodeParams != null) {
|
||||
PdfString cryptFilterName = decodeParams.getAsString(PdfName.NAME);
|
||||
if (cryptFilterName != null && !cryptFilterName.equals(PdfName.IDENTITY))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("not.identity.crypt.filter.is.not.permitted", new Object[0]));
|
||||
}
|
||||
}
|
||||
} else if (filter instanceof PdfArray) {
|
||||
for (int i = 0; i < ((PdfArray)filter).size(); i++) {
|
||||
PdfName f = ((PdfArray)filter).getAsName(i);
|
||||
if (f.equals(PdfName.LZWDECODE))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("lzwdecode.filter.is.not.permitted", new Object[0]));
|
||||
if (f.equals(PdfName.CRYPT)) {
|
||||
PdfArray decodeParams = getDirectArray(stream.get(PdfName.DECODEPARMS));
|
||||
if (decodeParams != null && i < decodeParams.size()) {
|
||||
PdfDictionary decodeParam = getDirectDictionary(decodeParams.getPdfObject(i));
|
||||
PdfString cryptFilterName = decodeParam.getAsString(PdfName.NAME);
|
||||
if (cryptFilterName != null && !cryptFilterName.equals(PdfName.IDENTITY))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("not.identity.crypt.filter.is.not.permitted", new Object[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (PdfName.FORM.equals(stream.getAsName(PdfName.SUBTYPE))) {
|
||||
if (stream.contains(PdfName.OPI))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("a.form.xobject.dictionary.shall.not.contain.opi.key", new Object[0]));
|
||||
if (stream.contains(PdfName.PS))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("a.form.xobject.dictionary.shall.not.contain.ps.key", new Object[0]));
|
||||
}
|
||||
if (PdfName.PS.equals(stream.getAsName(PdfName.SUBTYPE)))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("postscript.xobjects.are.not.allowed", new Object[0]));
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkFileSpec(PdfWriter writer, int key, Object obj1) {
|
||||
if (obj1 instanceof PdfFileSpecification) {
|
||||
PdfFileSpecification pdfFileSpecification = (PdfFileSpecification)obj1;
|
||||
if (!pdfFileSpecification.contains(PdfName.UF) || !pdfFileSpecification.contains(PdfName.F) || !pdfFileSpecification.contains(PdfName.DESC))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("file.specification.dictionary.shall.contain.f.uf.and.desc.entries", new Object[0]));
|
||||
if (pdfFileSpecification.contains(PdfName.EF)) {
|
||||
PdfDictionary dict = getDirectDictionary(pdfFileSpecification.get(PdfName.EF));
|
||||
if (dict == null || !dict.contains(PdfName.F))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("ef.key.of.file.specification.dictionary.shall.contain.dictionary.with.valid.f.key", new Object[0]));
|
||||
PdfDictionary embeddedFile = getDirectDictionary(dict.get(PdfName.F));
|
||||
if (embeddedFile == null)
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("ef.key.of.file.specification.dictionary.shall.contain.dictionary.with.valid.f.key", new Object[0]));
|
||||
checkEmbeddedFile(embeddedFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static PdfName MimeTypePdf = new PdfName(PdfAWriter.MimeTypePdf);
|
||||
|
||||
protected void checkEmbeddedFile(PdfDictionary embeddedFile) {
|
||||
PdfName subtype = embeddedFile.getAsName(PdfName.SUBTYPE);
|
||||
if (subtype == null || !MimeTypePdf.equals(subtype))
|
||||
throw new PdfAConformanceException(embeddedFile, MessageLocalization.getComposedMessage("embedded.file.shall.contain.pdf.mime.type", new Object[0]));
|
||||
}
|
||||
|
||||
protected void checkPdfObject(PdfWriter writer, int key, Object obj1) {
|
||||
if (obj1 instanceof PdfNumber) {
|
||||
PdfNumber number = (PdfNumber)obj1;
|
||||
if (Math.abs(number.doubleValue()) > Float.MAX_VALUE && number.toString().contains("."))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("real.number.is.out.of.range", new Object[0]));
|
||||
} else if (obj1 instanceof PdfString) {
|
||||
PdfString string = (PdfString)obj1;
|
||||
if ((string.getBytes()).length > 32767)
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("pdf.string.is.too.long", new Object[0]));
|
||||
} else if (obj1 instanceof PdfDictionary) {
|
||||
PdfDictionary dictionary = (PdfDictionary)obj1;
|
||||
PdfName type = dictionary.getAsName(PdfName.TYPE);
|
||||
if (PdfName.CATALOG.equals(type)) {
|
||||
if (!dictionary.contains(PdfName.METADATA))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("the.document.catalog.dictionary.shall.contain.metadata", new Object[0]));
|
||||
if (dictionary.contains(PdfName.AA))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("the.document.catalog.dictionary.shall.not.include.an.aa.entry", new Object[0]));
|
||||
if (dictionary.contains(PdfName.REQUIREMENTS))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("the.document.catalog.dictionary.shall.not.include.a.requirements.entry", new Object[0]));
|
||||
if (dictionary.contains(PdfName.NEEDRENDERING))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("the.document.catalog.dictionary.shall.not.include.a.needrendering.entry", new Object[0]));
|
||||
if (dictionary.contains(PdfName.ACROFORM)) {
|
||||
PdfDictionary acroForm = getDirectDictionary(dictionary.get(PdfName.ACROFORM));
|
||||
if (acroForm != null && acroForm.contains(PdfName.XFA))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("the.document.catalog.dictionary.shall.not.include.acroform.xfa.entry", new Object[0]));
|
||||
}
|
||||
if (dictionary.contains(PdfName.NAMES)) {
|
||||
PdfDictionary names = getDirectDictionary(dictionary.get(PdfName.NAMES));
|
||||
if (names != null && names.contains(PdfName.ALTERNATEPRESENTATION))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("the.document.catalog.dictionary.shall.not.include.alternatepresentation.names.entry", new Object[0]));
|
||||
}
|
||||
PdfDictionary permissions = getDirectDictionary(dictionary.get(PdfName.PERMS));
|
||||
if (permissions != null)
|
||||
for (PdfName dictKey : (Iterable<PdfName>)permissions.getKeys()) {
|
||||
if (PdfName.DOCMDP.equals(dictKey)) {
|
||||
PdfDictionary signatureDict = getDirectDictionary(permissions.get(PdfName.DOCMDP));
|
||||
if (signatureDict != null) {
|
||||
PdfArray references = getDirectArray(signatureDict.get(PdfName.REFERENCE));
|
||||
if (references != null)
|
||||
for (int i = 0; i < references.size(); i++) {
|
||||
PdfDictionary referenceDict = getDirectDictionary(references.getPdfObject(i));
|
||||
if (referenceDict.contains(DIGESTLOCATION) ||
|
||||
referenceDict.contains(DIGESTMETHOD) ||
|
||||
referenceDict.contains(DIGESTVALUE))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("signature.references.dictionary.shall.not.contain.digestlocation.digestmethod.digestvalue", new Object[0]));
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (PdfName.UR3.equals(dictKey))
|
||||
continue;
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("no.keys.other.than.UR3.and.DocMDP.shall.be.present.in.a.permissions.dictionary", new Object[0]));
|
||||
}
|
||||
if (checkStructure(this.conformanceLevel)) {
|
||||
PdfDictionary markInfo = getDirectDictionary(dictionary.get(PdfName.MARKINFO));
|
||||
if (markInfo == null || markInfo.getAsBoolean(PdfName.MARKED) == null || !markInfo.getAsBoolean(PdfName.MARKED).booleanValue())
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("document.catalog.dictionary.shall.include.a.markinfo.dictionary.whose.entry.marked.shall.have.a.value.of.true", new Object[0]));
|
||||
if (!dictionary.contains(PdfName.LANG))
|
||||
this.LOGGER.warning(MessageLocalization.getComposedMessage("document.catalog.dictionary.should.contain.lang.entry", new Object[0]));
|
||||
}
|
||||
} else if (PdfName.PAGE.equals(type)) {
|
||||
PdfName[] boxNames = { PdfName.MEDIABOX, PdfName.CROPBOX, PdfName.TRIMBOX, PdfName.ARTBOX, PdfName.BLEEDBOX };
|
||||
for (PdfName boxName : boxNames) {
|
||||
PdfObject box = dictionary.getDirectObject(boxName);
|
||||
if (box instanceof PdfRectangle) {
|
||||
float width = ((PdfRectangle)box).width();
|
||||
float height = ((PdfRectangle)box).height();
|
||||
if (width < 3.0F || width > 14400.0F || height < 3.0F || height > 14400.0F)
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("the.page.less.3.units.nor.greater.14400.in.either.direction", new Object[0]));
|
||||
}
|
||||
}
|
||||
if (dictionary.contains(PdfName.AA))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("page.dictionary.shall.not.include.aa.entry", new Object[0]));
|
||||
if (dictionary.contains(PdfName.PRESSTEPS))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("page.dictionary.shall.not.include.pressteps.entry", new Object[0]));
|
||||
if (this.transparencyDetectedOnThePage) {
|
||||
PdfDictionary group = getDirectDictionary(dictionary.get(PdfName.GROUP));
|
||||
if (group == null || !PdfName.TRANSPARENCY.equals(group.getAsName(PdfName.S)) || !group.contains(PdfName.CS)) {
|
||||
this.transparencyWithoutPageGroupDetected = true;
|
||||
} else {
|
||||
PdfName csName = group.getAsName(PdfName.CS);
|
||||
if (PdfName.DEVICERGB.equals(csName))
|
||||
this.rgbUsed = true;
|
||||
if (PdfName.DEVICEGRAY.equals(csName))
|
||||
this.grayUsed = true;
|
||||
if (PdfName.DEVICECMYK.equals(csName))
|
||||
this.cmykUsed = true;
|
||||
}
|
||||
}
|
||||
this.transparencyDetectedOnThePage = false;
|
||||
} else if (PdfName.OUTPUTINTENT.equals(type)) {
|
||||
this.isCheckOutputIntent = true;
|
||||
PdfObject destOutputIntent = dictionary.get(PdfName.DESTOUTPUTPROFILE);
|
||||
if (destOutputIntent != null && this.pdfaDestOutputIntent != null) {
|
||||
if (this.pdfaDestOutputIntent.getIndRef() != destOutputIntent.getIndRef())
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("if.outputintents.array.more.than.one.entry.the.same.indirect.object", new Object[0]));
|
||||
} else {
|
||||
this.pdfaDestOutputIntent = destOutputIntent;
|
||||
}
|
||||
PdfName gts = dictionary.getAsName(PdfName.S);
|
||||
if (this.pdfaDestOutputIntent != null) {
|
||||
if (PdfName.GTS_PDFA1.equals(gts)) {
|
||||
if (this.pdfaOutputIntentColorSpace != null)
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("a.pdfa.file.may.have.only.one.pdfa.outputintent", new Object[0]));
|
||||
this.pdfaOutputIntentColorSpace = "";
|
||||
}
|
||||
String deviceClass = "";
|
||||
ICC_Profile icc_profile = writer.getColorProfile();
|
||||
try {
|
||||
if (PdfName.GTS_PDFA1.equals(gts))
|
||||
this.pdfaOutputIntentColorSpace = new String(icc_profile.getData(), 16, 4, "US-ASCII");
|
||||
deviceClass = new String(icc_profile.getData(), 12, 4, "US-ASCII");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new ExceptionConverter(e);
|
||||
}
|
||||
if (!"prtr".equals(deviceClass) && !"mntr".equals(deviceClass))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("outputintent.shall.be.prtr.or.mntr", new Object[0]));
|
||||
} else {
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("outputintent.shall.have.gtspdfa1.and.destoutputintent", new Object[0]));
|
||||
}
|
||||
} else if (PdfName.EMBEDDEDFILE.equals(type)) {
|
||||
checkEmbeddedFile(dictionary);
|
||||
}
|
||||
PdfObject obj2 = dictionary.get(PdfName.HALFTONETYPE);
|
||||
if (obj2 != null && obj2.isNumber()) {
|
||||
PdfNumber number = (PdfNumber)obj2;
|
||||
if (number.intValue() != 1 || number.intValue() != 5)
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("an.extgstate.dictionary.shall.contain.the.halftonetype.key.of.value.1.or.5", new Object[0]));
|
||||
if (dictionary.contains(PdfName.HALFTONENAME))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("an.extgstate.dictionary.shall.not.contain.the.halftonename.key", new Object[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkCanvas(PdfWriter writer, int key, Object obj1) {
|
||||
if (obj1 instanceof String)
|
||||
if ("q".equals(obj1)) {
|
||||
if (++this.gsStackDepth > 28)
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("graphics.state.stack.depth.is.greater.than.28", new Object[0]));
|
||||
} else if ("Q".equals(obj1)) {
|
||||
this.gsStackDepth--;
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkColor(PdfWriter writer, int key, Object obj1) {
|
||||
switch (key) {
|
||||
case 1:
|
||||
if (obj1 instanceof ExtendedColor) {
|
||||
SpotColor sc;
|
||||
ShadingColor xc;
|
||||
PatternColor pc;
|
||||
ExtendedColor ec = (ExtendedColor)obj1;
|
||||
switch (ec.getType()) {
|
||||
case 2:
|
||||
checkColor(writer, 2, obj1);
|
||||
break;
|
||||
case 1:
|
||||
checkColor(writer, 18, obj1);
|
||||
return;
|
||||
case 0:
|
||||
checkColor(writer, 3, obj1);
|
||||
break;
|
||||
case 3:
|
||||
sc = (SpotColor)ec;
|
||||
checkColor(writer, 1, sc.getPdfSpotColor().getAlternativeCS());
|
||||
break;
|
||||
case 5:
|
||||
xc = (ShadingColor)ec;
|
||||
checkColor(writer, 1, xc.getPdfShadingPattern().getShading().getColorSpace());
|
||||
break;
|
||||
case 4:
|
||||
pc = (PatternColor)ec;
|
||||
checkColor(writer, 1, pc.getPainter().getDefaultColor());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (obj1 instanceof com.itextpdf.text.BaseColor)
|
||||
checkColor(writer, 3, obj1);
|
||||
break;
|
||||
case 2:
|
||||
this.cmykUsed = true;
|
||||
break;
|
||||
case 3:
|
||||
this.rgbUsed = true;
|
||||
break;
|
||||
case 18:
|
||||
this.grayUsed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkAnnotation(PdfWriter writer, int key, Object obj1) {
|
||||
if (obj1 instanceof PdfFormField) {
|
||||
PdfFormField field = (PdfFormField)obj1;
|
||||
if (!field.contains(PdfName.SUBTYPE))
|
||||
return;
|
||||
if (field.contains(PdfName.AA) || field.contains(PdfName.A))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("widget.annotation.dictionary.or.field.dictionary.shall.not.include.a.or.aa.entry", new Object[0]));
|
||||
}
|
||||
if (obj1 instanceof PdfAnnotation) {
|
||||
PdfAnnotation annot = (PdfAnnotation)obj1;
|
||||
PdfObject subtype = annot.get(PdfName.SUBTYPE);
|
||||
if (subtype == null)
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("annotation.type.1.not.allowed", new Object[] { "null" }));
|
||||
if (subtype != null && !allowedAnnotTypes.contains(subtype))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("annotation.type.1.not.allowed", new Object[] { subtype.toString() }));
|
||||
if (!PdfName.POPUP.equals(annot.getAsName(PdfName.SUBTYPE))) {
|
||||
PdfNumber f = annot.getAsNumber(PdfName.F);
|
||||
if (f == null)
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("an.annotation.dictionary.shall.contain.the.f.key", new Object[0]));
|
||||
int flags = f.intValue();
|
||||
if (!checkFlag(flags, 4) ||
|
||||
checkFlag(flags, 2) == true ||
|
||||
checkFlag(flags, 1) == true ||
|
||||
checkFlag(flags, 32) == true ||
|
||||
checkFlag(flags, 256) == true)
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("the.f.keys.print.flag.bit.shall.be.set.to.1.and.its.hidden.invisible.noview.and.togglenoview.flag.bits.shall.be.set.to.0", new Object[0]));
|
||||
if (PdfName.TEXT.equals(annot.getAsName(PdfName.SUBTYPE)))
|
||||
if (!checkFlag(flags, 8) || !checkFlag(flags, 16))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("text.annotations.should.set.the.nozoom.and.norotate.flag.bits.of.the.f.key.to.1", new Object[0]));
|
||||
}
|
||||
if (PdfName.WIDGET.equals(annot.getAsName(PdfName.SUBTYPE)) && (annot.contains(PdfName.AA) || annot.contains(PdfName.A)))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("widget.annotation.dictionary.or.field.dictionary.shall.not.include.a.or.aa.entry", new Object[0]));
|
||||
if (checkStructure(this.conformanceLevel) &&
|
||||
contentAnnotations.contains(subtype) && !annot.contains(PdfName.CONTENTS))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("annotation.of.type.1.should.have.contents.key", new Object[] { subtype.toString() }));
|
||||
PdfDictionary ap = getDirectDictionary(annot.get(PdfName.AP));
|
||||
if (ap != null) {
|
||||
if (ap.contains(PdfName.R) || ap.contains(PdfName.D))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("appearance.dictionary.shall.contain.only.the.n.key.with.stream.value", new Object[0]));
|
||||
PdfObject n = getDirectObject(ap.get(PdfName.N));
|
||||
if (PdfName.WIDGET.equals(annot.getAsName(PdfName.SUBTYPE)) && new PdfName("Btn").equals(annot.getAsName(PdfName.FT))) {
|
||||
if (n == null || (!n.isDictionary() && n.type() != 0))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("appearance.dictionary.of.widget.subtype.and.btn.field.type.shall.contain.only.the.n.key.with.dictionary.value", new Object[0]));
|
||||
} else if (n == null || (!n.isStream() && n.type() != 0)) {
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("appearance.dictionary.shall.contain.only.the.n.key.with.stream.value", new Object[0]));
|
||||
}
|
||||
} else {
|
||||
boolean isCorrectRect = false;
|
||||
PdfArray rect = getDirectArray(annot.get(PdfName.RECT));
|
||||
if (rect != null && rect.size() == 4) {
|
||||
PdfNumber index0 = rect.getAsNumber(0);
|
||||
PdfNumber index1 = rect.getAsNumber(1);
|
||||
PdfNumber index2 = rect.getAsNumber(2);
|
||||
PdfNumber index3 = rect.getAsNumber(3);
|
||||
if (index0 != null && index1 != null && index2 != null && index3 != null &&
|
||||
index0.doubleValue() == index2.doubleValue() && index1.doubleValue() == index3.doubleValue())
|
||||
isCorrectRect = true;
|
||||
}
|
||||
if (!PdfName.POPUP.equals(annot.getAsName(PdfName.SUBTYPE)) &&
|
||||
!PdfName.LINK.equals(annot.getAsName(PdfName.SUBTYPE)) && !isCorrectRect)
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("every.annotation.shall.have.at.least.one.appearance.dictionary", new Object[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkAction(PdfWriter writer, int key, Object obj1) {
|
||||
if (obj1 instanceof PdfAction) {
|
||||
PdfAction action = (PdfAction)obj1;
|
||||
PdfName s = action.getAsName(PdfName.S);
|
||||
if (PdfA1Checker.setState.equals(s) || PdfA1Checker.noOp.equals(s))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("deprecated.setstate.and.noop.actions.are.not.allowed", new Object[0]));
|
||||
if (restrictedActions.contains(s))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("launch.sound.movie.resetform.importdata.and.javascript.actions.are.not.allowed", new Object[0]));
|
||||
if (PdfName.NAMED.equals(s)) {
|
||||
PdfName n = action.getAsName(PdfName.N);
|
||||
if (n != null && !PdfA1Checker.allowedNamedActions.contains(n))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("named.action.type.1.not.allowed", new Object[] { n.toString() }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkForm(PdfWriter writer, int key, Object obj1) {
|
||||
if (obj1 instanceof PdfAcroForm) {
|
||||
PdfAcroForm form = (PdfAcroForm)obj1;
|
||||
PdfBoolean needAppearances = form.getAsBoolean(PdfName.NEEDAPPEARANCES);
|
||||
if (needAppearances != null && needAppearances.booleanValue())
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("needappearances.flag.of.the.interactive.form.dictionary.shall.either.not.be.present.or.shall.be.false", new Object[0]));
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkStructElem(PdfWriter writer, int key, Object obj1) {
|
||||
if (obj1 instanceof PdfStructureElement) {
|
||||
PdfStructureElement structElem = (PdfStructureElement)obj1;
|
||||
PdfName role = structElem.getStructureType();
|
||||
if (PdfName.FIGURE.equals(role) || PdfName.FORMULA.equals(role) || PdfName.FORM.equals(role)) {
|
||||
PdfObject o = structElem.get(PdfName.ALT);
|
||||
if (!(o instanceof PdfString) || o.toString().length() <= 0)
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("alt.entry.should.specify.alternate.description.for.1.element", new Object[] { role.toString() }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkOutputIntent(PdfWriter writer, int key, Object obj1) {
|
||||
if (writer instanceof com.itextpdf.text.pdf.PdfAStamperImp && writer.getColorProfile() != null)
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("outputintent.shall.not.be.updated", new Object[0]));
|
||||
}
|
||||
|
||||
private void fillOrderRecursively(PdfArray orderArray, HashSet<PdfObject> order) {
|
||||
for (int i = 0; i < orderArray.size(); i++) {
|
||||
PdfArray orderChild = getDirectArray(orderArray.getPdfObject(i));
|
||||
if (orderChild == null) {
|
||||
order.add(orderArray.getPdfObject(i));
|
||||
} else {
|
||||
fillOrderRecursively(orderChild, order);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void close(PdfWriter writer) {
|
||||
checkOutputIntentsInStamperMode(writer);
|
||||
if (this.pdfaOutputIntentColorSpace != null) {
|
||||
if ("RGB ".equals(this.pdfaOutputIntentColorSpace)) {
|
||||
if (this.cmykUsed && writer.getDefaultColorspace().get(PdfName.DEFAULTCMYK) == null)
|
||||
throw new PdfAConformanceException(null, MessageLocalization.getComposedMessage("devicecmyk.shall.only.be.used.if.defaultcmyk.pdfa.or.outputintent", new Object[0]));
|
||||
} else if ("CMYK".equals(this.pdfaOutputIntentColorSpace)) {
|
||||
if (this.rgbUsed && writer.getDefaultColorspace().get(PdfName.DEFAULTRGB) == null)
|
||||
throw new PdfAConformanceException(null, MessageLocalization.getComposedMessage("devicergb.shall.only.be.used.if.defaultrgb.pdfa.or.outputintent", new Object[0]));
|
||||
} else if ("GRAY".equals(this.pdfaOutputIntentColorSpace)) {
|
||||
if (this.rgbUsed && writer.getDefaultColorspace().get(PdfName.DEFAULTRGB) == null)
|
||||
throw new PdfAConformanceException(null, MessageLocalization.getComposedMessage("devicergb.shall.only.be.used.if.defaultrgb.pdfa.or.outputintent", new Object[0]));
|
||||
if (this.cmykUsed && writer.getDefaultColorspace().get(PdfName.DEFAULTCMYK) == null)
|
||||
throw new PdfAConformanceException(null, MessageLocalization.getComposedMessage("devicecmyk.shall.only.be.used.if.defaultcmyk.pdfa.or.outputintent", new Object[0]));
|
||||
} else {
|
||||
throw new PdfAConformanceException(null, MessageLocalization.getComposedMessage("outputintent.shall.have.colourspace.gray.rgb.or.cmyk", new Object[0]));
|
||||
}
|
||||
} else {
|
||||
if (this.rgbUsed && writer.getDefaultColorspace().get(PdfName.DEFAULTRGB) == null)
|
||||
throw new PdfAConformanceException(null, MessageLocalization.getComposedMessage("devicergb.shall.only.be.used.if.defaultrgb.pdfa.or.outputintent", new Object[0]));
|
||||
if (this.cmykUsed && writer.getDefaultColorspace().get(PdfName.DEFAULTCMYK) == null)
|
||||
throw new PdfAConformanceException(null, MessageLocalization.getComposedMessage("devicecmyk.shall.only.be.used.if.defaultcmyk.pdfa.or.outputintent", new Object[0]));
|
||||
if (this.grayUsed && writer.getDefaultColorspace().get(PdfName.DEFAULTGRAY) == null)
|
||||
throw new PdfAConformanceException(null, MessageLocalization.getComposedMessage("devicegray.shall.only.be.used.if.defaultgray.pdfa.or.outputintent", new Object[0]));
|
||||
if (this.transparencyWithoutPageGroupDetected)
|
||||
throw new PdfAConformanceException(null, MessageLocalization.getComposedMessage("if.the.document.not.contain.outputintent.transparencygroup.shall.comtain.cs.key", new Object[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
package com.itextpdf.text.pdf.internal;
|
||||
|
||||
import com.itextpdf.text.error_messages.MessageLocalization;
|
||||
import com.itextpdf.text.pdf.AFRelationshipValue;
|
||||
import com.itextpdf.text.pdf.PdfAConformanceException;
|
||||
import com.itextpdf.text.pdf.PdfAConformanceLevel;
|
||||
import com.itextpdf.text.pdf.PdfDictionary;
|
||||
import com.itextpdf.text.pdf.PdfFileSpecification;
|
||||
import com.itextpdf.text.pdf.PdfName;
|
||||
import com.itextpdf.text.pdf.PdfObject;
|
||||
import com.itextpdf.text.pdf.PdfWriter;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class PdfA3Checker extends PdfA2Checker {
|
||||
private static HashSet<PdfName> allowedAFRelationships = new HashSet<PdfName>(Arrays.<PdfName>asList(AFRelationshipValue.Source, AFRelationshipValue.Data, AFRelationshipValue.Alternative, AFRelationshipValue.Supplement, AFRelationshipValue.Unspecified));
|
||||
|
||||
PdfA3Checker(PdfAConformanceLevel conformanceLevel) {
|
||||
super(conformanceLevel);
|
||||
}
|
||||
|
||||
protected HashSet<PdfName> initKeysForCheck() {
|
||||
HashSet<PdfName> keysForCheck = super.initKeysForCheck();
|
||||
keysForCheck.add(PdfName.PARAMS);
|
||||
keysForCheck.add(PdfName.MODDATE);
|
||||
keysForCheck.add(PdfName.F);
|
||||
return keysForCheck;
|
||||
}
|
||||
|
||||
protected void checkFileSpec(PdfWriter writer, int key, Object obj1) {
|
||||
if (obj1 instanceof PdfFileSpecification) {
|
||||
PdfFileSpecification pdfFileSpecification = (PdfFileSpecification)obj1;
|
||||
if (!pdfFileSpecification.contains(PdfName.UF) || !pdfFileSpecification.contains(PdfName.F) ||
|
||||
!pdfFileSpecification.contains(PdfName.DESC))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("file.specification.dictionary.shall.contain.f.uf.and.desc.entries", new Object[0]));
|
||||
PdfObject obj = pdfFileSpecification.get(PdfName.AFRELATIONSHIP);
|
||||
if (obj == null || !obj.isName() || !allowedAFRelationships.contains(obj))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("file.specification.dictionary.shall.contain.correct.afrelationship.key", new Object[0]));
|
||||
if (pdfFileSpecification.contains(PdfName.EF)) {
|
||||
PdfDictionary dict = getDirectDictionary(pdfFileSpecification.get(PdfName.EF));
|
||||
if (dict == null || !dict.contains(PdfName.F))
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("ef.key.of.file.specification.dictionary.shall.contain.dictionary.with.valid.f.key", new Object[0]));
|
||||
PdfDictionary embeddedFile = getDirectDictionary(dict.get(PdfName.F));
|
||||
if (embeddedFile == null)
|
||||
throw new PdfAConformanceException(obj1, MessageLocalization.getComposedMessage("ef.key.of.file.specification.dictionary.shall.contain.dictionary.with.valid.f.key", new Object[0]));
|
||||
checkEmbeddedFile(embeddedFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkEmbeddedFile(PdfDictionary embeddedFile) {
|
||||
PdfObject params = getDirectObject(embeddedFile.get(PdfName.PARAMS));
|
||||
if (params == null)
|
||||
throw new PdfAConformanceException(embeddedFile, MessageLocalization.getComposedMessage("embedded.file.shall.contain.valid.params.key", new Object[0]));
|
||||
if (params.isDictionary()) {
|
||||
PdfObject modDate = ((PdfDictionary)params).get(PdfName.MODDATE);
|
||||
if (modDate == null || !(modDate instanceof com.itextpdf.text.pdf.PdfString))
|
||||
throw new PdfAConformanceException(embeddedFile, MessageLocalization.getComposedMessage("embedded.file.shall.contain.params.key.with.valid.moddate.key", new Object[0]));
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkPdfObject(PdfWriter writer, int key, Object obj1) {
|
||||
super.checkPdfObject(writer, key, obj1);
|
||||
if (obj1 instanceof PdfDictionary) {
|
||||
PdfDictionary dictionary = (PdfDictionary)obj1;
|
||||
PdfName type = dictionary.getAsName(PdfName.TYPE);
|
||||
if (PdfName.EMBEDDEDFILE.equals(type))
|
||||
checkEmbeddedFile(dictionary);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,288 @@
|
|||
package com.itextpdf.text.pdf.internal;
|
||||
|
||||
import com.itextpdf.text.ExceptionConverter;
|
||||
import com.itextpdf.text.error_messages.MessageLocalization;
|
||||
import com.itextpdf.text.io.TempFileCache;
|
||||
import com.itextpdf.text.pdf.PdfAConformanceException;
|
||||
import com.itextpdf.text.pdf.PdfAConformanceLevel;
|
||||
import com.itextpdf.text.pdf.PdfAStamperImp;
|
||||
import com.itextpdf.text.pdf.PdfArray;
|
||||
import com.itextpdf.text.pdf.PdfDictionary;
|
||||
import com.itextpdf.text.pdf.PdfIndirectReference;
|
||||
import com.itextpdf.text.pdf.PdfName;
|
||||
import com.itextpdf.text.pdf.PdfObject;
|
||||
import com.itextpdf.text.pdf.PdfReader;
|
||||
import com.itextpdf.text.pdf.PdfStream;
|
||||
import com.itextpdf.text.pdf.PdfWriter;
|
||||
import com.itextpdf.text.pdf.RefKey;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public abstract class PdfAChecker {
|
||||
protected final Logger LOGGER = Logger.getLogger(getClass().getName());
|
||||
|
||||
protected PdfAConformanceLevel conformanceLevel;
|
||||
|
||||
private HashMap<RefKey, PdfObject> cachedObjects = new HashMap<RefKey, PdfObject>();
|
||||
|
||||
private HashSet<PdfName> keysForCheck = initKeysForCheck();
|
||||
|
||||
private static byte[] emptyByteArray = new byte[0];
|
||||
|
||||
TempFileCache fileCache;
|
||||
|
||||
private boolean isToUseExternalCache = false;
|
||||
|
||||
private HashMap<RefKey, TempFileCache.ObjectPosition> externallyCachedObjects = new HashMap<RefKey, TempFileCache.ObjectPosition>();
|
||||
|
||||
protected String pdfaOutputIntentColorSpace = null;
|
||||
|
||||
protected PdfObject pdfaDestOutputIntent = null;
|
||||
|
||||
protected boolean isCheckOutputIntent = false;
|
||||
|
||||
PdfAChecker(PdfAConformanceLevel conformanceLevel) {
|
||||
this.conformanceLevel = conformanceLevel;
|
||||
}
|
||||
|
||||
protected abstract HashSet<PdfName> initKeysForCheck();
|
||||
|
||||
public void cacheObject(PdfIndirectReference iref, PdfObject obj) {
|
||||
if (obj.type() == 0) {
|
||||
putObjectToCache(new RefKey(iref), obj);
|
||||
} else if (obj instanceof PdfDictionary) {
|
||||
putObjectToCache(new RefKey(iref), cleverPdfDictionaryClone((PdfDictionary)obj));
|
||||
} else if (obj.isArray()) {
|
||||
putObjectToCache(new RefKey(iref), cleverPdfArrayClone((PdfArray)obj));
|
||||
}
|
||||
}
|
||||
|
||||
public void useExternalCache(TempFileCache fileCache) {
|
||||
this.isToUseExternalCache = true;
|
||||
this.fileCache = fileCache;
|
||||
for (Map.Entry<RefKey, PdfObject> entry : this.cachedObjects.entrySet())
|
||||
putObjectToCache(entry.getKey(), entry.getValue());
|
||||
this.cachedObjects.clear();
|
||||
}
|
||||
|
||||
public abstract void close(PdfWriter paramPdfWriter);
|
||||
|
||||
private PdfObject cleverPdfArrayClone(PdfArray array) {
|
||||
PdfArray newArray = new PdfArray();
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
PdfObject obj = array.getPdfObject(i);
|
||||
if (obj instanceof PdfDictionary) {
|
||||
newArray.add(cleverPdfDictionaryClone((PdfDictionary)obj));
|
||||
} else {
|
||||
newArray.add(obj);
|
||||
}
|
||||
}
|
||||
return (PdfObject)newArray;
|
||||
}
|
||||
|
||||
private PdfObject cleverPdfDictionaryClone(PdfDictionary dict) {
|
||||
PdfDictionary newDict;
|
||||
if (dict.isStream()) {
|
||||
PdfStream pdfStream = new PdfStream(emptyByteArray);
|
||||
pdfStream.remove(PdfName.LENGTH);
|
||||
} else {
|
||||
newDict = new PdfDictionary();
|
||||
}
|
||||
for (PdfName key : (Iterable<PdfName>)dict.getKeys()) {
|
||||
if (this.keysForCheck.contains(key))
|
||||
newDict.put(key, dict.get(key));
|
||||
}
|
||||
return (PdfObject)newDict;
|
||||
}
|
||||
|
||||
protected PdfObject getDirectObject(PdfObject obj) {
|
||||
if (obj == null)
|
||||
return null;
|
||||
int count = 0;
|
||||
while (obj instanceof PdfIndirectReference) {
|
||||
PdfObject curr;
|
||||
if (obj.isIndirect()) {
|
||||
curr = PdfReader.getPdfObject(obj);
|
||||
} else {
|
||||
curr = getObjectFromCache(new RefKey((PdfIndirectReference)obj));
|
||||
}
|
||||
if (curr == null)
|
||||
break;
|
||||
obj = curr;
|
||||
if (count++ > 10)
|
||||
break;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
protected PdfDictionary getDirectDictionary(PdfObject obj) {
|
||||
obj = getDirectObject(obj);
|
||||
if (obj != null && obj instanceof PdfDictionary)
|
||||
return (PdfDictionary)obj;
|
||||
return null;
|
||||
}
|
||||
|
||||
protected PdfStream getDirectStream(PdfObject obj) {
|
||||
obj = getDirectObject(obj);
|
||||
if (obj != null && obj.isStream())
|
||||
return (PdfStream)obj;
|
||||
return null;
|
||||
}
|
||||
|
||||
protected PdfArray getDirectArray(PdfObject obj) {
|
||||
obj = getDirectObject(obj);
|
||||
if (obj != null && obj.isArray())
|
||||
return (PdfArray)obj;
|
||||
return null;
|
||||
}
|
||||
|
||||
protected abstract void checkFont(PdfWriter paramPdfWriter, int paramInt, Object paramObject);
|
||||
|
||||
protected abstract void checkImage(PdfWriter paramPdfWriter, int paramInt, Object paramObject);
|
||||
|
||||
protected abstract void checkInlineImage(PdfWriter paramPdfWriter, int paramInt, Object paramObject);
|
||||
|
||||
protected abstract void checkFormXObj(PdfWriter paramPdfWriter, int paramInt, Object paramObject);
|
||||
|
||||
protected abstract void checkGState(PdfWriter paramPdfWriter, int paramInt, Object paramObject);
|
||||
|
||||
protected abstract void checkLayer(PdfWriter paramPdfWriter, int paramInt, Object paramObject);
|
||||
|
||||
protected abstract void checkTrailer(PdfWriter paramPdfWriter, int paramInt, Object paramObject);
|
||||
|
||||
protected abstract void checkStream(PdfWriter paramPdfWriter, int paramInt, Object paramObject);
|
||||
|
||||
protected abstract void checkFileSpec(PdfWriter paramPdfWriter, int paramInt, Object paramObject);
|
||||
|
||||
protected abstract void checkPdfObject(PdfWriter paramPdfWriter, int paramInt, Object paramObject);
|
||||
|
||||
protected abstract void checkCanvas(PdfWriter paramPdfWriter, int paramInt, Object paramObject);
|
||||
|
||||
protected abstract void checkColor(PdfWriter paramPdfWriter, int paramInt, Object paramObject);
|
||||
|
||||
protected abstract void checkAnnotation(PdfWriter paramPdfWriter, int paramInt, Object paramObject);
|
||||
|
||||
protected abstract void checkAction(PdfWriter paramPdfWriter, int paramInt, Object paramObject);
|
||||
|
||||
protected abstract void checkForm(PdfWriter paramPdfWriter, int paramInt, Object paramObject);
|
||||
|
||||
protected abstract void checkStructElem(PdfWriter paramPdfWriter, int paramInt, Object paramObject);
|
||||
|
||||
protected abstract void checkOutputIntent(PdfWriter paramPdfWriter, int paramInt, Object paramObject);
|
||||
|
||||
void checkPdfAConformance(PdfWriter writer, int key, Object obj1) {
|
||||
if (writer == null || !writer.isPdfIso())
|
||||
return;
|
||||
switch (key) {
|
||||
case 4:
|
||||
checkFont(writer, key, obj1);
|
||||
break;
|
||||
case 5:
|
||||
checkImage(writer, key, obj1);
|
||||
break;
|
||||
case 6:
|
||||
checkGState(writer, key, obj1);
|
||||
break;
|
||||
case 7:
|
||||
checkLayer(writer, key, obj1);
|
||||
break;
|
||||
case 8:
|
||||
checkTrailer(writer, key, obj1);
|
||||
break;
|
||||
case 9:
|
||||
checkStream(writer, key, obj1);
|
||||
break;
|
||||
case 10:
|
||||
checkFileSpec(writer, key, obj1);
|
||||
break;
|
||||
case 11:
|
||||
checkPdfObject(writer, key, obj1);
|
||||
break;
|
||||
case 12:
|
||||
checkCanvas(writer, key, obj1);
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
checkColor(writer, key, obj1);
|
||||
break;
|
||||
case 13:
|
||||
checkAnnotation(writer, key, obj1);
|
||||
break;
|
||||
case 14:
|
||||
checkAction(writer, key, obj1);
|
||||
break;
|
||||
case 15:
|
||||
checkForm(writer, key, obj1);
|
||||
break;
|
||||
case 16:
|
||||
if (checkStructure(this.conformanceLevel))
|
||||
checkStructElem(writer, key, obj1);
|
||||
break;
|
||||
case 17:
|
||||
checkInlineImage(writer, key, obj1);
|
||||
break;
|
||||
case 19:
|
||||
checkOutputIntent(writer, key, obj1);
|
||||
break;
|
||||
case 20:
|
||||
checkFormXObj(writer, key, obj1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean checkStructure(PdfAConformanceLevel conformanceLevel) {
|
||||
return (conformanceLevel == PdfAConformanceLevel.PDF_A_1A || conformanceLevel == PdfAConformanceLevel.PDF_A_2A || conformanceLevel == PdfAConformanceLevel.PDF_A_3A);
|
||||
}
|
||||
|
||||
protected static boolean checkFlag(int flags, int flag) {
|
||||
return ((flags & flag) != 0);
|
||||
}
|
||||
|
||||
private void putObjectToCache(RefKey ref, PdfObject obj) {
|
||||
if (this.isToUseExternalCache) {
|
||||
TempFileCache.ObjectPosition pos = null;
|
||||
try {
|
||||
pos = this.fileCache.put(obj);
|
||||
} catch (IOException e) {
|
||||
throw new ExceptionConverter(e);
|
||||
}
|
||||
this.externallyCachedObjects.put(ref, pos);
|
||||
} else {
|
||||
this.cachedObjects.put(ref, obj);
|
||||
}
|
||||
}
|
||||
|
||||
private PdfObject getObjectFromCache(RefKey ref) {
|
||||
if (this.isToUseExternalCache) {
|
||||
PdfObject obj = null;
|
||||
TempFileCache.ObjectPosition pos = this.externallyCachedObjects.get(ref);
|
||||
try {
|
||||
obj = this.fileCache.get(pos);
|
||||
} catch (IOException e) {
|
||||
throw new ExceptionConverter(e);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new ExceptionConverter(e);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
return this.cachedObjects.get(ref);
|
||||
}
|
||||
|
||||
protected void checkOutputIntentsInStamperMode(PdfWriter writer) {
|
||||
if (writer instanceof PdfAStamperImp && !this.isCheckOutputIntent) {
|
||||
PdfReader pdfReader = ((PdfAStamperImp)writer).getPdfReader();
|
||||
PdfArray outPutIntentsDic = pdfReader.getCatalog().getAsArray(PdfName.OUTPUTINTENTS);
|
||||
if (outPutIntentsDic != null) {
|
||||
if (outPutIntentsDic.size() > 1)
|
||||
throw new PdfAConformanceException(outPutIntentsDic, MessageLocalization.getComposedMessage("a.pdfa.file.may.have.only.one.pdfa.outputintent", new Object[0]));
|
||||
PdfDictionary outPutIntentDic = outPutIntentsDic.getAsDict(0);
|
||||
if (outPutIntentDic != null)
|
||||
checkPdfObject(writer, 11, outPutIntentDic);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
package com.itextpdf.text.pdf.internal;
|
||||
|
||||
import com.itextpdf.text.pdf.PdfAConformanceLevel;
|
||||
import com.itextpdf.text.pdf.PdfWriter;
|
||||
import com.itextpdf.text.pdf.interfaces.PdfAConformance;
|
||||
|
||||
public class PdfAConformanceImp implements PdfAConformance {
|
||||
protected PdfAConformanceLevel conformanceLevel;
|
||||
|
||||
protected PdfAChecker pdfAChecker;
|
||||
|
||||
protected PdfWriter writer;
|
||||
|
||||
public PdfAConformanceImp(PdfWriter writer) {
|
||||
this.writer = writer;
|
||||
}
|
||||
|
||||
public void checkPdfIsoConformance(int key, Object obj1) {
|
||||
this.pdfAChecker.checkPdfAConformance(this.writer, key, obj1);
|
||||
}
|
||||
|
||||
public PdfAConformanceLevel getConformanceLevel() {
|
||||
return this.conformanceLevel;
|
||||
}
|
||||
|
||||
public void setConformanceLevel(PdfAConformanceLevel conformanceLevel) {
|
||||
this.conformanceLevel = conformanceLevel;
|
||||
switch (this.conformanceLevel) {
|
||||
case PDF_A_1A:
|
||||
case PDF_A_1B:
|
||||
this.pdfAChecker = new PdfA1Checker(conformanceLevel);
|
||||
break;
|
||||
case PDF_A_2A:
|
||||
case PDF_A_2B:
|
||||
case PDF_A_2U:
|
||||
this.pdfAChecker = new PdfA2Checker(conformanceLevel);
|
||||
break;
|
||||
case PDF_A_3A:
|
||||
case PDF_A_3B:
|
||||
case PDF_A_3U:
|
||||
this.pdfAChecker = new PdfA3Checker(conformanceLevel);
|
||||
break;
|
||||
case ZUGFeRD:
|
||||
case ZUGFeRDComfort:
|
||||
case ZUGFeRDBasic:
|
||||
case ZUGFeRDExtended:
|
||||
this.pdfAChecker = new ZugferdChecker(conformanceLevel);
|
||||
break;
|
||||
default:
|
||||
this.pdfAChecker = new PdfA1Checker(conformanceLevel);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isPdfIso() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public PdfAChecker getPdfAChecker() {
|
||||
return this.pdfAChecker;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
package com.itextpdf.text.pdf.internal;
|
||||
|
||||
import com.itextpdf.text.ExceptionConverter;
|
||||
import com.itextpdf.text.error_messages.MessageLocalization;
|
||||
import com.itextpdf.text.pdf.AFRelationshipValue;
|
||||
import com.itextpdf.text.pdf.PdfAConformanceException;
|
||||
import com.itextpdf.text.pdf.PdfAConformanceLevel;
|
||||
import com.itextpdf.text.pdf.PdfAStamperImp;
|
||||
import com.itextpdf.text.pdf.PdfArray;
|
||||
import com.itextpdf.text.pdf.PdfDictionary;
|
||||
import com.itextpdf.text.pdf.PdfFileSpecification;
|
||||
import com.itextpdf.text.pdf.PdfName;
|
||||
import com.itextpdf.text.pdf.PdfReader;
|
||||
import com.itextpdf.text.pdf.PdfWriter;
|
||||
import com.itextpdf.xmp.XMPException;
|
||||
import com.itextpdf.xmp.XMPMeta;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ZugferdChecker extends PdfA3Checker {
|
||||
private List<PdfFileSpecification> attachments = new ArrayList<PdfFileSpecification>();
|
||||
|
||||
ZugferdChecker(PdfAConformanceLevel conformanceLevel) {
|
||||
super(conformanceLevel);
|
||||
}
|
||||
|
||||
protected void checkFileSpec(PdfWriter writer, int key, Object obj1) {
|
||||
super.checkFileSpec(writer, key, obj1);
|
||||
this.attachments.add((PdfFileSpecification)obj1);
|
||||
}
|
||||
|
||||
public void close(PdfWriter writer) {
|
||||
super.close(writer);
|
||||
boolean ok = false;
|
||||
XMPMeta xmpMeta = null;
|
||||
if (writer.getXmpWriter() == null) {
|
||||
if (writer instanceof PdfAStamperImp) {
|
||||
xmpMeta = ((PdfAStamperImp)writer).getXmpMeta();
|
||||
PdfReader pdfReader = ((PdfAStamperImp)writer).getPdfReader();
|
||||
PdfArray pdfArray = pdfReader.getCatalog().getAsArray(PdfName.AF);
|
||||
if (pdfArray != null)
|
||||
for (int i = 0; i < pdfArray.size(); i++) {
|
||||
PdfFileSpecification pdfFileSpecification = new PdfFileSpecification();
|
||||
pdfFileSpecification.putAll((PdfDictionary)pdfArray.getDirectObject(i));
|
||||
this.attachments.add(pdfFileSpecification);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
xmpMeta = writer.getXmpWriter().getXmpMeta();
|
||||
}
|
||||
if (xmpMeta == null)
|
||||
writer.createXmpMetadata();
|
||||
try {
|
||||
String docFileName = xmpMeta.getPropertyString("urn:ferd:pdfa:CrossIndustryDocument:invoice:1p0#", "DocumentFileName");
|
||||
for (PdfFileSpecification attachment : this.attachments) {
|
||||
if ((attachment.getAsString(PdfName.UF) != null && docFileName.equals(attachment.getAsString(PdfName.UF).toString())) || (
|
||||
attachment.getAsString(PdfName.F) != null && docFileName.equals(attachment.getAsString(PdfName.F).toString()))) {
|
||||
PdfName relationship = attachment.getAsName(PdfName.AFRELATIONSHIP);
|
||||
if (!AFRelationshipValue.Alternative.equals(relationship)) {
|
||||
this.attachments.clear();
|
||||
throw new PdfAConformanceException(attachment, MessageLocalization.getComposedMessage("afrelationship.value.shall.be.alternative", new Object[0]));
|
||||
}
|
||||
ok = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (XMPException e) {
|
||||
this.attachments.clear();
|
||||
throw new ExceptionConverter(e);
|
||||
}
|
||||
this.attachments.clear();
|
||||
if (!ok)
|
||||
throw new PdfAConformanceException(xmpMeta, MessageLocalization.getComposedMessage("zugferd.xmp.schema.shall.contain.attachment.name", new Object[0]));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.itextpdf.text.xml.xmp;
|
||||
|
||||
import com.itextpdf.xmp.XMPException;
|
||||
import com.itextpdf.xmp.XMPMeta;
|
||||
|
||||
public class PdfAProperties {
|
||||
public static final String PART = "part";
|
||||
|
||||
public static final String CONFORMANCE = "conformance";
|
||||
|
||||
public static void setPart(XMPMeta xmpMeta, String part) throws XMPException {
|
||||
xmpMeta.setProperty("http://www.aiim.org/pdfa/ns/id/", "part", part);
|
||||
}
|
||||
|
||||
public static void setConformance(XMPMeta xmpMeta, String conformance) throws XMPException {
|
||||
xmpMeta.setProperty("http://www.aiim.org/pdfa/ns/id/", "conformance", conformance);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package com.itextpdf.text.xml.xmp;
|
||||
|
||||
@Deprecated
|
||||
public class PdfASchema extends XmpSchema {
|
||||
private static final long serialVersionUID = 5300646133692948168L;
|
||||
|
||||
public static final String DEFAULT_XPATH_ID = "pdfaid";
|
||||
|
||||
public static final String DEFAULT_XPATH_URI = "http://www.aiim.org/pdfa/ns/id/";
|
||||
|
||||
public static final String PART = "pdfaid:part";
|
||||
|
||||
public static final String CONFORMANCE = "pdfaid:conformance";
|
||||
|
||||
public PdfASchema() {
|
||||
super("xmlns:pdfaid=\"http://www.aiim.org/pdfa/ns/id/\"");
|
||||
}
|
||||
|
||||
public void addPart(String part) {
|
||||
setProperty("pdfaid:part", part);
|
||||
}
|
||||
|
||||
public void addConformance(String conformance) {
|
||||
setProperty("pdfaid:conformance", conformance);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,124 @@
|
|||
package com.itextpdf.text.xml.xmp;
|
||||
|
||||
import com.itextpdf.text.pdf.PdfAConformanceLevel;
|
||||
import com.itextpdf.text.pdf.PdfDictionary;
|
||||
import com.itextpdf.text.pdf.PdfWriter;
|
||||
import com.itextpdf.xmp.XMPException;
|
||||
import com.itextpdf.xmp.XMPMeta;
|
||||
import com.itextpdf.xmp.XMPMetaFactory;
|
||||
import com.itextpdf.xmp.XMPUtils;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Map;
|
||||
|
||||
public class PdfAXmpWriter extends XmpWriter {
|
||||
private static final String pdfUaExtension = " <x:xmpmeta xmlns:x=\"adobe:ns:meta/\">\n <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n <rdf:Description rdf:about=\"\" xmlns:pdfaExtension=\"http://www.aiim.org/pdfa/ns/extension/\" xmlns:pdfaSchema=\"http://www.aiim.org/pdfa/ns/schema#\" xmlns:pdfaProperty=\"http://www.aiim.org/pdfa/ns/property#\">\n <pdfaExtension:schemas>\n <rdf:Bag>\n <rdf:li rdf:parseType=\"Resource\">\n <pdfaSchema:namespaceURI>http://www.aiim.org/pdfua/ns/id/</pdfaSchema:namespaceURI>\n <pdfaSchema:prefix>pdfuaid</pdfaSchema:prefix>\n <pdfaSchema:schema>PDF/UA identification schema</pdfaSchema:schema>\n <pdfaSchema:property>\n <rdf:Seq>\n <rdf:li rdf:parseType=\"Resource\">\n <pdfaProperty:category>internal</pdfaProperty:category>\n <pdfaProperty:description>PDF/UA version identifier</pdfaProperty:description>\n <pdfaProperty:name>part</pdfaProperty:name>\n <pdfaProperty:valueType>Integer</pdfaProperty:valueType>\n </rdf:li>\n <rdf:li rdf:parseType=\"Resource\">\n <pdfaProperty:category>internal</pdfaProperty:category>\n <pdfaProperty:description>PDF/UA amendment identifier</pdfaProperty:description>\n <pdfaProperty:name>amd</pdfaProperty:name>\n <pdfaProperty:valueType>Text</pdfaProperty:valueType>\n </rdf:li>\n <rdf:li rdf:parseType=\"Resource\">\n <pdfaProperty:category>internal</pdfaProperty:category>\n <pdfaProperty:description>PDF/UA corrigenda identifier</pdfaProperty:description>\n <pdfaProperty:name>corr</pdfaProperty:name>\n <pdfaProperty:valueType>Text</pdfaProperty:valueType>\n </rdf:li>\n </rdf:Seq>\n </pdfaSchema:property>\n </rdf:li>\n </rdf:Bag>\n </pdfaExtension:schemas>\n </rdf:Description>\n </rdf:RDF>\n </x:xmpmeta>";
|
||||
|
||||
private static final String zugferdExtension = " <x:xmpmeta xmlns:x=\"adobe:ns:meta/\">\n <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n <rdf:Description rdf:about=\"\" xmlns:zf=\"urn:ferd:pdfa:CrossIndustryDocument:invoice:1p0#\">\n <zf:ConformanceLevel>%s</zf:ConformanceLevel>\n <zf:DocumentFileName>ZUGFeRD-invoice.xml</zf:DocumentFileName>\n <zf:DocumentType>INVOICE</zf:DocumentType>\n <zf:Version>1.0</zf:Version>\n </rdf:Description>\n <rdf:Description rdf:about=\"\" xmlns:pdfaExtension=\"http://www.aiim.org/pdfa/ns/extension/\" xmlns:pdfaSchema=\"http://www.aiim.org/pdfa/ns/schema#\" xmlns:pdfaProperty=\"http://www.aiim.org/pdfa/ns/property#\">\n <pdfaExtension:schemas>\n <rdf:Bag>\n <rdf:li rdf:parseType=\"Resource\">\n <pdfaSchema:schema>ZUGFeRD PDFA Extension Schema</pdfaSchema:schema>\n <pdfaSchema:namespaceURI>urn:ferd:pdfa:CrossIndustryDocument:invoice:1p0#</pdfaSchema:namespaceURI>\n <pdfaSchema:prefix>zf</pdfaSchema:prefix>\n <pdfaSchema:property>\n <rdf:Seq>\n <rdf:li rdf:parseType=\"Resource\">\n <pdfaProperty:name>DocumentFileName</pdfaProperty:name>\n <pdfaProperty:valueType>Text</pdfaProperty:valueType>\n <pdfaProperty:category>external</pdfaProperty:category>\n <pdfaProperty:description>name of the embedded XML invoice file</pdfaProperty:description>\n </rdf:li>\n <rdf:li rdf:parseType=\"Resource\">\n <pdfaProperty:name>DocumentType</pdfaProperty:name>\n <pdfaProperty:valueType>Text</pdfaProperty:valueType>\n <pdfaProperty:category>external</pdfaProperty:category>\n <pdfaProperty:description>INVOICE</pdfaProperty:description>\n </rdf:li>\n <rdf:li rdf:parseType=\"Resource\">\n <pdfaProperty:name>Version</pdfaProperty:name>\n <pdfaProperty:valueType>Text</pdfaProperty:valueType>\n <pdfaProperty:category>external</pdfaProperty:category>\n <pdfaProperty:description>The actual version of the ZUGFeRD data</pdfaProperty:description>\n </rdf:li>\n <rdf:li rdf:parseType=\"Resource\">\n <pdfaProperty:name>ConformanceLevel</pdfaProperty:name>\n <pdfaProperty:valueType>Text</pdfaProperty:valueType>\n <pdfaProperty:category>external</pdfaProperty:category>\n <pdfaProperty:description>The conformance level of the ZUGFeRD data</pdfaProperty:description>\n </rdf:li>\n </rdf:Seq>\n </pdfaSchema:property>\n </rdf:li>\n </rdf:Bag>\n </pdfaExtension:schemas>\n </rdf:Description>\n </rdf:RDF>\n </x:xmpmeta>\n";
|
||||
|
||||
private PdfWriter writer;
|
||||
|
||||
public static final String zugferdSchemaNS = "urn:ferd:pdfa:CrossIndustryDocument:invoice:1p0#";
|
||||
|
||||
public static final String zugferdConformanceLevel = "ConformanceLevel";
|
||||
|
||||
public static final String zugferdDocumentFileName = "DocumentFileName";
|
||||
|
||||
public static final String zugferdDocumentType = "DocumentType";
|
||||
|
||||
public static final String zugferdVersion = "Version";
|
||||
|
||||
public PdfAXmpWriter(OutputStream os, PdfAConformanceLevel conformanceLevel, PdfWriter writer) throws IOException {
|
||||
super(os);
|
||||
this.writer = writer;
|
||||
try {
|
||||
addRdfDescription(conformanceLevel);
|
||||
} catch (XMPException xmpExc) {
|
||||
throw new IOException(xmpExc.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public PdfAXmpWriter(OutputStream os, PdfDictionary info, PdfAConformanceLevel conformanceLevel, PdfWriter writer) throws IOException {
|
||||
super(os, info);
|
||||
this.writer = writer;
|
||||
try {
|
||||
addRdfDescription(conformanceLevel);
|
||||
} catch (XMPException xmpExc) {
|
||||
throw new IOException(xmpExc.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public PdfAXmpWriter(OutputStream os, Map<String, String> info, PdfAConformanceLevel conformanceLevel, PdfWriter writer) throws IOException {
|
||||
super(os, info);
|
||||
this.writer = writer;
|
||||
try {
|
||||
addRdfDescription(conformanceLevel);
|
||||
} catch (XMPException xmpExc) {
|
||||
throw new IOException(xmpExc.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void addRdfDescription(PdfAConformanceLevel conformanceLevel) throws XMPException {
|
||||
XMPMeta taggedExtensionMetaComfort;
|
||||
switch (conformanceLevel) {
|
||||
case PDF_A_1A:
|
||||
this.xmpMeta.setProperty("http://www.aiim.org/pdfa/ns/id/", "part", "1");
|
||||
this.xmpMeta.setProperty("http://www.aiim.org/pdfa/ns/id/", "conformance", "A");
|
||||
break;
|
||||
case PDF_A_1B:
|
||||
this.xmpMeta.setProperty("http://www.aiim.org/pdfa/ns/id/", "part", "1");
|
||||
this.xmpMeta.setProperty("http://www.aiim.org/pdfa/ns/id/", "conformance", "B");
|
||||
break;
|
||||
case PDF_A_2A:
|
||||
this.xmpMeta.setProperty("http://www.aiim.org/pdfa/ns/id/", "part", "2");
|
||||
this.xmpMeta.setProperty("http://www.aiim.org/pdfa/ns/id/", "conformance", "A");
|
||||
break;
|
||||
case PDF_A_2B:
|
||||
this.xmpMeta.setProperty("http://www.aiim.org/pdfa/ns/id/", "part", "2");
|
||||
this.xmpMeta.setProperty("http://www.aiim.org/pdfa/ns/id/", "conformance", "B");
|
||||
break;
|
||||
case PDF_A_2U:
|
||||
this.xmpMeta.setProperty("http://www.aiim.org/pdfa/ns/id/", "part", "2");
|
||||
this.xmpMeta.setProperty("http://www.aiim.org/pdfa/ns/id/", "conformance", "U");
|
||||
break;
|
||||
case PDF_A_3A:
|
||||
this.xmpMeta.setProperty("http://www.aiim.org/pdfa/ns/id/", "part", "3");
|
||||
this.xmpMeta.setProperty("http://www.aiim.org/pdfa/ns/id/", "conformance", "A");
|
||||
break;
|
||||
case PDF_A_3B:
|
||||
this.xmpMeta.setProperty("http://www.aiim.org/pdfa/ns/id/", "part", "3");
|
||||
this.xmpMeta.setProperty("http://www.aiim.org/pdfa/ns/id/", "conformance", "B");
|
||||
break;
|
||||
case PDF_A_3U:
|
||||
this.xmpMeta.setProperty("http://www.aiim.org/pdfa/ns/id/", "part", "3");
|
||||
this.xmpMeta.setProperty("http://www.aiim.org/pdfa/ns/id/", "conformance", "U");
|
||||
break;
|
||||
case ZUGFeRD:
|
||||
case ZUGFeRDBasic:
|
||||
case ZUGFeRDComfort:
|
||||
case ZUGFeRDExtended:
|
||||
this.xmpMeta.setProperty("http://www.aiim.org/pdfa/ns/id/", "part", "3");
|
||||
this.xmpMeta.setProperty("http://www.aiim.org/pdfa/ns/id/", "conformance", "B");
|
||||
taggedExtensionMetaComfort = XMPMetaFactory.parseFromString(getZugferdExtension(conformanceLevel));
|
||||
XMPUtils.appendProperties(taggedExtensionMetaComfort, this.xmpMeta, true, false);
|
||||
break;
|
||||
}
|
||||
if (this.writer.isTagged()) {
|
||||
XMPMeta taggedExtensionMeta = XMPMetaFactory.parseFromString(" <x:xmpmeta xmlns:x=\"adobe:ns:meta/\">\n <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n <rdf:Description rdf:about=\"\" xmlns:pdfaExtension=\"http://www.aiim.org/pdfa/ns/extension/\" xmlns:pdfaSchema=\"http://www.aiim.org/pdfa/ns/schema#\" xmlns:pdfaProperty=\"http://www.aiim.org/pdfa/ns/property#\">\n <pdfaExtension:schemas>\n <rdf:Bag>\n <rdf:li rdf:parseType=\"Resource\">\n <pdfaSchema:namespaceURI>http://www.aiim.org/pdfua/ns/id/</pdfaSchema:namespaceURI>\n <pdfaSchema:prefix>pdfuaid</pdfaSchema:prefix>\n <pdfaSchema:schema>PDF/UA identification schema</pdfaSchema:schema>\n <pdfaSchema:property>\n <rdf:Seq>\n <rdf:li rdf:parseType=\"Resource\">\n <pdfaProperty:category>internal</pdfaProperty:category>\n <pdfaProperty:description>PDF/UA version identifier</pdfaProperty:description>\n <pdfaProperty:name>part</pdfaProperty:name>\n <pdfaProperty:valueType>Integer</pdfaProperty:valueType>\n </rdf:li>\n <rdf:li rdf:parseType=\"Resource\">\n <pdfaProperty:category>internal</pdfaProperty:category>\n <pdfaProperty:description>PDF/UA amendment identifier</pdfaProperty:description>\n <pdfaProperty:name>amd</pdfaProperty:name>\n <pdfaProperty:valueType>Text</pdfaProperty:valueType>\n </rdf:li>\n <rdf:li rdf:parseType=\"Resource\">\n <pdfaProperty:category>internal</pdfaProperty:category>\n <pdfaProperty:description>PDF/UA corrigenda identifier</pdfaProperty:description>\n <pdfaProperty:name>corr</pdfaProperty:name>\n <pdfaProperty:valueType>Text</pdfaProperty:valueType>\n </rdf:li>\n </rdf:Seq>\n </pdfaSchema:property>\n </rdf:li>\n </rdf:Bag>\n </pdfaExtension:schemas>\n </rdf:Description>\n </rdf:RDF>\n </x:xmpmeta>");
|
||||
XMPUtils.appendProperties(taggedExtensionMeta, this.xmpMeta, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
private String getZugferdExtension(PdfAConformanceLevel conformanceLevel) {
|
||||
switch (conformanceLevel) {
|
||||
case ZUGFeRD:
|
||||
case ZUGFeRDBasic:
|
||||
return String.format(" <x:xmpmeta xmlns:x=\"adobe:ns:meta/\">\n <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n <rdf:Description rdf:about=\"\" xmlns:zf=\"urn:ferd:pdfa:CrossIndustryDocument:invoice:1p0#\">\n <zf:ConformanceLevel>%s</zf:ConformanceLevel>\n <zf:DocumentFileName>ZUGFeRD-invoice.xml</zf:DocumentFileName>\n <zf:DocumentType>INVOICE</zf:DocumentType>\n <zf:Version>1.0</zf:Version>\n </rdf:Description>\n <rdf:Description rdf:about=\"\" xmlns:pdfaExtension=\"http://www.aiim.org/pdfa/ns/extension/\" xmlns:pdfaSchema=\"http://www.aiim.org/pdfa/ns/schema#\" xmlns:pdfaProperty=\"http://www.aiim.org/pdfa/ns/property#\">\n <pdfaExtension:schemas>\n <rdf:Bag>\n <rdf:li rdf:parseType=\"Resource\">\n <pdfaSchema:schema>ZUGFeRD PDFA Extension Schema</pdfaSchema:schema>\n <pdfaSchema:namespaceURI>urn:ferd:pdfa:CrossIndustryDocument:invoice:1p0#</pdfaSchema:namespaceURI>\n <pdfaSchema:prefix>zf</pdfaSchema:prefix>\n <pdfaSchema:property>\n <rdf:Seq>\n <rdf:li rdf:parseType=\"Resource\">\n <pdfaProperty:name>DocumentFileName</pdfaProperty:name>\n <pdfaProperty:valueType>Text</pdfaProperty:valueType>\n <pdfaProperty:category>external</pdfaProperty:category>\n <pdfaProperty:description>name of the embedded XML invoice file</pdfaProperty:description>\n </rdf:li>\n <rdf:li rdf:parseType=\"Resource\">\n <pdfaProperty:name>DocumentType</pdfaProperty:name>\n <pdfaProperty:valueType>Text</pdfaProperty:valueType>\n <pdfaProperty:category>external</pdfaProperty:category>\n <pdfaProperty:description>INVOICE</pdfaProperty:description>\n </rdf:li>\n <rdf:li rdf:parseType=\"Resource\">\n <pdfaProperty:name>Version</pdfaProperty:name>\n <pdfaProperty:valueType>Text</pdfaProperty:valueType>\n <pdfaProperty:category>external</pdfaProperty:category>\n <pdfaProperty:description>The actual version of the ZUGFeRD data</pdfaProperty:description>\n </rdf:li>\n <rdf:li rdf:parseType=\"Resource\">\n <pdfaProperty:name>ConformanceLevel</pdfaProperty:name>\n <pdfaProperty:valueType>Text</pdfaProperty:valueType>\n <pdfaProperty:category>external</pdfaProperty:category>\n <pdfaProperty:description>The conformance level of the ZUGFeRD data</pdfaProperty:description>\n </rdf:li>\n </rdf:Seq>\n </pdfaSchema:property>\n </rdf:li>\n </rdf:Bag>\n </pdfaExtension:schemas>\n </rdf:Description>\n </rdf:RDF>\n </x:xmpmeta>\n", "BASIC");
|
||||
case ZUGFeRDComfort:
|
||||
return String.format(" <x:xmpmeta xmlns:x=\"adobe:ns:meta/\">\n <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n <rdf:Description rdf:about=\"\" xmlns:zf=\"urn:ferd:pdfa:CrossIndustryDocument:invoice:1p0#\">\n <zf:ConformanceLevel>%s</zf:ConformanceLevel>\n <zf:DocumentFileName>ZUGFeRD-invoice.xml</zf:DocumentFileName>\n <zf:DocumentType>INVOICE</zf:DocumentType>\n <zf:Version>1.0</zf:Version>\n </rdf:Description>\n <rdf:Description rdf:about=\"\" xmlns:pdfaExtension=\"http://www.aiim.org/pdfa/ns/extension/\" xmlns:pdfaSchema=\"http://www.aiim.org/pdfa/ns/schema#\" xmlns:pdfaProperty=\"http://www.aiim.org/pdfa/ns/property#\">\n <pdfaExtension:schemas>\n <rdf:Bag>\n <rdf:li rdf:parseType=\"Resource\">\n <pdfaSchema:schema>ZUGFeRD PDFA Extension Schema</pdfaSchema:schema>\n <pdfaSchema:namespaceURI>urn:ferd:pdfa:CrossIndustryDocument:invoice:1p0#</pdfaSchema:namespaceURI>\n <pdfaSchema:prefix>zf</pdfaSchema:prefix>\n <pdfaSchema:property>\n <rdf:Seq>\n <rdf:li rdf:parseType=\"Resource\">\n <pdfaProperty:name>DocumentFileName</pdfaProperty:name>\n <pdfaProperty:valueType>Text</pdfaProperty:valueType>\n <pdfaProperty:category>external</pdfaProperty:category>\n <pdfaProperty:description>name of the embedded XML invoice file</pdfaProperty:description>\n </rdf:li>\n <rdf:li rdf:parseType=\"Resource\">\n <pdfaProperty:name>DocumentType</pdfaProperty:name>\n <pdfaProperty:valueType>Text</pdfaProperty:valueType>\n <pdfaProperty:category>external</pdfaProperty:category>\n <pdfaProperty:description>INVOICE</pdfaProperty:description>\n </rdf:li>\n <rdf:li rdf:parseType=\"Resource\">\n <pdfaProperty:name>Version</pdfaProperty:name>\n <pdfaProperty:valueType>Text</pdfaProperty:valueType>\n <pdfaProperty:category>external</pdfaProperty:category>\n <pdfaProperty:description>The actual version of the ZUGFeRD data</pdfaProperty:description>\n </rdf:li>\n <rdf:li rdf:parseType=\"Resource\">\n <pdfaProperty:name>ConformanceLevel</pdfaProperty:name>\n <pdfaProperty:valueType>Text</pdfaProperty:valueType>\n <pdfaProperty:category>external</pdfaProperty:category>\n <pdfaProperty:description>The conformance level of the ZUGFeRD data</pdfaProperty:description>\n </rdf:li>\n </rdf:Seq>\n </pdfaSchema:property>\n </rdf:li>\n </rdf:Bag>\n </pdfaExtension:schemas>\n </rdf:Description>\n </rdf:RDF>\n </x:xmpmeta>\n", "COMFORT");
|
||||
case ZUGFeRDExtended:
|
||||
return String.format(" <x:xmpmeta xmlns:x=\"adobe:ns:meta/\">\n <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n <rdf:Description rdf:about=\"\" xmlns:zf=\"urn:ferd:pdfa:CrossIndustryDocument:invoice:1p0#\">\n <zf:ConformanceLevel>%s</zf:ConformanceLevel>\n <zf:DocumentFileName>ZUGFeRD-invoice.xml</zf:DocumentFileName>\n <zf:DocumentType>INVOICE</zf:DocumentType>\n <zf:Version>1.0</zf:Version>\n </rdf:Description>\n <rdf:Description rdf:about=\"\" xmlns:pdfaExtension=\"http://www.aiim.org/pdfa/ns/extension/\" xmlns:pdfaSchema=\"http://www.aiim.org/pdfa/ns/schema#\" xmlns:pdfaProperty=\"http://www.aiim.org/pdfa/ns/property#\">\n <pdfaExtension:schemas>\n <rdf:Bag>\n <rdf:li rdf:parseType=\"Resource\">\n <pdfaSchema:schema>ZUGFeRD PDFA Extension Schema</pdfaSchema:schema>\n <pdfaSchema:namespaceURI>urn:ferd:pdfa:CrossIndustryDocument:invoice:1p0#</pdfaSchema:namespaceURI>\n <pdfaSchema:prefix>zf</pdfaSchema:prefix>\n <pdfaSchema:property>\n <rdf:Seq>\n <rdf:li rdf:parseType=\"Resource\">\n <pdfaProperty:name>DocumentFileName</pdfaProperty:name>\n <pdfaProperty:valueType>Text</pdfaProperty:valueType>\n <pdfaProperty:category>external</pdfaProperty:category>\n <pdfaProperty:description>name of the embedded XML invoice file</pdfaProperty:description>\n </rdf:li>\n <rdf:li rdf:parseType=\"Resource\">\n <pdfaProperty:name>DocumentType</pdfaProperty:name>\n <pdfaProperty:valueType>Text</pdfaProperty:valueType>\n <pdfaProperty:category>external</pdfaProperty:category>\n <pdfaProperty:description>INVOICE</pdfaProperty:description>\n </rdf:li>\n <rdf:li rdf:parseType=\"Resource\">\n <pdfaProperty:name>Version</pdfaProperty:name>\n <pdfaProperty:valueType>Text</pdfaProperty:valueType>\n <pdfaProperty:category>external</pdfaProperty:category>\n <pdfaProperty:description>The actual version of the ZUGFeRD data</pdfaProperty:description>\n </rdf:li>\n <rdf:li rdf:parseType=\"Resource\">\n <pdfaProperty:name>ConformanceLevel</pdfaProperty:name>\n <pdfaProperty:valueType>Text</pdfaProperty:valueType>\n <pdfaProperty:category>external</pdfaProperty:category>\n <pdfaProperty:description>The conformance level of the ZUGFeRD data</pdfaProperty:description>\n </rdf:li>\n </rdf:Seq>\n </pdfaSchema:property>\n </rdf:li>\n </rdf:Bag>\n </pdfaExtension:schemas>\n </rdf:Description>\n </rdf:RDF>\n </x:xmpmeta>\n", "EXTENDED");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,664 @@
|
|||
package com.itextpdf.text.zugferd;
|
||||
|
||||
import com.itextpdf.text.io.StreamUtil;
|
||||
import com.itextpdf.text.zugferd.checkers.NumberChecker;
|
||||
import com.itextpdf.text.zugferd.checkers.basic.CountryCode;
|
||||
import com.itextpdf.text.zugferd.checkers.basic.CurrencyCode;
|
||||
import com.itextpdf.text.zugferd.checkers.basic.DateFormatCode;
|
||||
import com.itextpdf.text.zugferd.checkers.basic.DocumentTypeCode;
|
||||
import com.itextpdf.text.zugferd.checkers.basic.MeasurementUnitCode;
|
||||
import com.itextpdf.text.zugferd.checkers.basic.TaxIDTypeCode;
|
||||
import com.itextpdf.text.zugferd.checkers.basic.TaxTypeCode;
|
||||
import com.itextpdf.text.zugferd.checkers.comfort.FreeTextSubjectCode;
|
||||
import com.itextpdf.text.zugferd.checkers.comfort.GlobalIdentifierCode;
|
||||
import com.itextpdf.text.zugferd.checkers.comfort.PaymentMeansCode;
|
||||
import com.itextpdf.text.zugferd.checkers.comfort.TaxCategoryCode;
|
||||
import com.itextpdf.text.zugferd.exceptions.DataIncompleteException;
|
||||
import com.itextpdf.text.zugferd.exceptions.InvalidCodeException;
|
||||
import com.itextpdf.text.zugferd.profiles.BasicProfile;
|
||||
import com.itextpdf.text.zugferd.profiles.ComfortProfile;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Date;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.transform.Result;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
public class InvoiceDOM {
|
||||
public static final CountryCode COUNTRY_CODE = new CountryCode();
|
||||
|
||||
public static final CurrencyCode CURR_CODE = new CurrencyCode();
|
||||
|
||||
public static final DateFormatCode DF_CODE = new DateFormatCode();
|
||||
|
||||
public static final GlobalIdentifierCode GI_CODE = new GlobalIdentifierCode();
|
||||
|
||||
public static final MeasurementUnitCode M_UNIT_CODE = new MeasurementUnitCode();
|
||||
|
||||
public static final NumberChecker DEC2 = new NumberChecker(2);
|
||||
|
||||
public static final NumberChecker DEC4 = new NumberChecker(4);
|
||||
|
||||
public static final PaymentMeansCode PM_CODE = new PaymentMeansCode();
|
||||
|
||||
public static final TaxCategoryCode TC_CODE = new TaxCategoryCode();
|
||||
|
||||
public static final TaxIDTypeCode TIDT_CODE = new TaxIDTypeCode();
|
||||
|
||||
public static final TaxTypeCode TT_CODE = new TaxTypeCode();
|
||||
|
||||
protected final Document doc;
|
||||
|
||||
public InvoiceDOM(BasicProfile data) throws ParserConfigurationException, SAXException, IOException, DataIncompleteException, InvalidCodeException {
|
||||
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
|
||||
InputStream is = StreamUtil.getResourceStream("com/itextpdf/text/zugferd/zugferd-template.xml");
|
||||
this.doc = docBuilder.parse(is);
|
||||
importData(this.doc, data);
|
||||
}
|
||||
|
||||
private void importData(Document doc, BasicProfile data) throws DataIncompleteException, InvalidCodeException {
|
||||
if (!data.getTestIndicator())
|
||||
throw new InvalidCodeException("false", "the test indicator: the ZUGFeRD functionality is still in beta; contact sales@itextpdf.com for more info.");
|
||||
importSpecifiedExchangedDocumentContext((Element)
|
||||
doc.getElementsByTagName("rsm:SpecifiedExchangedDocumentContext").item(0), data);
|
||||
importHeaderExchangedDocument((Element)
|
||||
doc.getElementsByTagName("rsm:HeaderExchangedDocument").item(0), data);
|
||||
importSpecifiedSupplyChainTradeTransaction((Element)
|
||||
doc.getElementsByTagName("rsm:SpecifiedSupplyChainTradeTransaction").item(0), data);
|
||||
}
|
||||
|
||||
protected void importSpecifiedExchangedDocumentContext(Element element, BasicProfile data) {
|
||||
importContent(element, "udt:Indicator", data.getTestIndicator() ? "true" : "false");
|
||||
}
|
||||
|
||||
protected void importHeaderExchangedDocument(Element element, BasicProfile data) throws DataIncompleteException, InvalidCodeException {
|
||||
check(data.getId(), "HeaderExchangedDocument > ID");
|
||||
importContent(element, "ram:ID", data.getId());
|
||||
check(data.getName(), "HeaderExchangedDocument > Name");
|
||||
importContent(element, "ram:Name", data.getName());
|
||||
DocumentTypeCode dtCode = new DocumentTypeCode((data instanceof ComfortProfile) ? 1 : 0);
|
||||
importContent(element, "ram:TypeCode", dtCode.check(data.getTypeCode()));
|
||||
check(data.getDateTimeFormat(), "HeaderExchangedDocument > DateTimeString");
|
||||
importDateTime(element, "udt:DateTimeString", data.getDateTimeFormat(), data.getDateTime());
|
||||
String[][] notes = data.getNotes();
|
||||
String[] notesCodes = null;
|
||||
if (data instanceof ComfortProfile)
|
||||
notesCodes = ((ComfortProfile)data).getNotesCodes();
|
||||
importIncludedNotes(element, 1, notes, notesCodes);
|
||||
}
|
||||
|
||||
protected void importContent(Element parent, String tag, String content, String... attributes) {
|
||||
Node node = parent.getElementsByTagName(tag).item(0);
|
||||
node.setTextContent(content);
|
||||
if (attributes == null || attributes.length == 0)
|
||||
return;
|
||||
int n = attributes.length;
|
||||
NamedNodeMap attrs = node.getAttributes();
|
||||
for (int i = 0; i < n; i++) {
|
||||
String attrName = attributes[i];
|
||||
if (++i != n) {
|
||||
String attrValue = attributes[i];
|
||||
Node attr = attrs.getNamedItem(attrName);
|
||||
if (attr != null)
|
||||
attr.setTextContent(attrValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void importDateTime(Element parent, String tag, String dateTimeFormat, Date dateTime) throws InvalidCodeException {
|
||||
if (dateTimeFormat == null)
|
||||
return;
|
||||
importContent(parent, tag, DF_CODE.convertToString(dateTime, DF_CODE.check(dateTimeFormat)), "format", dateTimeFormat);
|
||||
}
|
||||
|
||||
protected void importIncludedNotes(Element parent, int level, String[][] notes, String[] notesCodes) throws DataIncompleteException, InvalidCodeException {
|
||||
if (notes == null)
|
||||
return;
|
||||
Node includedNoteNode = parent.getElementsByTagName("ram:IncludedNote").item(0);
|
||||
int n = notes.length;
|
||||
FreeTextSubjectCode ftsCode = new FreeTextSubjectCode(level);
|
||||
if (notesCodes != null && n != notesCodes.length)
|
||||
throw new DataIncompleteException("Number of included notes is not equal to number of codes for included notes.");
|
||||
for (int i = 0; i < n; i++) {
|
||||
Element noteNode = (Element)includedNoteNode.cloneNode(true);
|
||||
Node content = noteNode.getElementsByTagName("ram:Content").item(0);
|
||||
for (String note : notes[i]) {
|
||||
Node newNode = content.cloneNode(true);
|
||||
newNode.setTextContent(note);
|
||||
noteNode.insertBefore(newNode, content);
|
||||
}
|
||||
if (notesCodes != null) {
|
||||
Node code = noteNode.getElementsByTagName("ram:SubjectCode").item(0);
|
||||
code.setTextContent(ftsCode.check(notesCodes[i]));
|
||||
}
|
||||
parent.insertBefore(noteNode, includedNoteNode);
|
||||
}
|
||||
}
|
||||
|
||||
protected void importSpecifiedSupplyChainTradeTransaction(Element element, BasicProfile data) throws DataIncompleteException, InvalidCodeException {
|
||||
ComfortProfile comfortData = null;
|
||||
if (data instanceof ComfortProfile)
|
||||
comfortData = (ComfortProfile)data;
|
||||
if (comfortData != null) {
|
||||
String buyerReference = comfortData.getBuyerReference();
|
||||
importContent(element, "ram:BuyerReference", buyerReference);
|
||||
}
|
||||
check(data.getSellerName(), "SpecifiedSupplyChainTradeTransaction > ApplicableSupplyChainTradeAgreement > SellerTradeParty > Name");
|
||||
importSellerTradeParty(element, data);
|
||||
check(data.getBuyerName(), "SpecifiedSupplyChainTradeTransaction > ApplicableSupplyChainTradeAgreement > BuyerTradeParty > Name");
|
||||
importBuyerTradeParty(element, data);
|
||||
if (comfortData != null) {
|
||||
Element document = (Element)element.getElementsByTagName("ram:BuyerOrderReferencedDocument").item(0);
|
||||
importDateTime(document, "ram:IssueDateTime", comfortData.getBuyerOrderReferencedDocumentIssueDateTimeFormat(), comfortData.getBuyerOrderReferencedDocumentIssueDateTime());
|
||||
importContent(document, "ram:ID", comfortData.getBuyerOrderReferencedDocumentID());
|
||||
document = (Element)element.getElementsByTagName("ram:ContractReferencedDocument").item(0);
|
||||
importDateTime(document, "ram:IssueDateTime", comfortData.getContractReferencedDocumentIssueDateTimeFormat(), comfortData.getContractReferencedDocumentIssueDateTime());
|
||||
importContent(document, "ram:ID", comfortData.getContractReferencedDocumentID());
|
||||
document = (Element)element.getElementsByTagName("ram:CustomerOrderReferencedDocument").item(0);
|
||||
importDateTime(document, "ram:IssueDateTime", comfortData.getCustomerOrderReferencedDocumentIssueDateTimeFormat(), comfortData.getCustomerOrderReferencedDocumentIssueDateTime());
|
||||
importContent(document, "ram:ID", comfortData.getCustomerOrderReferencedDocumentID());
|
||||
}
|
||||
Element parent = (Element)element.getElementsByTagName("ram:ActualDeliverySupplyChainEvent").item(0);
|
||||
importDateTime(parent, "udt:DateTimeString", data.getDeliveryDateTimeFormat(), data.getDeliveryDateTime());
|
||||
if (comfortData != null) {
|
||||
Element document = (Element)element.getElementsByTagName("ram:DeliveryNoteReferencedDocument").item(0);
|
||||
importDateTime(document, "ram:IssueDateTime", comfortData.getDeliveryNoteReferencedDocumentIssueDateTimeFormat(), comfortData.getDeliveryNoteReferencedDocumentIssueDateTime());
|
||||
importContent(document, "ram:ID", comfortData.getDeliveryNoteReferencedDocumentID());
|
||||
}
|
||||
importContent(element, "ram:PaymentReference", data.getPaymentReference());
|
||||
importContent(element, "ram:InvoiceCurrencyCode", CURR_CODE.check(data.getInvoiceCurrencyCode()));
|
||||
if (comfortData != null)
|
||||
importInvoiceeTradeParty(element, comfortData);
|
||||
parent = (Element)element.getElementsByTagName("ram:ApplicableSupplyChainTradeSettlement").item(0);
|
||||
importPaymentMeans(parent, data);
|
||||
importTax(parent, data);
|
||||
if (comfortData != null) {
|
||||
Element period = (Element)element.getElementsByTagName("ram:BillingSpecifiedPeriod").item(0);
|
||||
Element start = (Element)period.getElementsByTagName("ram:StartDateTime").item(0);
|
||||
importDateTime(start, "udt:DateTimeString", comfortData.getBillingStartDateTimeFormat(), comfortData.getBillingStartDateTime());
|
||||
Element end = (Element)period.getElementsByTagName("ram:EndDateTime").item(0);
|
||||
importDateTime(end, "udt:DateTimeString", comfortData.getBillingEndDateTimeFormat(), comfortData.getBillingEndDateTime());
|
||||
importSpecifiedTradeAllowanceCharge(parent, comfortData);
|
||||
importSpecifiedLogisticsServiceCharge(parent, comfortData);
|
||||
importSpecifiedTradePaymentTerms(parent, comfortData);
|
||||
}
|
||||
check(DEC2.check(data.getLineTotalAmount()), "SpecifiedTradeSettlementMonetarySummation > LineTotalAmount");
|
||||
check(CURR_CODE.check(data.getLineTotalAmountCurrencyID()), "SpecifiedTradeSettlementMonetarySummation > LineTotalAmount . currencyID");
|
||||
importContent(element, "ram:LineTotalAmount", data.getLineTotalAmount(), "currencyID", data.getLineTotalAmountCurrencyID());
|
||||
check(DEC2.check(data.getChargeTotalAmount()), "SpecifiedTradeSettlementMonetarySummation > ChargeTotalAmount");
|
||||
check(CURR_CODE.check(data.getChargeTotalAmountCurrencyID()), "SpecifiedTradeSettlementMonetarySummation > ChargeTotalAmount . currencyID");
|
||||
importContent(element, "ram:ChargeTotalAmount", data.getChargeTotalAmount(), "currencyID", data.getChargeTotalAmountCurrencyID());
|
||||
check(DEC2.check(data.getAllowanceTotalAmount()), "SpecifiedTradeSettlementMonetarySummation > AllowanceTotalAmount");
|
||||
check(CURR_CODE.check(data.getAllowanceTotalAmountCurrencyID()), "SpecifiedTradeSettlementMonetarySummation > AllowanceTotalAmount . currencyID");
|
||||
importContent(element, "ram:AllowanceTotalAmount", data.getAllowanceTotalAmount(), "currencyID", data.getAllowanceTotalAmountCurrencyID());
|
||||
check(DEC2.check(data.getTaxBasisTotalAmount()), "SpecifiedTradeSettlementMonetarySummation > TaxBasisTotalAmount");
|
||||
check(CURR_CODE.check(data.getTaxBasisTotalAmountCurrencyID()), "SpecifiedTradeSettlementMonetarySummation > TaxBasisTotalAmount . currencyID");
|
||||
importContent(element, "ram:TaxBasisTotalAmount", data.getTaxBasisTotalAmount(), "currencyID", data.getTaxBasisTotalAmountCurrencyID());
|
||||
check(DEC2.check(data.getTaxTotalAmount()), "SpecifiedTradeSettlementMonetarySummation > TaxTotalAmount");
|
||||
check(CURR_CODE.check(data.getTaxTotalAmountCurrencyID()), "SpecifiedTradeSettlementMonetarySummation > TaxTotalAmount . currencyID");
|
||||
importContent(element, "ram:TaxTotalAmount", data.getTaxTotalAmount(), "currencyID", data.getTaxTotalAmountCurrencyID());
|
||||
check(DEC2.check(data.getGrandTotalAmount()), "SpecifiedTradeSettlementMonetarySummation > GrandTotalAmount");
|
||||
check(CURR_CODE.check(data.getGrandTotalAmountCurrencyID()), "SpecifiedTradeSettlementMonetarySummation > GrandTotalAmount . currencyID");
|
||||
importContent(element, "ram:GrandTotalAmount", data.getGrandTotalAmount(), "currencyID", data.getGrandTotalAmountCurrencyID());
|
||||
if (comfortData != null) {
|
||||
importContent(element, "ram:TotalPrepaidAmount", comfortData.getTotalPrepaidAmount(), "currencyID", comfortData.getTotalPrepaidAmountCurrencyID());
|
||||
importContent(element, "ram:DuePayableAmount", comfortData.getDuePayableAmount(), "currencyID", comfortData.getDuePayableAmountCurrencyID());
|
||||
}
|
||||
if (comfortData != null) {
|
||||
importLineItemsComfort(element, comfortData);
|
||||
} else {
|
||||
importLineItemsBasic(element, data);
|
||||
}
|
||||
}
|
||||
|
||||
protected void importSellerTradeParty(Element parent, BasicProfile data) throws DataIncompleteException, InvalidCodeException {
|
||||
String id = null;
|
||||
String[] globalID = null;
|
||||
String[] globalIDScheme = null;
|
||||
if (data instanceof ComfortProfile) {
|
||||
id = ((ComfortProfile)data).getSellerID();
|
||||
globalID = ((ComfortProfile)data).getSellerGlobalID();
|
||||
globalIDScheme = ((ComfortProfile)data).getSellerGlobalSchemeID();
|
||||
}
|
||||
String name = data.getSellerName();
|
||||
String postcode = data.getSellerPostcode();
|
||||
String lineOne = data.getSellerLineOne();
|
||||
String lineTwo = data.getSellerLineTwo();
|
||||
String cityName = data.getSellerCityName();
|
||||
String countryID = data.getSellerCountryID();
|
||||
String[] taxRegistrationID = data.getSellerTaxRegistrationID();
|
||||
String[] taxRegistrationSchemeID = data.getSellerTaxRegistrationSchemeID();
|
||||
importTradeParty((Element)
|
||||
parent.getElementsByTagName("ram:SellerTradeParty").item(0), id, globalID, globalIDScheme, name, postcode, lineOne, lineTwo, cityName, countryID, taxRegistrationID, taxRegistrationSchemeID);
|
||||
}
|
||||
|
||||
protected void importBuyerTradeParty(Element parent, BasicProfile data) throws DataIncompleteException, InvalidCodeException {
|
||||
String id = null;
|
||||
String[] globalID = null;
|
||||
String[] globalIDScheme = null;
|
||||
if (data instanceof ComfortProfile) {
|
||||
id = ((ComfortProfile)data).getBuyerID();
|
||||
globalID = ((ComfortProfile)data).getBuyerGlobalID();
|
||||
globalIDScheme = ((ComfortProfile)data).getBuyerGlobalSchemeID();
|
||||
}
|
||||
String name = data.getBuyerName();
|
||||
String postcode = data.getBuyerPostcode();
|
||||
String lineOne = data.getBuyerLineOne();
|
||||
String lineTwo = data.getBuyerLineTwo();
|
||||
String cityName = data.getBuyerCityName();
|
||||
String countryID = data.getBuyerCountryID();
|
||||
String[] taxRegistrationID = data.getBuyerTaxRegistrationID();
|
||||
String[] taxRegistrationSchemeID = data.getBuyerTaxRegistrationSchemeID();
|
||||
importTradeParty((Element)
|
||||
parent.getElementsByTagName("ram:BuyerTradeParty").item(0), id, globalID, globalIDScheme, name, postcode, lineOne, lineTwo, cityName, countryID, taxRegistrationID, taxRegistrationSchemeID);
|
||||
}
|
||||
|
||||
protected void importInvoiceeTradeParty(Element parent, ComfortProfile data) throws DataIncompleteException, InvalidCodeException {
|
||||
String name = data.getInvoiceeName();
|
||||
if (name == null)
|
||||
return;
|
||||
String id = data.getInvoiceeID();
|
||||
String[] globalID = data.getInvoiceeGlobalID();
|
||||
String[] globalIDScheme = data.getInvoiceeGlobalSchemeID();
|
||||
String postcode = data.getInvoiceePostcode();
|
||||
String lineOne = data.getInvoiceeLineOne();
|
||||
String lineTwo = data.getInvoiceeLineTwo();
|
||||
String cityName = data.getInvoiceeCityName();
|
||||
String countryID = data.getInvoiceeCountryID();
|
||||
String[] taxRegistrationID = data.getInvoiceeTaxRegistrationID();
|
||||
String[] taxRegistrationSchemeID = data.getInvoiceeTaxRegistrationSchemeID();
|
||||
importTradeParty((Element)
|
||||
parent.getElementsByTagName("ram:InvoiceeTradeParty").item(0), id, globalID, globalIDScheme, name, postcode, lineOne, lineTwo, cityName, countryID, taxRegistrationID, taxRegistrationSchemeID);
|
||||
}
|
||||
|
||||
protected void importTradeParty(Element parent, String id, String[] globalID, String[] globalIDScheme, String name, String postcode, String lineOne, String lineTwo, String cityName, String countryID, String[] taxRegistrationID, String[] taxRegistrationSchemeID) throws DataIncompleteException, InvalidCodeException {
|
||||
if (id != null) {
|
||||
Node node1 = parent.getElementsByTagName("ram:ID").item(0);
|
||||
node1.setTextContent(id);
|
||||
}
|
||||
if (globalID != null) {
|
||||
int j = globalID.length;
|
||||
if (globalIDScheme == null || globalIDScheme.length != j)
|
||||
throw new DataIncompleteException("Number of global ID schemes is not equal to number of global IDs.");
|
||||
Node node1 = parent.getElementsByTagName("ram:GlobalID").item(0);
|
||||
for (int k = 0; k < j; k++) {
|
||||
Element idNode = (Element)node1.cloneNode(true);
|
||||
NamedNodeMap attrs = idNode.getAttributes();
|
||||
idNode.setTextContent(globalID[k]);
|
||||
Node schemeID = attrs.getNamedItem("schemeID");
|
||||
schemeID.setTextContent(GI_CODE.check(globalIDScheme[k]));
|
||||
parent.insertBefore(idNode, node1);
|
||||
}
|
||||
}
|
||||
importContent(parent, "ram:Name", name);
|
||||
importContent(parent, "ram:PostcodeCode", postcode);
|
||||
importContent(parent, "ram:LineOne", lineOne);
|
||||
importContent(parent, "ram:LineTwo", lineTwo);
|
||||
importContent(parent, "ram:CityName", cityName);
|
||||
if (countryID != null)
|
||||
importContent(parent, "ram:CountryID", COUNTRY_CODE.check(countryID));
|
||||
int n = taxRegistrationID.length;
|
||||
if (taxRegistrationSchemeID != null && taxRegistrationSchemeID.length != n)
|
||||
throw new DataIncompleteException("Number of tax ID schemes is not equal to number of tax IDs.");
|
||||
Element tax = (Element)parent.getElementsByTagName("ram:SpecifiedTaxRegistration").item(0);
|
||||
Node node = tax.getElementsByTagName("ram:ID").item(0);
|
||||
for (int i = 0; i < n; i++) {
|
||||
Element idNode = (Element)node.cloneNode(true);
|
||||
idNode.setTextContent(taxRegistrationID[i]);
|
||||
NamedNodeMap attrs = idNode.getAttributes();
|
||||
Node schemeID = attrs.getNamedItem("schemeID");
|
||||
schemeID.setTextContent(TIDT_CODE.check(taxRegistrationSchemeID[i]));
|
||||
tax.insertBefore(idNode, node);
|
||||
}
|
||||
}
|
||||
|
||||
protected void importPaymentMeans(Element parent, BasicProfile data) throws InvalidCodeException {
|
||||
String[] pmID = data.getPaymentMeansID();
|
||||
int n = pmID.length;
|
||||
String[] pmTypeCode = new String[n];
|
||||
String[][] pmInformation = new String[n][];
|
||||
String[] pmSchemeAgencyID = data.getPaymentMeansSchemeAgencyID();
|
||||
String[] pmPayerIBAN = new String[n];
|
||||
String[] pmPayerProprietaryID = new String[n];
|
||||
String[] pmIBAN = data.getPaymentMeansPayeeAccountIBAN();
|
||||
String[] pmAccountName = data.getPaymentMeansPayeeAccountAccountName();
|
||||
String[] pmAccountID = data.getPaymentMeansPayeeAccountProprietaryID();
|
||||
String[] pmPayerBIC = new String[n];
|
||||
String[] pmPayerGermanBankleitzahlID = new String[n];
|
||||
String[] pmPayerFinancialInst = new String[n];
|
||||
String[] pmBIC = data.getPaymentMeansPayeeFinancialInstitutionBIC();
|
||||
String[] pmGermanBankleitzahlID = data.getPaymentMeansPayeeFinancialInstitutionGermanBankleitzahlID();
|
||||
String[] pmFinancialInst = data.getPaymentMeansPayeeFinancialInstitutionName();
|
||||
if (data instanceof ComfortProfile) {
|
||||
ComfortProfile comfortData = (ComfortProfile)data;
|
||||
pmTypeCode = comfortData.getPaymentMeansTypeCode();
|
||||
pmInformation = comfortData.getPaymentMeansInformation();
|
||||
pmPayerIBAN = comfortData.getPaymentMeansPayerAccountIBAN();
|
||||
pmPayerProprietaryID = comfortData.getPaymentMeansPayerAccountProprietaryID();
|
||||
pmPayerBIC = comfortData.getPaymentMeansPayerFinancialInstitutionBIC();
|
||||
pmPayerGermanBankleitzahlID = comfortData.getPaymentMeansPayerFinancialInstitutionGermanBankleitzahlID();
|
||||
pmPayerFinancialInst = comfortData.getPaymentMeansPayerFinancialInstitutionName();
|
||||
}
|
||||
Node node = parent.getElementsByTagName("ram:SpecifiedTradeSettlementPaymentMeans").item(0);
|
||||
for (int i = 0; i < pmID.length; i++) {
|
||||
Node newNode = node.cloneNode(true);
|
||||
importPaymentMeans((Element)newNode, pmTypeCode[i], pmInformation[i], pmID[i], pmSchemeAgencyID[i], pmPayerIBAN[i], pmPayerProprietaryID[i], pmIBAN[i], pmAccountName[i], pmAccountID[i], pmPayerBIC[i], pmPayerGermanBankleitzahlID[i], pmPayerFinancialInst[i], pmBIC[i], pmGermanBankleitzahlID[i], pmFinancialInst[i]);
|
||||
parent.insertBefore(newNode, node);
|
||||
}
|
||||
}
|
||||
|
||||
protected void importPaymentMeans(Element parent, String typeCode, String[] information, String id, String scheme, String payerIban, String payerProprietaryID, String iban, String accName, String accID, String payerBic, String payerBank, String payerInst, String bic, String bank, String inst) throws InvalidCodeException {
|
||||
if (typeCode != null)
|
||||
importContent(parent, "ram:TypeCode", PM_CODE.check(typeCode));
|
||||
if (information != null) {
|
||||
Node node = parent.getElementsByTagName("ram:Information").item(0);
|
||||
for (String info : information) {
|
||||
Node newNode = node.cloneNode(true);
|
||||
newNode.setTextContent(info);
|
||||
parent.insertBefore(newNode, node);
|
||||
}
|
||||
}
|
||||
importContent(parent, "ram:ID", id, "schemeAgencyID", scheme);
|
||||
Element payer = (Element)parent.getElementsByTagName("ram:PayerPartyDebtorFinancialAccount").item(0);
|
||||
importContent(payer, "ram:IBANID", payerIban);
|
||||
importContent(payer, "ram:ProprietaryID", payerProprietaryID);
|
||||
Element payee = (Element)parent.getElementsByTagName("ram:PayeePartyCreditorFinancialAccount").item(0);
|
||||
importContent(payee, "ram:IBANID", iban);
|
||||
importContent(payee, "ram:AccountName", accName);
|
||||
importContent(payee, "ram:ProprietaryID", accID);
|
||||
payer = (Element)parent.getElementsByTagName("ram:PayerSpecifiedDebtorFinancialInstitution").item(0);
|
||||
importContent(payer, "ram:BICID", payerBic);
|
||||
importContent(payer, "ram:GermanBankleitzahlID", payerBank);
|
||||
importContent(payer, "ram:Name", payerInst);
|
||||
payee = (Element)parent.getElementsByTagName("ram:PayeeSpecifiedCreditorFinancialInstitution").item(0);
|
||||
importContent(payee, "ram:BICID", bic);
|
||||
importContent(payee, "ram:GermanBankleitzahlID", bank);
|
||||
importContent(payee, "ram:Name", inst);
|
||||
}
|
||||
|
||||
protected void importTax(Element parent, BasicProfile data) throws InvalidCodeException, DataIncompleteException {
|
||||
String[] calculated = data.getTaxCalculatedAmount();
|
||||
int n = calculated.length;
|
||||
String[] calculatedCurr = data.getTaxCalculatedAmountCurrencyID();
|
||||
String[] typeCode = data.getTaxTypeCode();
|
||||
String[] exemptionReason = new String[n];
|
||||
String[] basisAmount = data.getTaxBasisAmount();
|
||||
String[] basisAmountCurr = data.getTaxBasisAmountCurrencyID();
|
||||
String[] category = new String[n];
|
||||
String[] percent = data.getTaxApplicablePercent();
|
||||
if (data instanceof ComfortProfile) {
|
||||
ComfortProfile comfortData = (ComfortProfile)data;
|
||||
exemptionReason = comfortData.getTaxExemptionReason();
|
||||
category = comfortData.getTaxCategoryCode();
|
||||
}
|
||||
Node node = parent.getElementsByTagName("ram:ApplicableTradeTax").item(0);
|
||||
for (int i = 0; i < n; i++) {
|
||||
Node newNode = node.cloneNode(true);
|
||||
importTax((Element)newNode, calculated[i], calculatedCurr[i], typeCode[i], exemptionReason[i], basisAmount[i], basisAmountCurr[i], category[i], percent[i]);
|
||||
parent.insertBefore(newNode, node);
|
||||
}
|
||||
}
|
||||
|
||||
protected void importTax(Element parent, String calculatedAmount, String currencyID, String typeCode, String exemptionReason, String basisAmount, String basisAmountCurr, String category, String percent) throws InvalidCodeException, DataIncompleteException {
|
||||
check(CURR_CODE.check(currencyID), "ApplicableTradeTax > CalculatedAmount > CurrencyID");
|
||||
importContent(parent, "ram:CalculatedAmount", DEC2.check(calculatedAmount), "currencyID", currencyID);
|
||||
check(typeCode, "ApplicableTradeTax > TypeCode");
|
||||
importContent(parent, "ram:TypeCode", TT_CODE.check(typeCode));
|
||||
importContent(parent, "ram:ExemptionReason", exemptionReason);
|
||||
check(CURR_CODE.check(basisAmountCurr), "ApplicableTradeTax > BasisAmount > CurrencyID");
|
||||
importContent(parent, "ram:BasisAmount", DEC2.check(basisAmount), "currencyID", basisAmountCurr);
|
||||
if (category != null)
|
||||
importContent(parent, "ram:CategoryCode", TC_CODE.check(category));
|
||||
importContent(parent, "ram:ApplicablePercent", DEC2.check(percent));
|
||||
}
|
||||
|
||||
protected void importSpecifiedTradeAllowanceCharge(Element parent, ComfortProfile data) throws InvalidCodeException {
|
||||
Boolean[] indicator = data.getSpecifiedTradeAllowanceChargeIndicator();
|
||||
String[] actualAmount = data.getSpecifiedTradeAllowanceChargeActualAmount();
|
||||
String[] actualAmountCurr = data.getSpecifiedTradeAllowanceChargeActualAmountCurrency();
|
||||
String[] reason = data.getSpecifiedTradeAllowanceChargeReason();
|
||||
String[][] typeCode = data.getSpecifiedTradeAllowanceChargeTaxTypeCode();
|
||||
String[][] categoryCode = data.getSpecifiedTradeAllowanceChargeTaxCategoryCode();
|
||||
String[][] percent = data.getSpecifiedTradeAllowanceChargeTaxApplicablePercent();
|
||||
Node node = parent.getElementsByTagName("ram:SpecifiedTradeAllowanceCharge").item(0);
|
||||
for (int i = 0; i < indicator.length; i++) {
|
||||
Node newNode = node.cloneNode(true);
|
||||
importSpecifiedTradeAllowanceCharge((Element)newNode, indicator[i].booleanValue(), actualAmount[i], actualAmountCurr[i], reason[i], typeCode[i], categoryCode[i], percent[i]);
|
||||
parent.insertBefore(newNode, node);
|
||||
}
|
||||
}
|
||||
|
||||
protected void importSpecifiedTradeAllowanceCharge(Element parent, boolean indicator, String actualAmount, String actualAmountCurrency, String reason, String[] typeCode, String[] categoryCode, String[] percent) throws InvalidCodeException {
|
||||
importContent(parent, "udt:Indicator", indicator ? "true" : "false");
|
||||
importContent(parent, "ram:ActualAmount", DEC4.check(actualAmount), "currencyID", CURR_CODE.check(actualAmountCurrency));
|
||||
importContent(parent, "ram:Reason", reason);
|
||||
Node node = parent.getElementsByTagName("ram:CategoryTradeTax").item(0);
|
||||
for (int i = 0; i < typeCode.length; i++) {
|
||||
Element newNode = (Element)node.cloneNode(true);
|
||||
importContent(newNode, "ram:TypeCode", TT_CODE.check(typeCode[i]));
|
||||
importContent(newNode, "ram:CategoryCode", TC_CODE.check(categoryCode[i]));
|
||||
importContent(newNode, "ram:ApplicablePercent", DEC2.check(percent[i]));
|
||||
parent.insertBefore(newNode, node);
|
||||
}
|
||||
}
|
||||
|
||||
protected void importSpecifiedLogisticsServiceCharge(Element parent, ComfortProfile data) throws InvalidCodeException {
|
||||
String[][] description = data.getSpecifiedLogisticsServiceChargeDescription();
|
||||
String[] appliedAmount = data.getSpecifiedLogisticsServiceChargeAmount();
|
||||
String[] appliedAmountCurr = data.getSpecifiedLogisticsServiceChargeAmountCurrency();
|
||||
String[][] typeCode = data.getSpecifiedLogisticsServiceChargeTaxTypeCode();
|
||||
String[][] categoryCode = data.getSpecifiedLogisticsServiceChargeTaxCategoryCode();
|
||||
String[][] percent = data.getSpecifiedLogisticsServiceChargeTaxApplicablePercent();
|
||||
Node node = parent.getElementsByTagName("ram:SpecifiedLogisticsServiceCharge").item(0);
|
||||
for (int i = 0; i < appliedAmount.length; i++) {
|
||||
Node newNode = node.cloneNode(true);
|
||||
importSpecifiedLogisticsServiceCharge((Element)newNode, description[i], appliedAmount[i], appliedAmountCurr[i], typeCode[i], categoryCode[i], percent[i]);
|
||||
parent.insertBefore(newNode, node);
|
||||
}
|
||||
}
|
||||
|
||||
protected void importSpecifiedLogisticsServiceCharge(Element parent, String[] description, String appliedAmount, String currencyID, String[] typeCode, String[] categoryCode, String[] percent) throws InvalidCodeException {
|
||||
Node node = parent.getElementsByTagName("ram:Description").item(0);
|
||||
for (String d : description) {
|
||||
Node newNode = node.cloneNode(true);
|
||||
newNode.setTextContent(d);
|
||||
parent.insertBefore(newNode, node);
|
||||
}
|
||||
importContent(parent, "ram:AppliedAmount", DEC4.check(appliedAmount), "currencyID", CURR_CODE.check(currencyID));
|
||||
node = parent.getElementsByTagName("ram:AppliedTradeTax").item(0);
|
||||
for (int i = 0; i < typeCode.length; i++) {
|
||||
Element newNode = (Element)node.cloneNode(true);
|
||||
importContent(newNode, "ram:TypeCode", TT_CODE.check(typeCode[i]));
|
||||
importContent(newNode, "ram:CategoryCode", TC_CODE.check(categoryCode[i]));
|
||||
importContent(newNode, "ram:ApplicablePercent", DEC2.check(percent[i]));
|
||||
parent.insertBefore(newNode, node);
|
||||
}
|
||||
}
|
||||
|
||||
protected void importSpecifiedTradePaymentTerms(Element parent, ComfortProfile data) throws InvalidCodeException {
|
||||
String[][] description = data.getSpecifiedTradePaymentTermsDescription();
|
||||
Date[] dateTime = data.getSpecifiedTradePaymentTermsDueDateTime();
|
||||
String[] dateTimeFormat = data.getSpecifiedTradePaymentTermsDueDateTimeFormat();
|
||||
Node node = parent.getElementsByTagName("ram:SpecifiedTradePaymentTerms").item(0);
|
||||
for (int i = 0; i < description.length; i++) {
|
||||
Node newNode = node.cloneNode(true);
|
||||
importSpecifiedTradePaymentTerms((Element)newNode, description[i], dateTime[i], dateTimeFormat[i]);
|
||||
parent.insertBefore(newNode, node);
|
||||
}
|
||||
}
|
||||
|
||||
protected void importSpecifiedTradePaymentTerms(Element parent, String[] description, Date dateTime, String dateTimeFormat) throws InvalidCodeException {
|
||||
Node node = parent.getElementsByTagName("ram:Description").item(0);
|
||||
for (String d : description) {
|
||||
Node newNode = node.cloneNode(true);
|
||||
newNode.setTextContent(d);
|
||||
parent.insertBefore(newNode, node);
|
||||
}
|
||||
if (dateTimeFormat != null)
|
||||
importDateTime(parent, "udt:DateTimeString", dateTimeFormat, dateTime);
|
||||
}
|
||||
|
||||
protected void importLineItemsComfort(Element parent, ComfortProfile data) throws DataIncompleteException, InvalidCodeException {
|
||||
String[] lineIDs = data.getLineItemLineID();
|
||||
if (lineIDs.length == 0)
|
||||
throw new DataIncompleteException("You can create an invoice without any line items");
|
||||
String[][][] includedNote = data.getLineItemIncludedNote();
|
||||
String[] grossPriceChargeAmount = data.getLineItemGrossPriceChargeAmount();
|
||||
String[] grossPriceChargeAmountCurrencyID = data.getLineItemGrossPriceChargeAmountCurrencyID();
|
||||
String[] grossPriceBasisQuantity = data.getLineItemGrossPriceBasisQuantity();
|
||||
String[] grossPriceBasisQuantityCode = data.getLineItemGrossPriceBasisQuantityCode();
|
||||
Boolean[][] grossPriceTradeAllowanceChargeIndicator = data.getLineItemGrossPriceTradeAllowanceChargeIndicator();
|
||||
String[][] grossPriceTradeAllowanceChargeActualAmount = data.getLineItemGrossPriceTradeAllowanceChargeActualAmount();
|
||||
String[][] grossPriceTradeAllowanceChargeActualAmountCurrencyID = data.getLineItemGrossPriceTradeAllowanceChargeActualAmountCurrencyID();
|
||||
String[][] grossPriceTradeAllowanceChargeReason = data.getLineItemGrossPriceTradeAllowanceChargeReason();
|
||||
String[] netPriceChargeAmount = data.getLineItemNetPriceChargeAmount();
|
||||
String[] netPriceChargeAmountCurrencyID = data.getLineItemNetPriceChargeAmountCurrencyID();
|
||||
String[] netPriceBasisQuantity = data.getLineItemNetPriceBasisQuantity();
|
||||
String[] netPriceBasisQuantityCode = data.getLineItemNetPriceBasisQuantityCode();
|
||||
String[] billedQuantity = data.getLineItemBilledQuantity();
|
||||
String[] billedQuantityUnitCode = data.getLineItemBilledQuantityUnitCode();
|
||||
String[][] settlementTaxTypeCode = data.getLineItemSettlementTaxTypeCode();
|
||||
String[][] settlementTaxExemptionReason = data.getLineItemSettlementTaxExemptionReason();
|
||||
String[][] settlementTaxCategoryCode = data.getLineItemSettlementTaxCategoryCode();
|
||||
String[][] settlementTaxApplicablePercent = data.getLineItemSettlementTaxApplicablePercent();
|
||||
String[] totalAmount = data.getLineItemLineTotalAmount();
|
||||
String[] totalAmountCurrencyID = data.getLineItemLineTotalAmountCurrencyID();
|
||||
String[] specifiedTradeProductGlobalID = data.getLineItemSpecifiedTradeProductGlobalID();
|
||||
String[] specifiedTradeProductSchemeID = data.getLineItemSpecifiedTradeProductSchemeID();
|
||||
String[] specifiedTradeProductSellerAssignedID = data.getLineItemSpecifiedTradeProductSellerAssignedID();
|
||||
String[] specifiedTradeProductBuyerAssignedID = data.getLineItemSpecifiedTradeProductBuyerAssignedID();
|
||||
String[] specifiedTradeProductName = data.getLineItemSpecifiedTradeProductName();
|
||||
String[] specifiedTradeProductDescription = data.getLineItemSpecifiedTradeProductDescription();
|
||||
Node node = parent.getElementsByTagName("ram:IncludedSupplyChainTradeLineItem").item(0);
|
||||
for (int i = 0; i < lineIDs.length; i++) {
|
||||
Node newNode = node.cloneNode(true);
|
||||
importLineItemComfort((Element)newNode, lineIDs[i], includedNote[i], grossPriceChargeAmount[i], grossPriceChargeAmountCurrencyID[i], grossPriceBasisQuantity[i], grossPriceBasisQuantityCode[i], grossPriceTradeAllowanceChargeIndicator[i], grossPriceTradeAllowanceChargeActualAmount[i], grossPriceTradeAllowanceChargeActualAmountCurrencyID[i], grossPriceTradeAllowanceChargeReason[i], netPriceChargeAmount[i], netPriceChargeAmountCurrencyID[i], netPriceBasisQuantity[i], netPriceBasisQuantityCode[i], billedQuantity[i], billedQuantityUnitCode[i], settlementTaxTypeCode[i], settlementTaxExemptionReason[i], settlementTaxCategoryCode[i], settlementTaxApplicablePercent[i], totalAmount[i], totalAmountCurrencyID[i], specifiedTradeProductGlobalID[i], specifiedTradeProductSchemeID[i], specifiedTradeProductSellerAssignedID[i], specifiedTradeProductBuyerAssignedID[i], specifiedTradeProductName[i], specifiedTradeProductDescription[i]);
|
||||
parent.insertBefore(newNode, node);
|
||||
}
|
||||
}
|
||||
|
||||
protected void importLineItemComfort(Element parent, String lineID, String[][] note, String grossPriceChargeAmount, String grossPriceChargeAmountCurrencyID, String grossPriceBasisQuantity, String grossPriceBasisQuantityCode, Boolean[] grossPriceTradeAllowanceChargeIndicator, String[] grossPriceTradeAllowanceChargeActualAmount, String[] grossPriceTradeAllowanceChargeActualAmountCurrencyID, String[] grossPriceTradeAllowanceChargeReason, String netPriceChargeAmount, String netPriceChargeAmountCurrencyID, String netPriceBasisQuantity, String netPriceBasisQuantityCode, String billedQuantity, String billedQuantityCode, String[] settlementTaxTypeCode, String[] settlementTaxExemptionReason, String[] settlementTaxCategoryCode, String[] settlementTaxApplicablePercent, String totalAmount, String totalAmountCurrencyID, String specifiedTradeProductGlobalID, String specifiedTradeProductSchemeID, String specifiedTradeProductSellerAssignedID, String specifiedTradeProductBuyerAssignedID, String specifiedTradeProductName, String specifiedTradeProductDescription) throws DataIncompleteException, InvalidCodeException {
|
||||
Element sub = (Element)parent.getElementsByTagName("ram:AssociatedDocumentLineDocument").item(0);
|
||||
importContent(sub, "ram:LineID", lineID);
|
||||
importIncludedNotes(sub, 2, note, null);
|
||||
if (grossPriceChargeAmount != null) {
|
||||
sub = (Element)parent.getElementsByTagName("ram:GrossPriceProductTradePrice").item(0);
|
||||
importContent(sub, "ram:ChargeAmount", DEC4.check(grossPriceChargeAmount), "currencyID", CURR_CODE.check(grossPriceChargeAmountCurrencyID));
|
||||
if (grossPriceBasisQuantity != null)
|
||||
importContent(sub, "ram:BasisQuantity", DEC4.check(grossPriceBasisQuantity), "unitCode", M_UNIT_CODE.check(grossPriceBasisQuantityCode));
|
||||
Node node1 = sub.getElementsByTagName("ram:AppliedTradeAllowanceCharge").item(0);
|
||||
if (grossPriceTradeAllowanceChargeIndicator != null)
|
||||
for (int j = 0; j < grossPriceTradeAllowanceChargeIndicator.length; j++) {
|
||||
Node newNode = node1.cloneNode(true);
|
||||
importAppliedTradeAllowanceCharge((Element)newNode, grossPriceTradeAllowanceChargeIndicator[j]
|
||||
.booleanValue(), grossPriceTradeAllowanceChargeActualAmount[j], grossPriceTradeAllowanceChargeActualAmountCurrencyID[j], grossPriceTradeAllowanceChargeReason[j]);
|
||||
sub.insertBefore(newNode, node1);
|
||||
}
|
||||
}
|
||||
if (netPriceChargeAmount != null) {
|
||||
sub = (Element)parent.getElementsByTagName("ram:NetPriceProductTradePrice").item(0);
|
||||
importContent(sub, "ram:ChargeAmount", DEC4.check(netPriceChargeAmount), "currencyID", CURR_CODE.check(netPriceChargeAmountCurrencyID));
|
||||
if (netPriceBasisQuantity != null)
|
||||
importContent(sub, "ram:BasisQuantity", DEC4.check(netPriceBasisQuantity), "unitCode", M_UNIT_CODE.check(netPriceBasisQuantityCode));
|
||||
}
|
||||
sub = (Element)parent.getElementsByTagName("ram:SpecifiedSupplyChainTradeDelivery").item(0);
|
||||
importContent(sub, "ram:BilledQuantity", DEC4.check(billedQuantity), "unitCode", M_UNIT_CODE.check(billedQuantityCode));
|
||||
sub = (Element)parent.getElementsByTagName("ram:SpecifiedSupplyChainTradeSettlement").item(0);
|
||||
Node node = sub.getElementsByTagName("ram:ApplicableTradeTax").item(0);
|
||||
for (int i = 0; i < settlementTaxApplicablePercent.length; i++) {
|
||||
Node newNode = node.cloneNode(true);
|
||||
importTax((Element)newNode, settlementTaxTypeCode[i], settlementTaxExemptionReason[i], settlementTaxCategoryCode[i], settlementTaxApplicablePercent[i]);
|
||||
sub.insertBefore(newNode, node);
|
||||
}
|
||||
importContent(sub, "ram:LineTotalAmount", totalAmount, "currencyID", totalAmountCurrencyID);
|
||||
sub = (Element)parent.getElementsByTagName("ram:SpecifiedTradeProduct").item(0);
|
||||
if (specifiedTradeProductGlobalID != null)
|
||||
importContent(sub, "ram:GlobalID", specifiedTradeProductGlobalID, "schemeID", GI_CODE.check(specifiedTradeProductSchemeID));
|
||||
importContent(sub, "ram:SellerAssignedID", specifiedTradeProductSellerAssignedID);
|
||||
importContent(sub, "ram:BuyerAssignedID", specifiedTradeProductBuyerAssignedID);
|
||||
importContent(sub, "ram:Name", specifiedTradeProductName);
|
||||
importContent(sub, "ram:Description", specifiedTradeProductDescription);
|
||||
}
|
||||
|
||||
protected void importAppliedTradeAllowanceCharge(Element parent, boolean indicator, String actualAmount, String currencyID, String reason) throws DataIncompleteException, InvalidCodeException {
|
||||
importContent(parent, "udt:Indicator", indicator ? "true" : "false");
|
||||
check(DEC4.check(actualAmount), "AppliedTradeAllowanceCharge > ActualAmount");
|
||||
importContent(parent, "ram:ActualAmount", actualAmount, "currencyID", CURR_CODE.check(currencyID));
|
||||
importContent(parent, "ram:Reason", reason);
|
||||
}
|
||||
|
||||
protected void importTax(Element parent, String typeCode, String exemptionReason, String category, String percent) throws InvalidCodeException, DataIncompleteException {
|
||||
check(typeCode, "ApplicableTradeTax > TypeCode");
|
||||
importContent(parent, "ram:TypeCode", TT_CODE.check(typeCode));
|
||||
importContent(parent, "ram:ExemptionReason", exemptionReason);
|
||||
if (category != null)
|
||||
importContent(parent, "ram:CategoryCode", TC_CODE.check(category));
|
||||
importContent(parent, "ram:ApplicablePercent", DEC2.check(percent));
|
||||
}
|
||||
|
||||
protected void importLineItemsBasic(Element parent, BasicProfile data) throws DataIncompleteException, InvalidCodeException {
|
||||
String[] quantity = data.getLineItemBilledQuantity();
|
||||
if (quantity.length == 0)
|
||||
throw new DataIncompleteException("You can create an invoice without any line items");
|
||||
String[] quantityCode = data.getLineItemBilledQuantityUnitCode();
|
||||
String[] name = data.getLineItemSpecifiedTradeProductName();
|
||||
Node node = parent.getElementsByTagName("ram:IncludedSupplyChainTradeLineItem").item(0);
|
||||
for (int i = 0; i < quantity.length; i++) {
|
||||
Node newNode = node.cloneNode(true);
|
||||
importLineItemBasic((Element)newNode, quantity[i], quantityCode[i], name[i]);
|
||||
parent.insertBefore(newNode, node);
|
||||
}
|
||||
}
|
||||
|
||||
protected void importLineItemBasic(Element parent, String quantity, String code, String name) throws InvalidCodeException {
|
||||
Element sub = (Element)parent.getElementsByTagName("ram:SpecifiedSupplyChainTradeDelivery").item(0);
|
||||
importContent(sub, "ram:BilledQuantity", DEC4.check(quantity), "unitCode", M_UNIT_CODE.check(code));
|
||||
sub = (Element)parent.getElementsByTagName("ram:SpecifiedTradeProduct").item(0);
|
||||
importContent(sub, "ram:Name", name);
|
||||
}
|
||||
|
||||
public byte[] toXML() throws TransformerException {
|
||||
removeEmptyNodes(this.doc);
|
||||
TransformerFactory transformerFactory = TransformerFactory.newInstance();
|
||||
Transformer transformer = transformerFactory.newTransformer();
|
||||
transformer.setOutputProperty("method", "xml");
|
||||
transformer.setOutputProperty("indent", "yes");
|
||||
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
|
||||
DOMSource source = new DOMSource(this.doc);
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
Result result = new StreamResult(out);
|
||||
transformer.transform(source, result);
|
||||
return out.toByteArray();
|
||||
}
|
||||
|
||||
protected static void removeEmptyNodes(Node node) {
|
||||
NodeList list = node.getChildNodes();
|
||||
for (int i = list.getLength() - 1; i >= 0; i--)
|
||||
removeEmptyNodes(list.item(i));
|
||||
boolean emptyElement = (node.getNodeType() == 1 &&
|
||||
node.getChildNodes().getLength() == 0);
|
||||
boolean emptyText = (node.getNodeType() == 3 &&
|
||||
node.getNodeValue().trim().length() == 0);
|
||||
if (emptyElement || emptyText)
|
||||
node.getParentNode().removeChild(node);
|
||||
}
|
||||
|
||||
protected void check(String s, String message) throws DataIncompleteException {
|
||||
if (s == null || s.trim().length() == 0)
|
||||
throw new DataIncompleteException(message);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package com.itextpdf.text.zugferd.checkers;
|
||||
|
||||
import com.itextpdf.text.zugferd.exceptions.InvalidCodeException;
|
||||
|
||||
public abstract class CodeValidation {
|
||||
public abstract boolean isValid(String paramString);
|
||||
|
||||
public String check(String code) throws InvalidCodeException {
|
||||
if (code == null || !isValid(code))
|
||||
throw new InvalidCodeException(code, getClass().getName());
|
||||
return code;
|
||||
}
|
||||
|
||||
public boolean isNumeric(String code, int digits) {
|
||||
if (code.length() != digits)
|
||||
return false;
|
||||
for (char c : code.toCharArray()) {
|
||||
if (c < '0' || c > '9')
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isUppercase(String code, int chars) {
|
||||
if (code.length() != chars)
|
||||
return false;
|
||||
for (char c : code.toCharArray()) {
|
||||
if (c < 'A' || c > 'Z')
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isLowercase(String code, int chars) {
|
||||
if (code.length() != chars)
|
||||
return false;
|
||||
for (char c : code.toCharArray()) {
|
||||
if (c < 'a' || c > 'z')
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package com.itextpdf.text.zugferd.checkers;
|
||||
|
||||
public class NumberChecker extends CodeValidation {
|
||||
public static final int INTEGER = 0;
|
||||
|
||||
public static final int ANY_DECIMALS = 1;
|
||||
|
||||
public static final int TWO_DECIMALS = 2;
|
||||
|
||||
public static final int FOUR_DECIMALS = 4;
|
||||
|
||||
protected int type;
|
||||
|
||||
public NumberChecker(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public boolean isValid(String code) {
|
||||
if (this.type == 0)
|
||||
return isNumeric(code, code.length());
|
||||
if (code.endsWith("."))
|
||||
return false;
|
||||
int pos = code.indexOf(".");
|
||||
if (pos < 1)
|
||||
return false;
|
||||
String part1 = code.substring(0, pos);
|
||||
if (!isNumeric(part1, part1.length()))
|
||||
return false;
|
||||
String part2 = code.substring(pos + 1);
|
||||
switch (this.type) {
|
||||
case 2:
|
||||
return isNumeric(part2, 2);
|
||||
case 4:
|
||||
return isNumeric(part2, 4);
|
||||
}
|
||||
return isNumeric(part2, part2.length());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.itextpdf.text.zugferd.checkers.basic;
|
||||
|
||||
import com.itextpdf.text.zugferd.checkers.CodeValidation;
|
||||
|
||||
public class CountryCode extends CodeValidation {
|
||||
public boolean isValid(String code) {
|
||||
return isUppercase(code, 2);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.itextpdf.text.zugferd.checkers.basic;
|
||||
|
||||
import com.itextpdf.text.zugferd.checkers.CodeValidation;
|
||||
|
||||
public class CurrencyCode extends CodeValidation {
|
||||
public boolean isValid(String code) {
|
||||
return isUppercase(code, 3);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
package com.itextpdf.text.zugferd.checkers.basic;
|
||||
|
||||
import com.itextpdf.text.zugferd.checkers.CodeValidation;
|
||||
import com.itextpdf.text.zugferd.exceptions.InvalidCodeException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class DateFormatCode extends CodeValidation {
|
||||
public static final String YYYYMMDD = "102";
|
||||
|
||||
public static final String YYYYMM = "610";
|
||||
|
||||
public static final String YYYYWW = "616";
|
||||
|
||||
public boolean isValid(String format) {
|
||||
return (format.equals("102") ||
|
||||
format.equals("610") ||
|
||||
format.equals("616"));
|
||||
}
|
||||
|
||||
public String convertToString(Date d, String format) throws InvalidCodeException {
|
||||
return getDateFormat(format).format(d);
|
||||
}
|
||||
|
||||
public Date convertToDate(String d, String format) throws InvalidCodeException, ParseException {
|
||||
return getDateFormat(format).parse(d);
|
||||
}
|
||||
|
||||
public static SimpleDateFormat getDateFormat(String format) throws InvalidCodeException {
|
||||
if ("102".equals(format))
|
||||
return new SimpleDateFormat("yyyyMMdd");
|
||||
if ("610".equals(format))
|
||||
return new SimpleDateFormat("yyyyMM");
|
||||
if ("616".equals(format))
|
||||
return new SimpleDateFormat("yyyyww");
|
||||
throw new InvalidCodeException(format, "date format");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
package com.itextpdf.text.zugferd.checkers.basic;
|
||||
|
||||
import com.itextpdf.text.zugferd.checkers.CodeValidation;
|
||||
|
||||
public class DocumentTypeCode extends CodeValidation {
|
||||
public static final String COMMERCIAL_INVOICE = "380";
|
||||
|
||||
public static final String DEBIT_NOTE_FINANCIAL_ADJUSTMENT = "38";
|
||||
|
||||
public static final String SELF_BILLED_INVOICE = "389";
|
||||
|
||||
public static final int BASIC = 0;
|
||||
|
||||
public static final int COMFORT = 1;
|
||||
|
||||
public static final int EXTENDED = 2;
|
||||
|
||||
protected int profile;
|
||||
|
||||
public DocumentTypeCode(int profile) {
|
||||
this.profile = profile;
|
||||
}
|
||||
|
||||
public boolean isValid(String code) {
|
||||
switch (this.profile) {
|
||||
case 0:
|
||||
return isValidBasic(code);
|
||||
case 1:
|
||||
return isValidComfort(code);
|
||||
}
|
||||
return isValidExtended(code);
|
||||
}
|
||||
|
||||
public static boolean isValidBasic(String code) {
|
||||
return "380".equals(code);
|
||||
}
|
||||
|
||||
public static boolean isValidComfort(String code) {
|
||||
return ("380".equals(code) || "38"
|
||||
.equals(code));
|
||||
}
|
||||
|
||||
public static boolean isValidExtended(String code) {
|
||||
return ("380".equals(code) || "38"
|
||||
.equals(code) || "389"
|
||||
.equals(code));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.itextpdf.text.zugferd.checkers.basic;
|
||||
|
||||
import com.itextpdf.text.zugferd.checkers.CodeValidation;
|
||||
|
||||
public class LanguageCode extends CodeValidation {
|
||||
public boolean isValid(String code) {
|
||||
return isLowercase(code, 2);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
package com.itextpdf.text.zugferd.checkers.basic;
|
||||
|
||||
import com.itextpdf.text.zugferd.checkers.CodeValidation;
|
||||
|
||||
public class MeasurementUnitCode extends CodeValidation {
|
||||
public static final String ITEM = "C62";
|
||||
|
||||
public static final String DAY = "DAY";
|
||||
|
||||
public static final String HA = "HAR";
|
||||
|
||||
public static final String HR = "HUR";
|
||||
|
||||
public static final String KG = "KGM";
|
||||
|
||||
public static final String KM = "KTM";
|
||||
|
||||
public static final String KWH = "KWH";
|
||||
|
||||
public static final String SUM = "LS";
|
||||
|
||||
public static final String L = "LTR";
|
||||
|
||||
public static final String MIN = "MIN";
|
||||
|
||||
public static final String MM2 = "MMK";
|
||||
|
||||
public static final String MM = "MMT";
|
||||
|
||||
public static final String M2 = "MTK";
|
||||
|
||||
public static final String M3 = "MTQ";
|
||||
|
||||
public static final String M = "MTR";
|
||||
|
||||
public static final String NO = "NAR";
|
||||
|
||||
public static final String PR = "NPR";
|
||||
|
||||
public static final String PCT = "P1";
|
||||
|
||||
public static final String SET = "SET";
|
||||
|
||||
public static final String T = "TNE";
|
||||
|
||||
public static final String WK = "WEE";
|
||||
|
||||
public boolean isValid(String code) {
|
||||
return (code.equals("C62") ||
|
||||
code.equals("DAY") ||
|
||||
code.equals("HAR") ||
|
||||
code.equals("HUR") ||
|
||||
code.equals("KGM") ||
|
||||
code.equals("KTM") ||
|
||||
code.equals("KWH") ||
|
||||
code.equals("LS") ||
|
||||
code.equals("LTR") ||
|
||||
code.equals("MIN") ||
|
||||
code.equals("MMK") ||
|
||||
code.equals("MMT") ||
|
||||
code.equals("MTK") ||
|
||||
code.equals("MTQ") ||
|
||||
code.equals("MTR") ||
|
||||
code.equals("NAR") ||
|
||||
code.equals("NPR") ||
|
||||
code.equals("P1") ||
|
||||
code.equals("SET") ||
|
||||
code.equals("TNE") ||
|
||||
code.equals("WEE"));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package com.itextpdf.text.zugferd.checkers.basic;
|
||||
|
||||
import com.itextpdf.text.zugferd.checkers.CodeValidation;
|
||||
|
||||
public class TaxIDTypeCode extends CodeValidation {
|
||||
public static final String VAT = "VA";
|
||||
|
||||
public static final String FISCAL_NUMBER = "FC";
|
||||
|
||||
public boolean isValid(String code) {
|
||||
return (code.equals("VA") || code.equals("FC"));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.itextpdf.text.zugferd.checkers.basic;
|
||||
|
||||
import com.itextpdf.text.zugferd.checkers.CodeValidation;
|
||||
|
||||
public class TaxTypeCode extends CodeValidation {
|
||||
public static final String VALUE_ADDED_TAX = "VAT";
|
||||
|
||||
public static final String INSURANCE_TAX = "ZF_INSURANCE_TAX";
|
||||
|
||||
public static final String TAX_ON_REPLACEMENT_PART = "AAJ";
|
||||
|
||||
public boolean isValid(String code) {
|
||||
return (code.equals("VAT") ||
|
||||
code.equals("ZF_INSURANCE_TAX") ||
|
||||
code.equals("AAJ"));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
package com.itextpdf.text.zugferd.checkers.comfort;
|
||||
|
||||
import com.itextpdf.text.zugferd.checkers.CodeValidation;
|
||||
|
||||
public class FreeTextSubjectCode extends CodeValidation {
|
||||
public static final String REGULATORY_INFORMATION = "REG";
|
||||
|
||||
public static final String PRICE_CONDITIONS = "AAK";
|
||||
|
||||
public static final String ADDITIONAL_SALES_CONDITIONS = "AAJ";
|
||||
|
||||
public static final String PAYMENT_INFORMATION = "PMT";
|
||||
|
||||
public static final String PRICE_CALCULATION_FORMULA = "PRF";
|
||||
|
||||
public static final String PRODUCT_INFORMATION = "PRD";
|
||||
|
||||
public static final String CERTIFICATION_STATEMENTS = "AAY";
|
||||
|
||||
public static final int HEADER = 1;
|
||||
|
||||
public static final int LINE = 2;
|
||||
|
||||
protected int level;
|
||||
|
||||
public FreeTextSubjectCode(int level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public boolean isValid(String code) {
|
||||
switch (this.level) {
|
||||
case 1:
|
||||
return isHeaderLevel(code);
|
||||
case 2:
|
||||
return isLineLevel(code);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isHeaderLevel(String code) {
|
||||
return (code.equals("REG") ||
|
||||
code.equals("AAK") ||
|
||||
code.equals("AAJ") ||
|
||||
code.equals("PMT"));
|
||||
}
|
||||
|
||||
public static boolean isLineLevel(String code) {
|
||||
return (code.equals("PRF") ||
|
||||
code.equals("PRD") ||
|
||||
code.equals("AAY"));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.itextpdf.text.zugferd.checkers.comfort;
|
||||
|
||||
import com.itextpdf.text.zugferd.checkers.CodeValidation;
|
||||
|
||||
public class GlobalIdentifierCode extends CodeValidation {
|
||||
public static final String SWIFT = "0021";
|
||||
|
||||
public static final String DUNS = "0060";
|
||||
|
||||
public static final String GLN = "0088";
|
||||
|
||||
public static final String GTIN = "0160";
|
||||
|
||||
public static final String ODETTE = "0177";
|
||||
|
||||
public boolean isValid(String code) {
|
||||
return isNumeric(code, 4);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
package com.itextpdf.text.zugferd.checkers.comfort;
|
||||
|
||||
import com.itextpdf.text.zugferd.checkers.CodeValidation;
|
||||
|
||||
public class PaymentMeansCode extends CodeValidation {
|
||||
public static final String NOT_DEFINED = "1";
|
||||
|
||||
public static final String AUTOMATED_CLEARING_HOUSE = "3";
|
||||
|
||||
public static final String CASH = "10";
|
||||
|
||||
public static final String CHEQUE = "20";
|
||||
|
||||
public static final String DEBIT_TRANSFER = "31";
|
||||
|
||||
public static final String PAYMENT_TO_BANK_ACCOUNT = "42";
|
||||
|
||||
public static final String BANK_CARD = "48";
|
||||
|
||||
public static final String DIRECT_DEBIT = "49";
|
||||
|
||||
public static final String CLEARING = "97";
|
||||
|
||||
public boolean isValid(String code) {
|
||||
return (code.equals("1") ||
|
||||
code.equals("3") ||
|
||||
code.equals("10") ||
|
||||
code.equals("20") ||
|
||||
code.equals("31") ||
|
||||
code.equals("42") ||
|
||||
code.equals("48") ||
|
||||
code.equals("49") ||
|
||||
code.equals("97"));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package com.itextpdf.text.zugferd.checkers.comfort;
|
||||
|
||||
import com.itextpdf.text.zugferd.checkers.CodeValidation;
|
||||
|
||||
public class TaxCategoryCode extends CodeValidation {
|
||||
public static final String VAT_REVERSE_CHARGE = "AE";
|
||||
|
||||
public static final String EXEMPT_FROM_TAX = "E";
|
||||
|
||||
public static final String ZERO_RATED_GOODS = "Z";
|
||||
|
||||
public static final String OUTSIDE_SCOPE = "O";
|
||||
|
||||
public static final String INTRA_COMMUNITY_SUPPLY = "IC";
|
||||
|
||||
public static final String STANDARD_RATE = "S";
|
||||
|
||||
public boolean isValid(String code) {
|
||||
return (code.equals("S") ||
|
||||
code.equals("E") ||
|
||||
code.equals("Z") ||
|
||||
code.equals("O") ||
|
||||
code.equals("IC") ||
|
||||
code.equals("AE"));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
package com.itextpdf.text.zugferd.checkers.extended;
|
||||
|
||||
import com.itextpdf.text.zugferd.checkers.CodeValidation;
|
||||
|
||||
public class AdditionalReferencedDocumentsCode extends CodeValidation {
|
||||
public static final String ORDER_ACKNOWLEDGEMENT = "AAA";
|
||||
|
||||
public static final String PROFORMA_INVOICE = "AAB";
|
||||
|
||||
public static final String OFFER = "AAG";
|
||||
|
||||
public static final String DELIVERY_ORDER = "AAJ";
|
||||
|
||||
public static final String DRAWING = "AAL";
|
||||
|
||||
public static final String WAYBILL = "AAM";
|
||||
|
||||
public static final String TRANSPORT_CONTRACT = "AAS";
|
||||
|
||||
public static final String GOODS_DECLARATION = "ABT";
|
||||
|
||||
public static final String PROJECT_SPECIFICATION = "AER";
|
||||
|
||||
public static final String DISPUTE = "AGG";
|
||||
|
||||
public static final String AGREEMENT = "AJS";
|
||||
|
||||
public static final String RETURNS_NOTICE = "ALQ";
|
||||
|
||||
public static final String RECEIVING_ADVICE = "ALO";
|
||||
|
||||
public static final String INVENTORY_REPORT = "API";
|
||||
|
||||
public static final String PROOF_OF_DELIVERY = "ASI";
|
||||
|
||||
public static final String COLLECTION_REF = "AUD";
|
||||
|
||||
public static final String DOCUMENT_REF = "AWR";
|
||||
|
||||
public static final String BLANKET_ORDER = "BO";
|
||||
|
||||
public static final String BUYERS_CONTRACT = "BC";
|
||||
|
||||
public static final String CREDIT_NOTE = "CD";
|
||||
|
||||
public static final String DEBIT_NOTE = "DL";
|
||||
|
||||
public static final String METER_UNIT = "MG";
|
||||
|
||||
public static final String PREVIOUS_INVOICE = "OI";
|
||||
|
||||
public static final String PRICE_LIST = "PL";
|
||||
|
||||
public static final String PACKING_LIST = "PK";
|
||||
|
||||
public static final String PURCHASE_ORDER_RESPONSE = "POR";
|
||||
|
||||
public static final String PURCHASE_ORDER_CHANGE = "PP";
|
||||
|
||||
public static final String TRANSPORT_INSTRUCTION = "TIN";
|
||||
|
||||
public static final String VENDOR_ORDER = "VN";
|
||||
|
||||
public boolean isValid(String code) {
|
||||
return (code.equals("AAA") ||
|
||||
code.equals("AAB") ||
|
||||
code.equals("AAG") ||
|
||||
code.equals("AAJ") ||
|
||||
code.equals("AAL") ||
|
||||
code.equals("AAM") ||
|
||||
code.equals("AAS") ||
|
||||
code.equals("ABT") ||
|
||||
code.equals("AER") ||
|
||||
code.equals("AGG") ||
|
||||
code.equals("AJS") ||
|
||||
code.equals("ALQ") ||
|
||||
code.equals("ALO") ||
|
||||
code.equals("API") ||
|
||||
code.equals("ASI") ||
|
||||
code.equals("AUD") ||
|
||||
code.equals("AWR") ||
|
||||
code.equals("BO") ||
|
||||
code.equals("BC") ||
|
||||
code.equals("CD") ||
|
||||
code.equals("DL") ||
|
||||
code.equals("MG") ||
|
||||
code.equals("OI") ||
|
||||
code.equals("PL") ||
|
||||
code.equals("PK") ||
|
||||
code.equals("POR") ||
|
||||
code.equals("PP") ||
|
||||
code.equals("TIN") ||
|
||||
code.equals("VN"));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
package com.itextpdf.text.zugferd.checkers.extended;
|
||||
|
||||
import com.itextpdf.text.zugferd.checkers.CodeValidation;
|
||||
|
||||
public class AllowanceChargeReasonCode extends CodeValidation {
|
||||
public static final String ADVERTISING = "AA";
|
||||
|
||||
public static final String OTHER_SERVICES = "ADR";
|
||||
|
||||
public static final String COLLECTION_AND_RECYCLING = "AEO";
|
||||
|
||||
public static final String DISCOUNT = "DI";
|
||||
|
||||
public static final String EARLY_PAYMENT_ALLOWANCE = "EAB";
|
||||
|
||||
public static final String FREIGHT_SERVICE = "FC";
|
||||
|
||||
public static final String INSURANCE = "IN";
|
||||
|
||||
public static final String MINIMUM_BILLING_CHARGE = "MAC";
|
||||
|
||||
public static final String NON_RETURNABLE_CONTAINERS = "NAA";
|
||||
|
||||
public static final String PACKING = "PC";
|
||||
|
||||
public static final String REBATE = "RAA";
|
||||
|
||||
public static final String SPECIAL_HANDLING = "SH";
|
||||
|
||||
public boolean isValid(String code) {
|
||||
return (code.equals("AA") ||
|
||||
code.equals("ADR") ||
|
||||
code.equals("AEO") ||
|
||||
code.equals("DI") ||
|
||||
code.equals("EAB") ||
|
||||
code.equals("FC") ||
|
||||
code.equals("IN") ||
|
||||
code.equals("MAC") ||
|
||||
code.equals("NAA") ||
|
||||
code.equals("PC") ||
|
||||
code.equals("RAA") ||
|
||||
code.equals("SH"));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.itextpdf.text.zugferd.checkers.extended;
|
||||
|
||||
import com.itextpdf.text.zugferd.checkers.CodeValidation;
|
||||
|
||||
public class IncotermsCode extends CodeValidation {
|
||||
public static final String EX_WORKS = "EXW";
|
||||
|
||||
public static final String FREE_CARRIER = "FCA";
|
||||
|
||||
public static final String FREE_ALONGSIDE_SHIP = "FAS";
|
||||
|
||||
public static final String FREE_ON_BOARD = "FOB";
|
||||
|
||||
public static final String COST_AND_FREIGHT = "CFR";
|
||||
|
||||
public static final String COST_INSURANCE_FREIGHT = "CIF";
|
||||
|
||||
public static final String DELIVERED_AT_TERMINAL = "DAT";
|
||||
|
||||
public static final String DELIVERED_AT_PLACE = "DAP";
|
||||
|
||||
public static final String CARRIAGE_PAID_TO = "CPT";
|
||||
|
||||
public static final String CARRIAGE_INSURANCE_PAID = "CIP";
|
||||
|
||||
public static final String DELIVERED_DUTY_PAID = "DDP";
|
||||
|
||||
public boolean isValid(String code) {
|
||||
return (code.equals("EXW") ||
|
||||
code.equals("FCA") ||
|
||||
code.equals("FAS") ||
|
||||
code.equals("FOB") ||
|
||||
code.equals("CFR") ||
|
||||
code.equals("CIF") ||
|
||||
code.equals("DAT") ||
|
||||
code.equals("DAP") ||
|
||||
code.equals("CPT") ||
|
||||
code.equals("CIP") ||
|
||||
code.equals("DDP"));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
package com.itextpdf.text.zugferd.checkers.extended;
|
||||
|
||||
import com.itextpdf.text.zugferd.checkers.CodeValidation;
|
||||
|
||||
public class ProductClassificationSystemCode extends CodeValidation {
|
||||
public static final String GPC = "GPC";
|
||||
|
||||
public static final String ECL = "ECL";
|
||||
|
||||
public static final String UNSPSC = "UNSPSC";
|
||||
|
||||
public static final String HS = "HS";
|
||||
|
||||
public static final String CBV = "CBV";
|
||||
|
||||
public static final String SELLER_ASSIGNED = "SELLER_ASSIGNED";
|
||||
|
||||
public static final String BUYER_ASSIGNED = "BUYER_ASSIGNED";
|
||||
|
||||
public boolean isValid(String code) {
|
||||
return (code.equals("GPC") ||
|
||||
code.equals("ECL") ||
|
||||
code.equals("UNSPSC") ||
|
||||
code.equals("HS") ||
|
||||
code.equals("CBV") ||
|
||||
code.equals("SELLER_ASSIGNED") ||
|
||||
code.equals("BUYER_ASSIGNED"));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package com.itextpdf.text.zugferd.checkers.extended;
|
||||
|
||||
import com.itextpdf.text.zugferd.checkers.CodeValidation;
|
||||
|
||||
public class QuantityCode extends CodeValidation {
|
||||
public static final String BARREL = "BA";
|
||||
|
||||
public static final String BOTTLECRATE = "BC";
|
||||
|
||||
public static final String BAG = "BG";
|
||||
|
||||
public static final String BOTTLE = "BO";
|
||||
|
||||
public static final String BOX = "BX";
|
||||
|
||||
public static final String CASE = "CS";
|
||||
|
||||
public static final String CARTON = "CT";
|
||||
|
||||
public static final String CAN = "CX";
|
||||
|
||||
public static final String UNPACKAGED = "NE";
|
||||
|
||||
public static final String PALLET = "PX";
|
||||
|
||||
public static final String ROLL = "RO";
|
||||
|
||||
public static final String SACK = "SA";
|
||||
|
||||
public boolean isValid(String code) {
|
||||
return isUppercase(code, 2);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package com.itextpdf.text.zugferd.checkers.extended;
|
||||
|
||||
import com.itextpdf.text.zugferd.checkers.CodeValidation;
|
||||
|
||||
public class TransportIdentificationCode extends CodeValidation {
|
||||
public static final String SHIPMENT_REFERENCE = "SHIPMENT_REFERENCE";
|
||||
|
||||
public static final String FLIGHT_NUMBER = "FLIGHT_NO";
|
||||
|
||||
public static final String NUMBER_PLATE = "NUMBER_PLATE";
|
||||
|
||||
public static final String SSCC = "SSCC";
|
||||
|
||||
public static final String GINC = "GINC";
|
||||
|
||||
public static final String GSIN = "GSIN";
|
||||
|
||||
public boolean isValid(String code) {
|
||||
return (code.equals("SHIPMENT_REFERENCE") ||
|
||||
code.equals("FLIGHT_NO") ||
|
||||
code.equals("NUMBER_PLATE") ||
|
||||
code.equals("SSCC") ||
|
||||
code.equals("GINC") ||
|
||||
code.equals("GSIN"));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
package com.itextpdf.text.zugferd.checkers.extended;
|
||||
|
||||
import com.itextpdf.text.zugferd.checkers.CodeValidation;
|
||||
|
||||
public class TransportMeansCode extends CodeValidation {
|
||||
public static final String MARITIME = "1";
|
||||
|
||||
public static final String RAIL = "2";
|
||||
|
||||
public static final String ROAD = "3";
|
||||
|
||||
public static final String AIR = "4";
|
||||
|
||||
public static final String MAIL = "5";
|
||||
|
||||
public static final String MULTIMODAL = "6";
|
||||
|
||||
public static final String FIXED_INSTALLATION = "7";
|
||||
|
||||
public static final String INLAND_WATER = "8";
|
||||
|
||||
public static final String NOT_APPLICABLE = "9";
|
||||
|
||||
public boolean isValid(String code) {
|
||||
return (code.equals("1") ||
|
||||
code.equals("2") ||
|
||||
code.equals("3") ||
|
||||
code.equals("4") ||
|
||||
code.equals("5") ||
|
||||
code.equals("6") ||
|
||||
code.equals("7") ||
|
||||
code.equals("8") ||
|
||||
code.equals("9"));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
package com.itextpdf.text.zugferd.exceptions;
|
||||
|
||||
public class DataIncompleteException extends Exception {
|
||||
public DataIncompleteException(String tag) {
|
||||
super(String.format("The data is missing: %s", tag));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
package com.itextpdf.text.zugferd.exceptions;
|
||||
|
||||
public class InvalidCodeException extends Exception {
|
||||
public InvalidCodeException(String code, String context) {
|
||||
super(String.format("%s is an invalid code for %s", code, context));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
package com.itextpdf.text.zugferd.profiles;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public interface BasicProfile {
|
||||
boolean getTestIndicator();
|
||||
|
||||
String getId();
|
||||
|
||||
String getName();
|
||||
|
||||
String getTypeCode();
|
||||
|
||||
Date getDateTime();
|
||||
|
||||
String getDateTimeFormat();
|
||||
|
||||
String[][] getNotes();
|
||||
|
||||
String getSellerName();
|
||||
|
||||
String getSellerPostcode();
|
||||
|
||||
String getSellerLineOne();
|
||||
|
||||
String getSellerLineTwo();
|
||||
|
||||
String getSellerCityName();
|
||||
|
||||
String getSellerCountryID();
|
||||
|
||||
String[] getSellerTaxRegistrationID();
|
||||
|
||||
String[] getSellerTaxRegistrationSchemeID();
|
||||
|
||||
String getBuyerName();
|
||||
|
||||
String getBuyerPostcode();
|
||||
|
||||
String getBuyerLineOne();
|
||||
|
||||
String getBuyerLineTwo();
|
||||
|
||||
String getBuyerCityName();
|
||||
|
||||
String getBuyerCountryID();
|
||||
|
||||
String[] getBuyerTaxRegistrationID();
|
||||
|
||||
String[] getBuyerTaxRegistrationSchemeID();
|
||||
|
||||
Date getDeliveryDateTime();
|
||||
|
||||
String getDeliveryDateTimeFormat();
|
||||
|
||||
String getPaymentReference();
|
||||
|
||||
String getInvoiceCurrencyCode();
|
||||
|
||||
String[] getPaymentMeansID();
|
||||
|
||||
String[] getPaymentMeansSchemeAgencyID();
|
||||
|
||||
String[] getPaymentMeansPayeeAccountIBAN();
|
||||
|
||||
String[] getPaymentMeansPayeeAccountAccountName();
|
||||
|
||||
String[] getPaymentMeansPayeeAccountProprietaryID();
|
||||
|
||||
String[] getPaymentMeansPayeeFinancialInstitutionBIC();
|
||||
|
||||
String[] getPaymentMeansPayeeFinancialInstitutionGermanBankleitzahlID();
|
||||
|
||||
String[] getPaymentMeansPayeeFinancialInstitutionName();
|
||||
|
||||
String[] getTaxCalculatedAmount();
|
||||
|
||||
String[] getTaxCalculatedAmountCurrencyID();
|
||||
|
||||
String[] getTaxTypeCode();
|
||||
|
||||
String[] getTaxBasisAmount();
|
||||
|
||||
String[] getTaxBasisAmountCurrencyID();
|
||||
|
||||
String[] getTaxApplicablePercent();
|
||||
|
||||
String getLineTotalAmount();
|
||||
|
||||
String getLineTotalAmountCurrencyID();
|
||||
|
||||
String getChargeTotalAmount();
|
||||
|
||||
String getChargeTotalAmountCurrencyID();
|
||||
|
||||
String getAllowanceTotalAmount();
|
||||
|
||||
String getAllowanceTotalAmountCurrencyID();
|
||||
|
||||
String getTaxBasisTotalAmount();
|
||||
|
||||
String getTaxBasisTotalAmountCurrencyID();
|
||||
|
||||
String getTaxTotalAmount();
|
||||
|
||||
String getTaxTotalAmountCurrencyID();
|
||||
|
||||
String getGrandTotalAmount();
|
||||
|
||||
String getGrandTotalAmountCurrencyID();
|
||||
|
||||
String[] getLineItemBilledQuantity();
|
||||
|
||||
String[] getLineItemBilledQuantityUnitCode();
|
||||
|
||||
String[] getLineItemSpecifiedTradeProductName();
|
||||
}
|
||||
|
|
@ -0,0 +1,512 @@
|
|||
package com.itextpdf.text.zugferd.profiles;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class BasicProfileImp implements BasicProfile {
|
||||
protected boolean test = true;
|
||||
|
||||
protected String id;
|
||||
|
||||
protected String name;
|
||||
|
||||
protected String typeCode;
|
||||
|
||||
protected Date date;
|
||||
|
||||
protected String dateFormat;
|
||||
|
||||
protected List<String[]> notes = new ArrayList<String[]>();
|
||||
|
||||
protected String sellerName;
|
||||
|
||||
protected String sellerPostcode;
|
||||
|
||||
protected String sellerLineOne;
|
||||
|
||||
protected String sellerLineTwo;
|
||||
|
||||
protected String sellerCityName;
|
||||
|
||||
protected String sellerCountryID;
|
||||
|
||||
protected List<String> sellerTaxRegistrationID = new ArrayList<String>();
|
||||
|
||||
protected List<String> sellerTaxRegistrationSchemeID = new ArrayList<String>();
|
||||
|
||||
protected String buyerName;
|
||||
|
||||
protected String buyerPostcode;
|
||||
|
||||
protected String buyerLineOne;
|
||||
|
||||
protected String buyerLineTwo;
|
||||
|
||||
protected String buyerCityName;
|
||||
|
||||
protected String buyerCountryID;
|
||||
|
||||
protected List<String> buyerTaxRegistrationID = new ArrayList<String>();
|
||||
|
||||
protected List<String> buyerTaxRegistrationSchemeID = new ArrayList<String>();
|
||||
|
||||
protected Date deliveryDate;
|
||||
|
||||
protected String deliveryDateFormat;
|
||||
|
||||
protected String paymentReference;
|
||||
|
||||
protected String invoiceCurrencyCode;
|
||||
|
||||
protected List<String> paymentMeansID = new ArrayList<String>();
|
||||
|
||||
protected List<String> paymentMeansSchemeAgencyID = new ArrayList<String>();
|
||||
|
||||
protected List<String> paymentMeansPayeeAccountIBAN = new ArrayList<String>();
|
||||
|
||||
protected List<String> paymentMeansPayeeAccountName = new ArrayList<String>();
|
||||
|
||||
protected List<String> paymentMeansPayeeAccountProprietaryID = new ArrayList<String>();
|
||||
|
||||
protected List<String> paymentMeansPayeeFinancialInstitutionBIC = new ArrayList<String>();
|
||||
|
||||
protected List<String> paymentMeansPayeeFinancialInstitutionGermanBankleitzahlID = new ArrayList<String>();
|
||||
|
||||
protected List<String> paymentMeansPayeeFinancialInstitutionName = new ArrayList<String>();
|
||||
|
||||
protected List<String> taxCalculatedAmount = new ArrayList<String>();
|
||||
|
||||
protected List<String> taxCalculatedAmountCurrencyID = new ArrayList<String>();
|
||||
|
||||
protected List<String> taxTypeCode = new ArrayList<String>();
|
||||
|
||||
protected List<String> taxBasisAmount = new ArrayList<String>();
|
||||
|
||||
protected List<String> taxBasisAmountCurrencyID = new ArrayList<String>();
|
||||
|
||||
protected List<String> taxApplicablePercent = new ArrayList<String>();
|
||||
|
||||
protected String lineTotalAmount;
|
||||
|
||||
protected String lineTotalAmountCurrencyID;
|
||||
|
||||
protected String chargeTotalAmount;
|
||||
|
||||
protected String chargeTotalAmountCurrencyID;
|
||||
|
||||
protected String allowanceTotalAmount;
|
||||
|
||||
protected String allowanceTotalAmountCurrencyID;
|
||||
|
||||
protected String taxBasisTotalAmount;
|
||||
|
||||
protected String taxBasisTotalAmountCurrencyID;
|
||||
|
||||
protected String taxTotalAmount;
|
||||
|
||||
protected String taxTotalAmountCurrencyID;
|
||||
|
||||
protected String grandTotalAmount;
|
||||
|
||||
protected String grandTotalAmountCurrencyID;
|
||||
|
||||
protected List<String> lineItemBilledQuantity = new ArrayList<String>();
|
||||
|
||||
protected List<String> lineItemBilledQuantityUnitCode = new ArrayList<String>();
|
||||
|
||||
protected List<String> lineItemSpecifiedTradeProductName = new ArrayList<String>();
|
||||
|
||||
public boolean getTestIndicator() {
|
||||
return this.test;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getTypeCode() {
|
||||
return this.typeCode;
|
||||
}
|
||||
|
||||
public Date getDateTime() {
|
||||
return this.date;
|
||||
}
|
||||
|
||||
public String getDateTimeFormat() {
|
||||
return this.dateFormat;
|
||||
}
|
||||
|
||||
public String[][] getNotes() {
|
||||
return to2DArray(this.notes);
|
||||
}
|
||||
|
||||
public String getSellerName() {
|
||||
return this.sellerName;
|
||||
}
|
||||
|
||||
public String getSellerPostcode() {
|
||||
return this.sellerPostcode;
|
||||
}
|
||||
|
||||
public String getSellerLineOne() {
|
||||
return this.sellerLineOne;
|
||||
}
|
||||
|
||||
public String getSellerLineTwo() {
|
||||
return this.sellerLineTwo;
|
||||
}
|
||||
|
||||
public String getSellerCityName() {
|
||||
return this.sellerCityName;
|
||||
}
|
||||
|
||||
public String getSellerCountryID() {
|
||||
return this.sellerCountryID;
|
||||
}
|
||||
|
||||
public String[] getSellerTaxRegistrationID() {
|
||||
return to1DArray(this.sellerTaxRegistrationID);
|
||||
}
|
||||
|
||||
public String[] getSellerTaxRegistrationSchemeID() {
|
||||
return to1DArray(this.sellerTaxRegistrationSchemeID);
|
||||
}
|
||||
|
||||
public String getBuyerName() {
|
||||
return this.buyerName;
|
||||
}
|
||||
|
||||
public String getBuyerPostcode() {
|
||||
return this.buyerPostcode;
|
||||
}
|
||||
|
||||
public String getBuyerLineOne() {
|
||||
return this.buyerLineOne;
|
||||
}
|
||||
|
||||
public String getBuyerLineTwo() {
|
||||
return this.buyerLineTwo;
|
||||
}
|
||||
|
||||
public String getBuyerCityName() {
|
||||
return this.buyerCityName;
|
||||
}
|
||||
|
||||
public String getBuyerCountryID() {
|
||||
return this.buyerCountryID;
|
||||
}
|
||||
|
||||
public String[] getBuyerTaxRegistrationID() {
|
||||
return to1DArray(this.buyerTaxRegistrationID);
|
||||
}
|
||||
|
||||
public String[] getBuyerTaxRegistrationSchemeID() {
|
||||
return to1DArray(this.buyerTaxRegistrationSchemeID);
|
||||
}
|
||||
|
||||
public Date getDeliveryDateTime() {
|
||||
return this.deliveryDate;
|
||||
}
|
||||
|
||||
public String getDeliveryDateTimeFormat() {
|
||||
return this.deliveryDateFormat;
|
||||
}
|
||||
|
||||
public String getPaymentReference() {
|
||||
return this.paymentReference;
|
||||
}
|
||||
|
||||
public String getInvoiceCurrencyCode() {
|
||||
return this.invoiceCurrencyCode;
|
||||
}
|
||||
|
||||
public String[] getPaymentMeansID() {
|
||||
return to1DArray(this.paymentMeansID);
|
||||
}
|
||||
|
||||
public String[] getPaymentMeansSchemeAgencyID() {
|
||||
return to1DArray(this.paymentMeansSchemeAgencyID);
|
||||
}
|
||||
|
||||
public String[] getPaymentMeansPayeeAccountIBAN() {
|
||||
return to1DArray(this.paymentMeansPayeeAccountIBAN);
|
||||
}
|
||||
|
||||
public String[] getPaymentMeansPayeeAccountAccountName() {
|
||||
return to1DArray(this.paymentMeansPayeeAccountName);
|
||||
}
|
||||
|
||||
public String[] getPaymentMeansPayeeAccountProprietaryID() {
|
||||
return to1DArray(this.paymentMeansPayeeAccountProprietaryID);
|
||||
}
|
||||
|
||||
public String[] getPaymentMeansPayeeFinancialInstitutionBIC() {
|
||||
return to1DArray(this.paymentMeansPayeeFinancialInstitutionBIC);
|
||||
}
|
||||
|
||||
public String[] getPaymentMeansPayeeFinancialInstitutionGermanBankleitzahlID() {
|
||||
return to1DArray(this.paymentMeansPayeeFinancialInstitutionGermanBankleitzahlID);
|
||||
}
|
||||
|
||||
public String[] getPaymentMeansPayeeFinancialInstitutionName() {
|
||||
return to1DArray(this.paymentMeansPayeeFinancialInstitutionName);
|
||||
}
|
||||
|
||||
public String[] getTaxCalculatedAmount() {
|
||||
return to1DArray(this.taxCalculatedAmount);
|
||||
}
|
||||
|
||||
public String[] getTaxCalculatedAmountCurrencyID() {
|
||||
return to1DArray(this.taxCalculatedAmountCurrencyID);
|
||||
}
|
||||
|
||||
public String[] getTaxTypeCode() {
|
||||
return to1DArray(this.taxTypeCode);
|
||||
}
|
||||
|
||||
public String[] getTaxBasisAmount() {
|
||||
return to1DArray(this.taxBasisAmount);
|
||||
}
|
||||
|
||||
public String[] getTaxBasisAmountCurrencyID() {
|
||||
return to1DArray(this.taxBasisAmountCurrencyID);
|
||||
}
|
||||
|
||||
public String[] getTaxApplicablePercent() {
|
||||
return to1DArray(this.taxApplicablePercent);
|
||||
}
|
||||
|
||||
public String getLineTotalAmount() {
|
||||
return this.lineTotalAmount;
|
||||
}
|
||||
|
||||
public String getLineTotalAmountCurrencyID() {
|
||||
return this.lineTotalAmountCurrencyID;
|
||||
}
|
||||
|
||||
public String getChargeTotalAmount() {
|
||||
return this.chargeTotalAmount;
|
||||
}
|
||||
|
||||
public String getChargeTotalAmountCurrencyID() {
|
||||
return this.chargeTotalAmountCurrencyID;
|
||||
}
|
||||
|
||||
public String getAllowanceTotalAmount() {
|
||||
return this.allowanceTotalAmount;
|
||||
}
|
||||
|
||||
public String getAllowanceTotalAmountCurrencyID() {
|
||||
return this.allowanceTotalAmountCurrencyID;
|
||||
}
|
||||
|
||||
public String getTaxBasisTotalAmount() {
|
||||
return this.taxBasisTotalAmount;
|
||||
}
|
||||
|
||||
public String getTaxBasisTotalAmountCurrencyID() {
|
||||
return this.taxBasisTotalAmountCurrencyID;
|
||||
}
|
||||
|
||||
public String getTaxTotalAmount() {
|
||||
return this.taxTotalAmount;
|
||||
}
|
||||
|
||||
public String getTaxTotalAmountCurrencyID() {
|
||||
return this.taxTotalAmountCurrencyID;
|
||||
}
|
||||
|
||||
public String getGrandTotalAmount() {
|
||||
return this.grandTotalAmount;
|
||||
}
|
||||
|
||||
public String getGrandTotalAmountCurrencyID() {
|
||||
return this.grandTotalAmountCurrencyID;
|
||||
}
|
||||
|
||||
public String[] getLineItemBilledQuantity() {
|
||||
return to1DArray(this.lineItemBilledQuantity);
|
||||
}
|
||||
|
||||
public String[] getLineItemBilledQuantityUnitCode() {
|
||||
return to1DArray(this.lineItemBilledQuantityUnitCode);
|
||||
}
|
||||
|
||||
public String[] getLineItemSpecifiedTradeProductName() {
|
||||
return to1DArray(this.lineItemSpecifiedTradeProductName);
|
||||
}
|
||||
|
||||
public void setTest(boolean test) {
|
||||
this.test = test;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setTypeCode(String typeCode) {
|
||||
this.typeCode = typeCode;
|
||||
}
|
||||
|
||||
public void setDate(Date date, String dateFormat) {
|
||||
this.date = date;
|
||||
this.dateFormat = dateFormat;
|
||||
}
|
||||
|
||||
public void addNote(String[] note) {
|
||||
this.notes.add(note);
|
||||
}
|
||||
|
||||
public void setSellerName(String sellerName) {
|
||||
this.sellerName = sellerName;
|
||||
}
|
||||
|
||||
public void setSellerPostcode(String sellerPostcode) {
|
||||
this.sellerPostcode = sellerPostcode;
|
||||
}
|
||||
|
||||
public void setSellerLineOne(String sellerLineOne) {
|
||||
this.sellerLineOne = sellerLineOne;
|
||||
}
|
||||
|
||||
public void setSellerLineTwo(String sellerLineTwo) {
|
||||
this.sellerLineTwo = sellerLineTwo;
|
||||
}
|
||||
|
||||
public void setSellerCityName(String sellerCityName) {
|
||||
this.sellerCityName = sellerCityName;
|
||||
}
|
||||
|
||||
public void setSellerCountryID(String sellerCountryID) {
|
||||
this.sellerCountryID = sellerCountryID;
|
||||
}
|
||||
|
||||
public void addSellerTaxRegistration(String schemeID, String taxId) {
|
||||
this.sellerTaxRegistrationSchemeID.add(schemeID);
|
||||
this.sellerTaxRegistrationID.add(taxId);
|
||||
}
|
||||
|
||||
public void setBuyerName(String buyerName) {
|
||||
this.buyerName = buyerName;
|
||||
}
|
||||
|
||||
public void setBuyerPostcode(String buyerPostcode) {
|
||||
this.buyerPostcode = buyerPostcode;
|
||||
}
|
||||
|
||||
public void setBuyerLineOne(String buyerLineOne) {
|
||||
this.buyerLineOne = buyerLineOne;
|
||||
}
|
||||
|
||||
public void setBuyerLineTwo(String buyerLineTwo) {
|
||||
this.buyerLineTwo = buyerLineTwo;
|
||||
}
|
||||
|
||||
public void setBuyerCityName(String buyerCityName) {
|
||||
this.buyerCityName = buyerCityName;
|
||||
}
|
||||
|
||||
public void setBuyerCountryID(String buyerCountryID) {
|
||||
this.buyerCountryID = buyerCountryID;
|
||||
}
|
||||
|
||||
public void addBuyerTaxRegistration(String schemeID, String taxId) {
|
||||
this.buyerTaxRegistrationSchemeID.add(schemeID);
|
||||
this.buyerTaxRegistrationID.add(taxId);
|
||||
}
|
||||
|
||||
public void setDeliveryDate(Date deliveryDate, String deliveryDateFormat) {
|
||||
this.deliveryDate = deliveryDate;
|
||||
this.deliveryDateFormat = deliveryDateFormat;
|
||||
}
|
||||
|
||||
public void setPaymentReference(String paymentReference) {
|
||||
this.paymentReference = paymentReference;
|
||||
}
|
||||
|
||||
public void setInvoiceCurrencyCode(String invoiceCurrencyCode) {
|
||||
this.invoiceCurrencyCode = invoiceCurrencyCode;
|
||||
}
|
||||
|
||||
public void addPaymentMeans(String schemeAgencyID, String id, String iban, String accountname, String proprietaryID, String bic, String germanBankleitzahlID, String institutionname) {
|
||||
this.paymentMeansID.add(id);
|
||||
this.paymentMeansSchemeAgencyID.add(schemeAgencyID);
|
||||
this.paymentMeansPayeeAccountIBAN.add(iban);
|
||||
this.paymentMeansPayeeAccountName.add(accountname);
|
||||
this.paymentMeansPayeeAccountProprietaryID.add(proprietaryID);
|
||||
this.paymentMeansPayeeFinancialInstitutionBIC.add(bic);
|
||||
this.paymentMeansPayeeFinancialInstitutionGermanBankleitzahlID.add(germanBankleitzahlID);
|
||||
this.paymentMeansPayeeFinancialInstitutionName.add(institutionname);
|
||||
}
|
||||
|
||||
public void addApplicableTradeTax(String calculatedAmount, String calculatedAmountCurrencyID, String typeCode, String basisAmount, String basisAmountCurrencyID, String applicablePercent) {
|
||||
this.taxCalculatedAmount.add(calculatedAmount);
|
||||
this.taxCalculatedAmountCurrencyID.add(calculatedAmountCurrencyID);
|
||||
this.taxTypeCode.add(typeCode);
|
||||
this.taxBasisAmount.add(basisAmount);
|
||||
this.taxBasisAmountCurrencyID.add(basisAmountCurrencyID);
|
||||
this.taxApplicablePercent.add(applicablePercent);
|
||||
}
|
||||
|
||||
public void setMonetarySummation(String lineTotalAmount, String lineTotalAmountCurrencyID, String chargeTotalAmount, String chargeTotalAmountCurrencyID, String allowanceTotalAmount, String allowanceTotalAmountCurrencyID, String taxBasisTotalAmount, String taxBasisTotalAmountCurrencyID, String taxTotalAmount, String taxTotalAmountCurrencyID, String grandTotalAmount, String grandTotalAmountCurrencyID) {
|
||||
this.lineTotalAmount = lineTotalAmount;
|
||||
this.lineTotalAmountCurrencyID = lineTotalAmountCurrencyID;
|
||||
this.chargeTotalAmount = chargeTotalAmount;
|
||||
this.chargeTotalAmountCurrencyID = chargeTotalAmountCurrencyID;
|
||||
this.allowanceTotalAmount = allowanceTotalAmount;
|
||||
this.allowanceTotalAmountCurrencyID = allowanceTotalAmountCurrencyID;
|
||||
this.taxBasisTotalAmount = taxBasisTotalAmount;
|
||||
this.taxBasisTotalAmountCurrencyID = taxBasisTotalAmountCurrencyID;
|
||||
this.taxTotalAmount = taxTotalAmount;
|
||||
this.taxTotalAmountCurrencyID = taxTotalAmountCurrencyID;
|
||||
this.grandTotalAmount = grandTotalAmount;
|
||||
this.grandTotalAmountCurrencyID = grandTotalAmountCurrencyID;
|
||||
}
|
||||
|
||||
public void addIncludedSupplyChainTradeLineItem(String billedQuantity, String billedQuantityUnitCode, String specifiedTradeProductName) {
|
||||
this.lineItemBilledQuantity.add(billedQuantity);
|
||||
this.lineItemBilledQuantityUnitCode.add(billedQuantityUnitCode);
|
||||
this.lineItemSpecifiedTradeProductName.add(specifiedTradeProductName);
|
||||
}
|
||||
|
||||
protected String[] to1DArray(List<String> list) {
|
||||
return list.<String>toArray(new String[list.size()]);
|
||||
}
|
||||
|
||||
protected Boolean[] to1DArrayB(List<Boolean> list) {
|
||||
return list.<Boolean>toArray(new Boolean[list.size()]);
|
||||
}
|
||||
|
||||
protected String[][] to2DArray(List<String[]> list) {
|
||||
int n = list.size();
|
||||
String[][] array = new String[n][];
|
||||
for (int i = 0; i < n; i++)
|
||||
array[i] = list.get(i);
|
||||
return array;
|
||||
}
|
||||
|
||||
protected Boolean[][] to2DArrayB(List<Boolean[]> list) {
|
||||
int n = list.size();
|
||||
Boolean[][] array = new Boolean[n][];
|
||||
for (int i = 0; i < n; i++)
|
||||
array[i] = list.get(i);
|
||||
return array;
|
||||
}
|
||||
|
||||
protected String[][][] to3DArray(List<String[][]> list) {
|
||||
int n = list.size();
|
||||
String[][][] array = new String[n][][];
|
||||
for (int i = 0; i < n; i++)
|
||||
array[i] = list.get(i);
|
||||
return array;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,183 @@
|
|||
package com.itextpdf.text.zugferd.profiles;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public interface ComfortProfile extends BasicProfile {
|
||||
String[] getNotesCodes();
|
||||
|
||||
String getBuyerReference();
|
||||
|
||||
String getSellerID();
|
||||
|
||||
String[] getSellerGlobalID();
|
||||
|
||||
String[] getSellerGlobalSchemeID();
|
||||
|
||||
String getBuyerID();
|
||||
|
||||
String[] getBuyerGlobalID();
|
||||
|
||||
String[] getBuyerGlobalSchemeID();
|
||||
|
||||
Date getBuyerOrderReferencedDocumentIssueDateTime();
|
||||
|
||||
String getBuyerOrderReferencedDocumentIssueDateTimeFormat();
|
||||
|
||||
String getBuyerOrderReferencedDocumentID();
|
||||
|
||||
Date getContractReferencedDocumentIssueDateTime();
|
||||
|
||||
String getContractReferencedDocumentIssueDateTimeFormat();
|
||||
|
||||
String getContractReferencedDocumentID();
|
||||
|
||||
Date getCustomerOrderReferencedDocumentIssueDateTime();
|
||||
|
||||
String getCustomerOrderReferencedDocumentIssueDateTimeFormat();
|
||||
|
||||
String getCustomerOrderReferencedDocumentID();
|
||||
|
||||
Date getDeliveryNoteReferencedDocumentIssueDateTime();
|
||||
|
||||
String getDeliveryNoteReferencedDocumentIssueDateTimeFormat();
|
||||
|
||||
String getDeliveryNoteReferencedDocumentID();
|
||||
|
||||
String getInvoiceeID();
|
||||
|
||||
String[] getInvoiceeGlobalID();
|
||||
|
||||
String[] getInvoiceeGlobalSchemeID();
|
||||
|
||||
String getInvoiceeName();
|
||||
|
||||
String getInvoiceePostcode();
|
||||
|
||||
String getInvoiceeLineOne();
|
||||
|
||||
String getInvoiceeLineTwo();
|
||||
|
||||
String getInvoiceeCityName();
|
||||
|
||||
String getInvoiceeCountryID();
|
||||
|
||||
String[] getInvoiceeTaxRegistrationID();
|
||||
|
||||
String[] getInvoiceeTaxRegistrationSchemeID();
|
||||
|
||||
String[] getPaymentMeansTypeCode();
|
||||
|
||||
String[][] getPaymentMeansInformation();
|
||||
|
||||
String[] getPaymentMeansPayerAccountIBAN();
|
||||
|
||||
String[] getPaymentMeansPayerAccountProprietaryID();
|
||||
|
||||
String[] getPaymentMeansPayerFinancialInstitutionBIC();
|
||||
|
||||
String[] getPaymentMeansPayerFinancialInstitutionGermanBankleitzahlID();
|
||||
|
||||
String[] getPaymentMeansPayerFinancialInstitutionName();
|
||||
|
||||
String[] getTaxExemptionReason();
|
||||
|
||||
String[] getTaxCategoryCode();
|
||||
|
||||
Date getBillingStartDateTime();
|
||||
|
||||
String getBillingStartDateTimeFormat();
|
||||
|
||||
Date getBillingEndDateTime();
|
||||
|
||||
String getBillingEndDateTimeFormat();
|
||||
|
||||
Boolean[] getSpecifiedTradeAllowanceChargeIndicator();
|
||||
|
||||
String[] getSpecifiedTradeAllowanceChargeActualAmount();
|
||||
|
||||
String[] getSpecifiedTradeAllowanceChargeActualAmountCurrency();
|
||||
|
||||
String[] getSpecifiedTradeAllowanceChargeReason();
|
||||
|
||||
String[][] getSpecifiedTradeAllowanceChargeTaxTypeCode();
|
||||
|
||||
String[][] getSpecifiedTradeAllowanceChargeTaxCategoryCode();
|
||||
|
||||
String[][] getSpecifiedTradeAllowanceChargeTaxApplicablePercent();
|
||||
|
||||
String[][] getSpecifiedLogisticsServiceChargeDescription();
|
||||
|
||||
String[] getSpecifiedLogisticsServiceChargeAmount();
|
||||
|
||||
String[] getSpecifiedLogisticsServiceChargeAmountCurrency();
|
||||
|
||||
String[][] getSpecifiedLogisticsServiceChargeTaxTypeCode();
|
||||
|
||||
String[][] getSpecifiedLogisticsServiceChargeTaxCategoryCode();
|
||||
|
||||
String[][] getSpecifiedLogisticsServiceChargeTaxApplicablePercent();
|
||||
|
||||
String[][] getSpecifiedTradePaymentTermsDescription();
|
||||
|
||||
Date[] getSpecifiedTradePaymentTermsDueDateTime();
|
||||
|
||||
String[] getSpecifiedTradePaymentTermsDueDateTimeFormat();
|
||||
|
||||
String getTotalPrepaidAmount();
|
||||
|
||||
String getTotalPrepaidAmountCurrencyID();
|
||||
|
||||
String getDuePayableAmount();
|
||||
|
||||
String getDuePayableAmountCurrencyID();
|
||||
|
||||
String[] getLineItemLineID();
|
||||
|
||||
String[][][] getLineItemIncludedNote();
|
||||
|
||||
String[] getLineItemGrossPriceChargeAmount();
|
||||
|
||||
String[] getLineItemGrossPriceChargeAmountCurrencyID();
|
||||
|
||||
String[] getLineItemGrossPriceBasisQuantity();
|
||||
|
||||
String[] getLineItemGrossPriceBasisQuantityCode();
|
||||
|
||||
Boolean[][] getLineItemGrossPriceTradeAllowanceChargeIndicator();
|
||||
|
||||
String[][] getLineItemGrossPriceTradeAllowanceChargeActualAmount();
|
||||
|
||||
String[][] getLineItemGrossPriceTradeAllowanceChargeActualAmountCurrencyID();
|
||||
|
||||
String[][] getLineItemGrossPriceTradeAllowanceChargeReason();
|
||||
|
||||
String[] getLineItemNetPriceChargeAmount();
|
||||
|
||||
String[] getLineItemNetPriceChargeAmountCurrencyID();
|
||||
|
||||
String[] getLineItemNetPriceBasisQuantity();
|
||||
|
||||
String[] getLineItemNetPriceBasisQuantityCode();
|
||||
|
||||
String[][] getLineItemSettlementTaxTypeCode();
|
||||
|
||||
String[][] getLineItemSettlementTaxExemptionReason();
|
||||
|
||||
String[][] getLineItemSettlementTaxCategoryCode();
|
||||
|
||||
String[][] getLineItemSettlementTaxApplicablePercent();
|
||||
|
||||
String[] getLineItemLineTotalAmount();
|
||||
|
||||
String[] getLineItemLineTotalAmountCurrencyID();
|
||||
|
||||
String[] getLineItemSpecifiedTradeProductGlobalID();
|
||||
|
||||
String[] getLineItemSpecifiedTradeProductSchemeID();
|
||||
|
||||
String[] getLineItemSpecifiedTradeProductSellerAssignedID();
|
||||
|
||||
String[] getLineItemSpecifiedTradeProductBuyerAssignedID();
|
||||
|
||||
String[] getLineItemSpecifiedTradeProductDescription();
|
||||
}
|
||||
|
|
@ -0,0 +1,760 @@
|
|||
package com.itextpdf.text.zugferd.profiles;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class ComfortProfileImp extends BasicProfileImp implements ComfortProfile {
|
||||
protected List<String> notesCodes = new ArrayList<String>();
|
||||
|
||||
protected String buyerReference;
|
||||
|
||||
protected String sellerID;
|
||||
|
||||
protected List<String> sellerGlobalID = new ArrayList<String>();
|
||||
|
||||
protected List<String> sellerGlobalSchemeID = new ArrayList<String>();
|
||||
|
||||
protected String buyerID;
|
||||
|
||||
protected List<String> buyerGlobalID = new ArrayList<String>();
|
||||
|
||||
protected List<String> buyerGlobalSchemeID = new ArrayList<String>();
|
||||
|
||||
protected Date buyerOrderReferencedDocumentIssueDateTime;
|
||||
|
||||
protected String buyerOrderReferencedDocumentIssueDateTimeFormat;
|
||||
|
||||
protected String buyerOrderReferencedDocumentID;
|
||||
|
||||
protected Date contractReferencedDocumentIssueDateTime;
|
||||
|
||||
protected String contractReferencedDocumentIssueDateTimeFormat;
|
||||
|
||||
protected String contractReferencedDocumentID;
|
||||
|
||||
protected Date customerOrderReferencedDocumentIssueDateTime;
|
||||
|
||||
protected String customerOrderReferencedDocumentIssueDateTimeFormat;
|
||||
|
||||
protected String customerOrderReferencedDocumentID;
|
||||
|
||||
protected Date deliveryNoteReferencedDocumentIssueDateTime;
|
||||
|
||||
protected String deliveryNoteReferencedDocumentIssueDateTimeFormat;
|
||||
|
||||
protected String deliveryNoteReferencedDocumentID;
|
||||
|
||||
protected String invoiceeID;
|
||||
|
||||
protected List<String> invoiceeGlobalID = new ArrayList<String>();
|
||||
|
||||
protected List<String> invoiceeGlobalSchemeID = new ArrayList<String>();
|
||||
|
||||
protected String invoiceeName;
|
||||
|
||||
protected String invoiceePostcode;
|
||||
|
||||
protected String invoiceeLineOne;
|
||||
|
||||
protected String invoiceeLineTwo;
|
||||
|
||||
protected String invoiceeCityName;
|
||||
|
||||
protected String invoiceeCountryID;
|
||||
|
||||
protected List<String> invoiceeTaxRegistrationID = new ArrayList<String>();
|
||||
|
||||
protected List<String> invoiceeTaxRegistrationSchemeID = new ArrayList<String>();
|
||||
|
||||
protected List<String> paymentMeansTypeCode = new ArrayList<String>();
|
||||
|
||||
protected List<String[]> paymentMeansInformation = new ArrayList<String[]>();
|
||||
|
||||
protected List<String> paymentMeansPayerAccountIBAN = new ArrayList<String>();
|
||||
|
||||
protected List<String> paymentMeansPayerAccountProprietaryID = new ArrayList<String>();
|
||||
|
||||
protected List<String> paymentMeansPayerFinancialInstitutionBIC = new ArrayList<String>();
|
||||
|
||||
protected List<String> paymentMeansPayerFinancialInstitutionGermanBankleitzahlID = new ArrayList<String>();
|
||||
|
||||
protected List<String> paymentMeansPayerFinancialInstitutionName = new ArrayList<String>();
|
||||
|
||||
protected List<String> taxExemptionReason = new ArrayList<String>();
|
||||
|
||||
protected List<String> taxCategoryCode = new ArrayList<String>();
|
||||
|
||||
protected Date billingStartDateTime;
|
||||
|
||||
protected String billingStartDateTimeFormat;
|
||||
|
||||
protected Date billingEndDateTime;
|
||||
|
||||
protected String billingEndDateTimeFormat;
|
||||
|
||||
protected List<Boolean> tradeAllowanceChargeIndicator = new ArrayList<Boolean>();
|
||||
|
||||
protected List<String> tradeAllowanceChargeActualAmount = new ArrayList<String>();
|
||||
|
||||
protected List<String> tradeAllowanceChargeActualAmountCurrency = new ArrayList<String>();
|
||||
|
||||
protected List<String> tradeAllowanceChargeReason = new ArrayList<String>();
|
||||
|
||||
protected List<String[]> tradeAllowanceChargeTaxTypeCode = new ArrayList<String[]>();
|
||||
|
||||
protected List<String[]> tradeAllowanceChargeTaxCategoryCode = new ArrayList<String[]>();
|
||||
|
||||
protected List<String[]> tradeAllowanceChargeTaxApplicablePercent = new ArrayList<String[]>();
|
||||
|
||||
protected List<String[]> logisticsServiceChargeDescription = new ArrayList<String[]>();
|
||||
|
||||
protected List<String> logisticsServiceChargeAmount = new ArrayList<String>();
|
||||
|
||||
protected List<String> logisticsServiceChargeAmountCurrency = new ArrayList<String>();
|
||||
|
||||
protected List<String[]> logisticsServiceChargeTaxTypeCode = new ArrayList<String[]>();
|
||||
|
||||
protected List<String[]> logisticsServiceChargeTaxCategoryCode = new ArrayList<String[]>();
|
||||
|
||||
protected List<String[]> logisticsServiceChargeTaxApplicablePercent = new ArrayList<String[]>();
|
||||
|
||||
protected List<String[]> tradePaymentTermsInformation = new ArrayList<String[]>();
|
||||
|
||||
protected List<Date> tradePaymentTermsDueDateTime = new ArrayList<Date>();
|
||||
|
||||
protected List<String> tradePaymentTermsDueDateTimeFormat = new ArrayList<String>();
|
||||
|
||||
protected String totalPrepaidAmount;
|
||||
|
||||
protected String totalPrepaidAmountCurrencyID;
|
||||
|
||||
protected String duePayableAmount;
|
||||
|
||||
protected String duePayableAmountCurrencyID;
|
||||
|
||||
protected List<String> lineItemLineID = new ArrayList<String>();
|
||||
|
||||
protected List<String[][]> lineItemIncludedNote = new ArrayList<String[][]>();
|
||||
|
||||
protected List<String> lineItemGrossPriceChargeAmount = new ArrayList<String>();
|
||||
|
||||
protected List<String> lineItemGrossPriceChargeAmountCurrencyID = new ArrayList<String>();
|
||||
|
||||
protected List<String> lineItemGrossPriceBasisQuantity = new ArrayList<String>();
|
||||
|
||||
protected List<String> lineItemGrossPriceBasisQuantityCode = new ArrayList<String>();
|
||||
|
||||
protected List<Boolean[]> lineItemGrossPriceTradeAllowanceChargeIndicator = new ArrayList<Boolean[]>();
|
||||
|
||||
protected List<String[]> lineItemGrossPriceTradeAllowanceChargeActualAmount = new ArrayList<String[]>();
|
||||
|
||||
protected List<String[]> lineItemGrossPriceTradeAllowanceChargeActualAmountCurrencyID = new ArrayList<String[]>();
|
||||
|
||||
protected List<String[]> lineItemGrossPriceTradeAllowanceChargeReason = new ArrayList<String[]>();
|
||||
|
||||
protected List<String> lineItemNetPriceChargeAmount = new ArrayList<String>();
|
||||
|
||||
protected List<String> lineItemNetPriceChargeAmountCurrencyID = new ArrayList<String>();
|
||||
|
||||
protected List<String> lineItemNetPriceBasisQuantity = new ArrayList<String>();
|
||||
|
||||
protected List<String> lineItemNetPriceBasisQuantityCode = new ArrayList<String>();
|
||||
|
||||
protected List<String[]> lineItemSettlementTaxTypeCode = new ArrayList<String[]>();
|
||||
|
||||
protected List<String[]> lineItemSettlementTaxExemptionReason = new ArrayList<String[]>();
|
||||
|
||||
protected List<String[]> lineItemSettlementTaxCategoryCode = new ArrayList<String[]>();
|
||||
|
||||
protected List<String[]> lineItemSettlementTaxApplicablePercent = new ArrayList<String[]>();
|
||||
|
||||
protected List<String> lineItemLineTotalAmount = new ArrayList<String>();
|
||||
|
||||
protected List<String> lineItemLineTotalAmountCurrencyID = new ArrayList<String>();
|
||||
|
||||
protected List<String> lineItemSpecifiedTradeProductGlobalID = new ArrayList<String>();
|
||||
|
||||
protected List<String> lineItemSpecifiedTradeProductSchemeID = new ArrayList<String>();
|
||||
|
||||
protected List<String> lineItemSpecifiedTradeProductSellerAssignedID = new ArrayList<String>();
|
||||
|
||||
protected List<String> lineItemSpecifiedTradeProductBuyerAssignedID = new ArrayList<String>();
|
||||
|
||||
protected List<String> lineItemSpecifiedTradeProductDescription = new ArrayList<String>();
|
||||
|
||||
public String[] getNotesCodes() {
|
||||
return to1DArray(this.notesCodes);
|
||||
}
|
||||
|
||||
public String getBuyerReference() {
|
||||
return this.buyerReference;
|
||||
}
|
||||
|
||||
public String getSellerID() {
|
||||
return this.sellerID;
|
||||
}
|
||||
|
||||
public String[] getSellerGlobalID() {
|
||||
return to1DArray(this.sellerGlobalID);
|
||||
}
|
||||
|
||||
public String[] getSellerGlobalSchemeID() {
|
||||
return to1DArray(this.sellerGlobalSchemeID);
|
||||
}
|
||||
|
||||
public String getBuyerID() {
|
||||
return this.buyerID;
|
||||
}
|
||||
|
||||
public String[] getBuyerGlobalID() {
|
||||
return to1DArray(this.buyerGlobalID);
|
||||
}
|
||||
|
||||
public String[] getBuyerGlobalSchemeID() {
|
||||
return to1DArray(this.buyerGlobalSchemeID);
|
||||
}
|
||||
|
||||
public Date getBuyerOrderReferencedDocumentIssueDateTime() {
|
||||
return this.buyerOrderReferencedDocumentIssueDateTime;
|
||||
}
|
||||
|
||||
public String getBuyerOrderReferencedDocumentIssueDateTimeFormat() {
|
||||
return this.buyerOrderReferencedDocumentIssueDateTimeFormat;
|
||||
}
|
||||
|
||||
public String getBuyerOrderReferencedDocumentID() {
|
||||
return this.buyerOrderReferencedDocumentID;
|
||||
}
|
||||
|
||||
public Date getContractReferencedDocumentIssueDateTime() {
|
||||
return this.contractReferencedDocumentIssueDateTime;
|
||||
}
|
||||
|
||||
public String getContractReferencedDocumentIssueDateTimeFormat() {
|
||||
return this.contractReferencedDocumentIssueDateTimeFormat;
|
||||
}
|
||||
|
||||
public String getContractReferencedDocumentID() {
|
||||
return this.contractReferencedDocumentID;
|
||||
}
|
||||
|
||||
public Date getCustomerOrderReferencedDocumentIssueDateTime() {
|
||||
return this.customerOrderReferencedDocumentIssueDateTime;
|
||||
}
|
||||
|
||||
public String getCustomerOrderReferencedDocumentIssueDateTimeFormat() {
|
||||
return this.customerOrderReferencedDocumentIssueDateTimeFormat;
|
||||
}
|
||||
|
||||
public String getCustomerOrderReferencedDocumentID() {
|
||||
return this.customerOrderReferencedDocumentID;
|
||||
}
|
||||
|
||||
public Date getDeliveryNoteReferencedDocumentIssueDateTime() {
|
||||
return this.deliveryNoteReferencedDocumentIssueDateTime;
|
||||
}
|
||||
|
||||
public String getDeliveryNoteReferencedDocumentIssueDateTimeFormat() {
|
||||
return this.deliveryNoteReferencedDocumentIssueDateTimeFormat;
|
||||
}
|
||||
|
||||
public String getDeliveryNoteReferencedDocumentID() {
|
||||
return this.deliveryNoteReferencedDocumentID;
|
||||
}
|
||||
|
||||
public String getInvoiceeID() {
|
||||
return this.invoiceeID;
|
||||
}
|
||||
|
||||
public String[] getInvoiceeGlobalID() {
|
||||
return to1DArray(this.invoiceeGlobalID);
|
||||
}
|
||||
|
||||
public String[] getInvoiceeGlobalSchemeID() {
|
||||
return to1DArray(this.invoiceeGlobalSchemeID);
|
||||
}
|
||||
|
||||
public String getInvoiceeName() {
|
||||
return this.invoiceeName;
|
||||
}
|
||||
|
||||
public String getInvoiceePostcode() {
|
||||
return this.invoiceePostcode;
|
||||
}
|
||||
|
||||
public String getInvoiceeLineOne() {
|
||||
return this.invoiceeLineOne;
|
||||
}
|
||||
|
||||
public String getInvoiceeLineTwo() {
|
||||
return this.invoiceeLineTwo;
|
||||
}
|
||||
|
||||
public String getInvoiceeCityName() {
|
||||
return this.invoiceeCityName;
|
||||
}
|
||||
|
||||
public String getInvoiceeCountryID() {
|
||||
return this.invoiceeCountryID;
|
||||
}
|
||||
|
||||
public String[] getInvoiceeTaxRegistrationID() {
|
||||
return to1DArray(this.invoiceeTaxRegistrationID);
|
||||
}
|
||||
|
||||
public String[] getInvoiceeTaxRegistrationSchemeID() {
|
||||
return to1DArray(this.invoiceeTaxRegistrationSchemeID);
|
||||
}
|
||||
|
||||
public String[] getPaymentMeansTypeCode() {
|
||||
return to1DArray(this.paymentMeansTypeCode);
|
||||
}
|
||||
|
||||
public String[][] getPaymentMeansInformation() {
|
||||
return to2DArray(this.paymentMeansInformation);
|
||||
}
|
||||
|
||||
public String[] getPaymentMeansPayerAccountIBAN() {
|
||||
return to1DArray(this.paymentMeansPayerAccountIBAN);
|
||||
}
|
||||
|
||||
public String[] getPaymentMeansPayerAccountProprietaryID() {
|
||||
return to1DArray(this.paymentMeansPayerAccountProprietaryID);
|
||||
}
|
||||
|
||||
public String[] getPaymentMeansPayerFinancialInstitutionBIC() {
|
||||
return to1DArray(this.paymentMeansPayerFinancialInstitutionBIC);
|
||||
}
|
||||
|
||||
public String[] getPaymentMeansPayerFinancialInstitutionGermanBankleitzahlID() {
|
||||
return to1DArray(this.paymentMeansPayerFinancialInstitutionGermanBankleitzahlID);
|
||||
}
|
||||
|
||||
public String[] getPaymentMeansPayerFinancialInstitutionName() {
|
||||
return to1DArray(this.paymentMeansPayerFinancialInstitutionName);
|
||||
}
|
||||
|
||||
public String[] getTaxExemptionReason() {
|
||||
return to1DArray(this.taxExemptionReason);
|
||||
}
|
||||
|
||||
public String[] getTaxCategoryCode() {
|
||||
return to1DArray(this.taxCategoryCode);
|
||||
}
|
||||
|
||||
public Date getBillingStartDateTime() {
|
||||
return this.billingStartDateTime;
|
||||
}
|
||||
|
||||
public String getBillingStartDateTimeFormat() {
|
||||
return this.billingStartDateTimeFormat;
|
||||
}
|
||||
|
||||
public Date getBillingEndDateTime() {
|
||||
return this.billingEndDateTime;
|
||||
}
|
||||
|
||||
public String getBillingEndDateTimeFormat() {
|
||||
return this.billingEndDateTimeFormat;
|
||||
}
|
||||
|
||||
public Boolean[] getSpecifiedTradeAllowanceChargeIndicator() {
|
||||
return to1DArrayB(this.tradeAllowanceChargeIndicator);
|
||||
}
|
||||
|
||||
public String[] getSpecifiedTradeAllowanceChargeActualAmount() {
|
||||
return to1DArray(this.tradeAllowanceChargeActualAmount);
|
||||
}
|
||||
|
||||
public String[] getSpecifiedTradeAllowanceChargeActualAmountCurrency() {
|
||||
return to1DArray(this.tradeAllowanceChargeActualAmountCurrency);
|
||||
}
|
||||
|
||||
public String[] getSpecifiedTradeAllowanceChargeReason() {
|
||||
return to1DArray(this.tradeAllowanceChargeReason);
|
||||
}
|
||||
|
||||
public String[][] getSpecifiedTradeAllowanceChargeTaxTypeCode() {
|
||||
return to2DArray(this.tradeAllowanceChargeTaxTypeCode);
|
||||
}
|
||||
|
||||
public String[][] getSpecifiedTradeAllowanceChargeTaxCategoryCode() {
|
||||
return to2DArray(this.tradeAllowanceChargeTaxCategoryCode);
|
||||
}
|
||||
|
||||
public String[][] getSpecifiedTradeAllowanceChargeTaxApplicablePercent() {
|
||||
return to2DArray(this.tradeAllowanceChargeTaxApplicablePercent);
|
||||
}
|
||||
|
||||
public String[][] getSpecifiedLogisticsServiceChargeDescription() {
|
||||
return to2DArray(this.logisticsServiceChargeDescription);
|
||||
}
|
||||
|
||||
public String[] getSpecifiedLogisticsServiceChargeAmount() {
|
||||
return to1DArray(this.logisticsServiceChargeAmount);
|
||||
}
|
||||
|
||||
public String[] getSpecifiedLogisticsServiceChargeAmountCurrency() {
|
||||
return to1DArray(this.logisticsServiceChargeAmountCurrency);
|
||||
}
|
||||
|
||||
public String[][] getSpecifiedLogisticsServiceChargeTaxTypeCode() {
|
||||
return to2DArray(this.logisticsServiceChargeTaxTypeCode);
|
||||
}
|
||||
|
||||
public String[][] getSpecifiedLogisticsServiceChargeTaxCategoryCode() {
|
||||
return to2DArray(this.logisticsServiceChargeTaxCategoryCode);
|
||||
}
|
||||
|
||||
public String[][] getSpecifiedLogisticsServiceChargeTaxApplicablePercent() {
|
||||
return to2DArray(this.logisticsServiceChargeTaxApplicablePercent);
|
||||
}
|
||||
|
||||
public String[][] getSpecifiedTradePaymentTermsDescription() {
|
||||
return to2DArray(this.tradePaymentTermsInformation);
|
||||
}
|
||||
|
||||
public Date[] getSpecifiedTradePaymentTermsDueDateTime() {
|
||||
return this.tradePaymentTermsDueDateTime.<Date>toArray(new Date[this.tradePaymentTermsDueDateTime.size()]);
|
||||
}
|
||||
|
||||
public String[] getSpecifiedTradePaymentTermsDueDateTimeFormat() {
|
||||
return to1DArray(this.tradePaymentTermsDueDateTimeFormat);
|
||||
}
|
||||
|
||||
public String getTotalPrepaidAmount() {
|
||||
return this.totalPrepaidAmount;
|
||||
}
|
||||
|
||||
public String getTotalPrepaidAmountCurrencyID() {
|
||||
return this.totalPrepaidAmountCurrencyID;
|
||||
}
|
||||
|
||||
public String getDuePayableAmount() {
|
||||
return this.duePayableAmount;
|
||||
}
|
||||
|
||||
public String getDuePayableAmountCurrencyID() {
|
||||
return this.duePayableAmountCurrencyID;
|
||||
}
|
||||
|
||||
public String[] getLineItemLineID() {
|
||||
return to1DArray(this.lineItemLineID);
|
||||
}
|
||||
|
||||
public String[][][] getLineItemIncludedNote() {
|
||||
return to3DArray(this.lineItemIncludedNote);
|
||||
}
|
||||
|
||||
public String[] getLineItemGrossPriceChargeAmount() {
|
||||
return to1DArray(this.lineItemGrossPriceChargeAmount);
|
||||
}
|
||||
|
||||
public String[] getLineItemGrossPriceChargeAmountCurrencyID() {
|
||||
return to1DArray(this.lineItemGrossPriceChargeAmountCurrencyID);
|
||||
}
|
||||
|
||||
public String[] getLineItemGrossPriceBasisQuantity() {
|
||||
return to1DArray(this.lineItemGrossPriceBasisQuantity);
|
||||
}
|
||||
|
||||
public String[] getLineItemGrossPriceBasisQuantityCode() {
|
||||
return to1DArray(this.lineItemGrossPriceBasisQuantityCode);
|
||||
}
|
||||
|
||||
public Boolean[][] getLineItemGrossPriceTradeAllowanceChargeIndicator() {
|
||||
return to2DArrayB(this.lineItemGrossPriceTradeAllowanceChargeIndicator);
|
||||
}
|
||||
|
||||
public String[][] getLineItemGrossPriceTradeAllowanceChargeActualAmount() {
|
||||
return to2DArray(this.lineItemGrossPriceTradeAllowanceChargeActualAmount);
|
||||
}
|
||||
|
||||
public String[][] getLineItemGrossPriceTradeAllowanceChargeActualAmountCurrencyID() {
|
||||
return to2DArray(this.lineItemGrossPriceTradeAllowanceChargeActualAmountCurrencyID);
|
||||
}
|
||||
|
||||
public String[][] getLineItemGrossPriceTradeAllowanceChargeReason() {
|
||||
return to2DArray(this.lineItemGrossPriceTradeAllowanceChargeReason);
|
||||
}
|
||||
|
||||
public String[] getLineItemNetPriceChargeAmount() {
|
||||
return to1DArray(this.lineItemNetPriceChargeAmount);
|
||||
}
|
||||
|
||||
public String[] getLineItemNetPriceChargeAmountCurrencyID() {
|
||||
return to1DArray(this.lineItemNetPriceChargeAmountCurrencyID);
|
||||
}
|
||||
|
||||
public String[] getLineItemNetPriceBasisQuantity() {
|
||||
return to1DArray(this.lineItemNetPriceBasisQuantity);
|
||||
}
|
||||
|
||||
public String[] getLineItemNetPriceBasisQuantityCode() {
|
||||
return to1DArray(this.lineItemNetPriceBasisQuantityCode);
|
||||
}
|
||||
|
||||
public String[][] getLineItemSettlementTaxTypeCode() {
|
||||
return to2DArray(this.lineItemSettlementTaxTypeCode);
|
||||
}
|
||||
|
||||
public String[][] getLineItemSettlementTaxExemptionReason() {
|
||||
return to2DArray(this.lineItemSettlementTaxExemptionReason);
|
||||
}
|
||||
|
||||
public String[][] getLineItemSettlementTaxCategoryCode() {
|
||||
return to2DArray(this.lineItemSettlementTaxCategoryCode);
|
||||
}
|
||||
|
||||
public String[][] getLineItemSettlementTaxApplicablePercent() {
|
||||
return to2DArray(this.lineItemSettlementTaxApplicablePercent);
|
||||
}
|
||||
|
||||
public String[] getLineItemLineTotalAmount() {
|
||||
return to1DArray(this.lineItemLineTotalAmount);
|
||||
}
|
||||
|
||||
public String[] getLineItemLineTotalAmountCurrencyID() {
|
||||
return to1DArray(this.lineItemLineTotalAmountCurrencyID);
|
||||
}
|
||||
|
||||
public String[] getLineItemSpecifiedTradeProductGlobalID() {
|
||||
return to1DArray(this.lineItemSpecifiedTradeProductGlobalID);
|
||||
}
|
||||
|
||||
public String[] getLineItemSpecifiedTradeProductSchemeID() {
|
||||
return to1DArray(this.lineItemSpecifiedTradeProductSchemeID);
|
||||
}
|
||||
|
||||
public String[] getLineItemSpecifiedTradeProductSellerAssignedID() {
|
||||
return to1DArray(this.lineItemSpecifiedTradeProductSellerAssignedID);
|
||||
}
|
||||
|
||||
public String[] getLineItemSpecifiedTradeProductBuyerAssignedID() {
|
||||
return to1DArray(this.lineItemSpecifiedTradeProductBuyerAssignedID);
|
||||
}
|
||||
|
||||
public String[] getLineItemSpecifiedTradeProductDescription() {
|
||||
return to1DArray(this.lineItemSpecifiedTradeProductDescription);
|
||||
}
|
||||
|
||||
public void addNote(String[] note) {
|
||||
throw new UnsupportedOperationException("This method can only be used for the BASIC level.");
|
||||
}
|
||||
|
||||
public void addNote(String[] note, String code) {
|
||||
this.notes.add(note);
|
||||
this.notesCodes.add(code);
|
||||
}
|
||||
|
||||
public void setBuyerReference(String buyerReference) {
|
||||
this.buyerReference = buyerReference;
|
||||
}
|
||||
|
||||
public void setSellerID(String sellerID) {
|
||||
this.sellerID = sellerID;
|
||||
}
|
||||
|
||||
public void addSellerGlobalID(String sellerGlobalSchemeID, String sellerGlobalID) {
|
||||
this.sellerGlobalID.add(sellerGlobalID);
|
||||
this.sellerGlobalSchemeID.add(sellerGlobalSchemeID);
|
||||
}
|
||||
|
||||
public void setBuyerID(String buyerID) {
|
||||
this.buyerID = buyerID;
|
||||
}
|
||||
|
||||
public void addBuyerGlobalID(String buyerGlobalSchemeID, String buyerGlobalID) {
|
||||
this.buyerGlobalID.add(buyerGlobalID);
|
||||
this.buyerGlobalSchemeID.add(buyerGlobalSchemeID);
|
||||
}
|
||||
|
||||
public void setBuyerOrderReferencedDocumentIssueDateTime(Date buyerOrderReferencedDocumentIssueDateTime, String buyerOrderReferencedDocumentIssueDateTimeFormat) {
|
||||
this.buyerOrderReferencedDocumentIssueDateTime = buyerOrderReferencedDocumentIssueDateTime;
|
||||
this.buyerOrderReferencedDocumentIssueDateTimeFormat = buyerOrderReferencedDocumentIssueDateTimeFormat;
|
||||
}
|
||||
|
||||
public void setBuyerOrderReferencedDocumentID(String buyerOrderReferencedDocumentID) {
|
||||
this.buyerOrderReferencedDocumentID = buyerOrderReferencedDocumentID;
|
||||
}
|
||||
|
||||
public void setContractReferencedDocumentIssueDateTime(Date contractReferencedDocumentIssueDateTime, String contractReferencedDocumentIssueDateTimeFormat) {
|
||||
this.contractReferencedDocumentIssueDateTime = contractReferencedDocumentIssueDateTime;
|
||||
this.contractReferencedDocumentIssueDateTimeFormat = contractReferencedDocumentIssueDateTimeFormat;
|
||||
}
|
||||
|
||||
public void setContractReferencedDocumentID(String contractReferencedDocumentID) {
|
||||
this.contractReferencedDocumentID = contractReferencedDocumentID;
|
||||
}
|
||||
|
||||
public void setCustomerOrderReferencedDocumentIssueDateTime(Date customerOrderReferencedDocumentIssueDateTime, String customerOrderReferencedDocumentIssueDateTimeFormat) {
|
||||
this.customerOrderReferencedDocumentIssueDateTime = customerOrderReferencedDocumentIssueDateTime;
|
||||
this.customerOrderReferencedDocumentIssueDateTimeFormat = customerOrderReferencedDocumentIssueDateTimeFormat;
|
||||
}
|
||||
|
||||
public void setCustomerOrderReferencedDocumentID(String customerOrderReferencedDocumentID) {
|
||||
this.customerOrderReferencedDocumentID = customerOrderReferencedDocumentID;
|
||||
}
|
||||
|
||||
public void setDeliveryNoteReferencedDocumentIssueDateTime(Date deliveryNoteReferencedDocumentIssueDateTime, String deliveryNoteReferencedDocumentIssueDateTimeFormat) {
|
||||
this.deliveryNoteReferencedDocumentIssueDateTime = deliveryNoteReferencedDocumentIssueDateTime;
|
||||
this.deliveryNoteReferencedDocumentIssueDateTimeFormat = deliveryNoteReferencedDocumentIssueDateTimeFormat;
|
||||
}
|
||||
|
||||
public void setDeliveryNoteReferencedDocumentID(String deliveryNoteReferencedDocumentID) {
|
||||
this.deliveryNoteReferencedDocumentID = deliveryNoteReferencedDocumentID;
|
||||
}
|
||||
|
||||
public void setInvoiceeID(String invoiceeID) {
|
||||
this.invoiceeID = invoiceeID;
|
||||
}
|
||||
|
||||
public void addInvoiceeGlobalID(String invoiceeGlobalSchemeID, String invoiceeGlobalID) {
|
||||
this.invoiceeGlobalSchemeID.add(invoiceeGlobalSchemeID);
|
||||
this.invoiceeGlobalID.add(invoiceeGlobalID);
|
||||
}
|
||||
|
||||
public void setInvoiceeName(String invoiceeName) {
|
||||
this.invoiceeName = invoiceeName;
|
||||
}
|
||||
|
||||
public void setInvoiceePostcode(String invoiceePostcode) {
|
||||
this.invoiceePostcode = invoiceePostcode;
|
||||
}
|
||||
|
||||
public void setInvoiceeLineOne(String invoiceeLineOne) {
|
||||
this.invoiceeLineOne = invoiceeLineOne;
|
||||
}
|
||||
|
||||
public void setInvoiceeLineTwo(String invoiceeLineTwo) {
|
||||
this.invoiceeLineTwo = invoiceeLineTwo;
|
||||
}
|
||||
|
||||
public void setInvoiceeCityName(String invoiceeCityName) {
|
||||
this.invoiceeCityName = invoiceeCityName;
|
||||
}
|
||||
|
||||
public void setInvoiceeCountryID(String invoiceeCountryID) {
|
||||
this.invoiceeCountryID = invoiceeCountryID;
|
||||
}
|
||||
|
||||
public void addInvoiceeTaxRegistration(String schemeID, String taxId) {
|
||||
this.invoiceeTaxRegistrationSchemeID.add(schemeID);
|
||||
this.invoiceeTaxRegistrationID.add(taxId);
|
||||
}
|
||||
|
||||
public void addPaymentMeans(String schemeAgencyID, String id, String iban, String accountname, String proprietaryID, String bic, String germanBankleitzahlID, String institutionname) {
|
||||
throw new UnsupportedOperationException("This method can only be used for the BASIC level.");
|
||||
}
|
||||
|
||||
public void addPaymentMeans(String typeCode, String[] information, String schemeAgencyID, String id, String ibanDebtor, String proprietaryIDDebtor, String ibanCreditor, String accountnameCreditor, String proprietaryIDCreditor, String bicDebtor, String germanBankleitzahlIDDebtor, String institutionnameDebtor, String bicCreditor, String germanBankleitzahlIDCreditor, String institutionnameCreditor) {
|
||||
this.paymentMeansTypeCode.add(typeCode);
|
||||
this.paymentMeansInformation.add(information);
|
||||
this.paymentMeansID.add(id);
|
||||
this.paymentMeansSchemeAgencyID.add(schemeAgencyID);
|
||||
this.paymentMeansPayerAccountIBAN.add(ibanDebtor);
|
||||
this.paymentMeansPayerAccountProprietaryID.add(proprietaryIDDebtor);
|
||||
this.paymentMeansPayeeAccountIBAN.add(ibanCreditor);
|
||||
this.paymentMeansPayeeAccountName.add(accountnameCreditor);
|
||||
this.paymentMeansPayeeAccountProprietaryID.add(proprietaryIDCreditor);
|
||||
this.paymentMeansPayerFinancialInstitutionBIC.add(bicDebtor);
|
||||
this.paymentMeansPayerFinancialInstitutionGermanBankleitzahlID.add(germanBankleitzahlIDDebtor);
|
||||
this.paymentMeansPayerFinancialInstitutionName.add(institutionnameDebtor);
|
||||
this.paymentMeansPayeeFinancialInstitutionBIC.add(bicCreditor);
|
||||
this.paymentMeansPayeeFinancialInstitutionGermanBankleitzahlID.add(germanBankleitzahlIDCreditor);
|
||||
this.paymentMeansPayeeFinancialInstitutionName.add(institutionnameCreditor);
|
||||
}
|
||||
|
||||
public void addApplicableTradeTax(String calculatedAmount, String calculatedAmountCurrencyID, String typeCode, String basisAmount, String basisAmountCurrencyID, String applicablePercent) {
|
||||
throw new UnsupportedOperationException("This method can only be used for the BASIC level.");
|
||||
}
|
||||
|
||||
public void addApplicableTradeTax(String calculatedAmount, String calculatedAmountCurrencyID, String typeCode, String exemptionReason, String basisAmount, String basisAmountCurrencyID, String categoryCode, String applicablePercent) {
|
||||
this.taxCalculatedAmount.add(calculatedAmount);
|
||||
this.taxCalculatedAmountCurrencyID.add(calculatedAmountCurrencyID);
|
||||
this.taxTypeCode.add(typeCode);
|
||||
this.taxExemptionReason.add(exemptionReason);
|
||||
this.taxBasisAmount.add(basisAmount);
|
||||
this.taxBasisAmountCurrencyID.add(basisAmountCurrencyID);
|
||||
this.taxCategoryCode.add(categoryCode);
|
||||
this.taxApplicablePercent.add(applicablePercent);
|
||||
}
|
||||
|
||||
public void setBillingStartEnd(Date billingStartDateTime, String billingStartDateTimeFormat, Date billingEndDateTime, String billingEndDateTimeFormat) {
|
||||
this.billingStartDateTime = billingStartDateTime;
|
||||
this.billingStartDateTimeFormat = billingStartDateTimeFormat;
|
||||
this.billingEndDateTime = billingEndDateTime;
|
||||
this.billingEndDateTimeFormat = billingEndDateTimeFormat;
|
||||
}
|
||||
|
||||
public void addSpecifiedTradeAllowanceCharge(boolean indicator, String actualAmount, String actualAmountCurrency, String reason, String[] typeCodes, String[] categoryCodes, String[] applicablePercent) {
|
||||
this.tradeAllowanceChargeIndicator.add(Boolean.valueOf(indicator));
|
||||
this.tradeAllowanceChargeActualAmount.add(actualAmount);
|
||||
this.tradeAllowanceChargeActualAmountCurrency.add(actualAmountCurrency);
|
||||
this.tradeAllowanceChargeReason.add(reason);
|
||||
this.tradeAllowanceChargeTaxTypeCode.add(typeCodes);
|
||||
this.tradeAllowanceChargeTaxCategoryCode.add(categoryCodes);
|
||||
this.tradeAllowanceChargeTaxApplicablePercent.add(applicablePercent);
|
||||
}
|
||||
|
||||
public void addSpecifiedLogisticsServiceCharge(String[] description, String actualAmount, String actualAmountCurrency, String[] typeCodes, String[] categoryCodes, String[] applicablePercent) {
|
||||
this.logisticsServiceChargeDescription.add(description);
|
||||
this.logisticsServiceChargeAmount.add(actualAmount);
|
||||
this.logisticsServiceChargeAmountCurrency.add(actualAmountCurrency);
|
||||
this.logisticsServiceChargeTaxTypeCode.add(typeCodes);
|
||||
this.logisticsServiceChargeTaxCategoryCode.add(categoryCodes);
|
||||
this.logisticsServiceChargeTaxApplicablePercent.add(applicablePercent);
|
||||
}
|
||||
|
||||
public void addSpecifiedTradePaymentTerms(String[] information, Date dateTime, String dateTimeFormat) {
|
||||
this.tradePaymentTermsInformation.add(information);
|
||||
this.tradePaymentTermsDueDateTime.add(dateTime);
|
||||
this.tradePaymentTermsDueDateTimeFormat.add(dateTimeFormat);
|
||||
}
|
||||
|
||||
public void setTotalPrepaidAmount(String totalPrepaidAmount, String totalPrepaidCurrencyID) {
|
||||
this.totalPrepaidAmount = totalPrepaidAmount;
|
||||
this.totalPrepaidAmountCurrencyID = totalPrepaidCurrencyID;
|
||||
}
|
||||
|
||||
public void setDuePayableAmount(String duePayableAmount, String duePayableAmountCurrencyID) {
|
||||
this.duePayableAmount = duePayableAmount;
|
||||
this.duePayableAmountCurrencyID = duePayableAmountCurrencyID;
|
||||
}
|
||||
|
||||
public void addIncludedSupplyChainTradeLineItem(String billedQuantity, String billedQuantityUnitCode, String specifiedTradeProductName) {
|
||||
throw new UnsupportedOperationException("This method can only be used for the BASIC level.");
|
||||
}
|
||||
|
||||
public void addIncludedSupplyChainTradeLineItem(String id, String[][] notes, String grossPriceChargeAmount, String grossPriceChargeAmountCurrencyID, String grossPriceBasisQuantity, String grossPriceBasisQuantityCode, Boolean[] grossPriceTradeAllowanceChargeIndicator, String[] grossPriceTradeAllowanceChargeActualAmount, String[] grossPriceTradeAllowanceChargeActualAmountCurrencyID, String[] grossPriceTradeAllowanceChargeReason, String netPriceChargeAmount, String netPriceChargeAmountCurrencyID, String netPriceBasisQuantity, String netPriceBasisQuantityCode, String billedQuantity, String billedQuantityUnitCode, String[] lineItemSettlementTaxTypeCode, String[] lineItemSettlementTaxExemptionReason, String[] lineItemSettlementTaxCategoryCode, String[] lineItemSettlementTaxApplicablePercent, String lineItemLineTotalAmount, String lineItemLineTotalAmountCurrencyID, String lineItemSpecifiedTradeProductGlobalID, String lineItemSpecifiedTradeProductSchemeID, String lineItemSpecifiedTradeProductSellerAssignedID, String lineItemSpecifiedTradeProductBuyerAssignedID, String lineItemSpecifiedTradeProductName, String lineItemSpecifiedTradeProductDescription) {
|
||||
this.lineItemLineID.add(id);
|
||||
this.lineItemIncludedNote.add(notes);
|
||||
this.lineItemGrossPriceChargeAmount.add(grossPriceChargeAmount);
|
||||
this.lineItemGrossPriceChargeAmountCurrencyID.add(grossPriceChargeAmountCurrencyID);
|
||||
this.lineItemGrossPriceBasisQuantity.add(grossPriceBasisQuantity);
|
||||
this.lineItemGrossPriceBasisQuantityCode.add(grossPriceBasisQuantityCode);
|
||||
this.lineItemGrossPriceTradeAllowanceChargeIndicator.add(grossPriceTradeAllowanceChargeIndicator);
|
||||
this.lineItemGrossPriceTradeAllowanceChargeActualAmount.add(grossPriceTradeAllowanceChargeActualAmount);
|
||||
this.lineItemGrossPriceTradeAllowanceChargeActualAmountCurrencyID.add(grossPriceTradeAllowanceChargeActualAmountCurrencyID);
|
||||
this.lineItemGrossPriceTradeAllowanceChargeReason.add(grossPriceTradeAllowanceChargeReason);
|
||||
this.lineItemNetPriceChargeAmount.add(netPriceChargeAmount);
|
||||
this.lineItemNetPriceChargeAmountCurrencyID.add(netPriceChargeAmountCurrencyID);
|
||||
this.lineItemNetPriceBasisQuantity.add(netPriceBasisQuantity);
|
||||
this.lineItemNetPriceBasisQuantityCode.add(netPriceBasisQuantityCode);
|
||||
this.lineItemBilledQuantity.add(billedQuantity);
|
||||
this.lineItemBilledQuantityUnitCode.add(billedQuantityUnitCode);
|
||||
this.lineItemSettlementTaxTypeCode.add(lineItemSettlementTaxTypeCode);
|
||||
this.lineItemSettlementTaxExemptionReason.add(lineItemSettlementTaxExemptionReason);
|
||||
this.lineItemSettlementTaxCategoryCode.add(lineItemSettlementTaxCategoryCode);
|
||||
this.lineItemSettlementTaxApplicablePercent.add(lineItemSettlementTaxApplicablePercent);
|
||||
this.lineItemLineTotalAmount.add(lineItemLineTotalAmount);
|
||||
this.lineItemLineTotalAmountCurrencyID.add(lineItemLineTotalAmountCurrencyID);
|
||||
this.lineItemSpecifiedTradeProductGlobalID.add(lineItemSpecifiedTradeProductGlobalID);
|
||||
this.lineItemSpecifiedTradeProductSchemeID.add(lineItemSpecifiedTradeProductSchemeID);
|
||||
this.lineItemSpecifiedTradeProductSellerAssignedID.add(lineItemSpecifiedTradeProductSellerAssignedID);
|
||||
this.lineItemSpecifiedTradeProductBuyerAssignedID.add(lineItemSpecifiedTradeProductBuyerAssignedID);
|
||||
this.lineItemSpecifiedTradeProductName.add(lineItemSpecifiedTradeProductName);
|
||||
this.lineItemSpecifiedTradeProductDescription.add(lineItemSpecifiedTradeProductDescription);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,217 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rsm:CrossIndustryDocument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rsm="urn:ferd:CrossIndustryDocument:invoice:1p0" xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:12" xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:15">
|
||||
<rsm:SpecifiedExchangedDocumentContext>
|
||||
<ram:TestIndicator><udt:Indicator /></ram:TestIndicator>
|
||||
<ram:GuidelineSpecifiedDocumentContextParameter>
|
||||
<ram:ID>urn:ferd:CrossIndustryDocument:invoice:1p0:comfort</ram:ID>
|
||||
</ram:GuidelineSpecifiedDocumentContextParameter>
|
||||
</rsm:SpecifiedExchangedDocumentContext>
|
||||
<rsm:HeaderExchangedDocument>
|
||||
<ram:ID />
|
||||
<ram:Name />
|
||||
<ram:TypeCode />
|
||||
<ram:IssueDateTime><udt:DateTimeString format="" /></ram:IssueDateTime>
|
||||
<ram:IncludedNote>
|
||||
<ram:Content />
|
||||
<ram:SubjectCode />
|
||||
</ram:IncludedNote>
|
||||
</rsm:HeaderExchangedDocument>
|
||||
<rsm:SpecifiedSupplyChainTradeTransaction>
|
||||
<ram:ApplicableSupplyChainTradeAgreement>
|
||||
<ram:BuyerReference />
|
||||
<ram:SellerTradeParty>
|
||||
<ram:ID />
|
||||
<ram:GlobalID schemeID="" />
|
||||
<ram:Name />
|
||||
<ram:PostalTradeAddress>
|
||||
<ram:PostcodeCode />
|
||||
<ram:LineOne />
|
||||
<ram:LineTwo />
|
||||
<ram:CityName />
|
||||
<ram:CountryID />
|
||||
</ram:PostalTradeAddress>
|
||||
<ram:SpecifiedTaxRegistration>
|
||||
<ram:ID schemeID="" />
|
||||
</ram:SpecifiedTaxRegistration>
|
||||
</ram:SellerTradeParty>
|
||||
<ram:BuyerTradeParty>
|
||||
<ram:ID />
|
||||
<ram:GlobalID schemeID="" />
|
||||
<ram:Name />
|
||||
<ram:PostalTradeAddress>
|
||||
<ram:PostcodeCode />
|
||||
<ram:LineOne />
|
||||
<ram:LineTwo />
|
||||
<ram:CityName />
|
||||
<ram:CountryID />
|
||||
</ram:PostalTradeAddress>
|
||||
<ram:SpecifiedTaxRegistration>
|
||||
<ram:ID schemeID="" />
|
||||
</ram:SpecifiedTaxRegistration>
|
||||
</ram:BuyerTradeParty>
|
||||
<ram:BuyerOrderReferencedDocument>
|
||||
<ram:IssueDateTime format="" />
|
||||
<ram:ID />
|
||||
</ram:BuyerOrderReferencedDocument>
|
||||
<ram:ContractReferencedDocument>
|
||||
<ram:IssueDateTime format="" />
|
||||
<ram:ID />
|
||||
</ram:ContractReferencedDocument>
|
||||
<ram:CustomerOrderReferencedDocument>
|
||||
<ram:IssueDateTime format="" />
|
||||
<ram:ID />
|
||||
</ram:CustomerOrderReferencedDocument>
|
||||
</ram:ApplicableSupplyChainTradeAgreement>
|
||||
<ram:ApplicableSupplyChainTradeDelivery>
|
||||
<ram:ActualDeliverySupplyChainEvent>
|
||||
<ram:OccurrenceDateTime><udt:DateTimeString format="" /></ram:OccurrenceDateTime>
|
||||
</ram:ActualDeliverySupplyChainEvent>
|
||||
<ram:DeliveryNoteReferencedDocument>
|
||||
<ram:IssueDateTime format="" />
|
||||
<ram:ID />
|
||||
</ram:DeliveryNoteReferencedDocument>
|
||||
</ram:ApplicableSupplyChainTradeDelivery>
|
||||
<ram:ApplicableSupplyChainTradeSettlement>
|
||||
<ram:PaymentReference />
|
||||
<ram:InvoiceCurrencyCode />
|
||||
<ram:InvoiceeTradeParty>
|
||||
<ram:ID />
|
||||
<ram:GlobalID schemeID="" />
|
||||
<ram:Name />
|
||||
<ram:PostalTradeAddress>
|
||||
<ram:PostcodeCode />
|
||||
<ram:LineOne />
|
||||
<ram:LineTwo />
|
||||
<ram:CityName />
|
||||
<ram:CountryID />
|
||||
</ram:PostalTradeAddress>
|
||||
<ram:SpecifiedTaxRegistration>
|
||||
<ram:ID schemeID="" />
|
||||
</ram:SpecifiedTaxRegistration>
|
||||
</ram:InvoiceeTradeParty>
|
||||
<ram:SpecifiedTradeSettlementPaymentMeans>
|
||||
<ram:TypeCode />
|
||||
<ram:Information />
|
||||
<ram:ID schemeAgencyID="" />
|
||||
<ram:PayerPartyDebtorFinancialAccount>
|
||||
<ram:IBANID />
|
||||
<ram:ProprietaryID />
|
||||
</ram:PayerPartyDebtorFinancialAccount>
|
||||
<ram:PayeePartyCreditorFinancialAccount>
|
||||
<ram:IBANID />
|
||||
<ram:AccountName />
|
||||
<ram:ProprietaryID />
|
||||
</ram:PayeePartyCreditorFinancialAccount>
|
||||
<ram:PayerSpecifiedDebtorFinancialInstitution>
|
||||
<ram:BICID />
|
||||
<ram:GermanBankleitzahlID />
|
||||
<ram:Name />
|
||||
</ram:PayerSpecifiedDebtorFinancialInstitution>
|
||||
<ram:PayeeSpecifiedCreditorFinancialInstitution>
|
||||
<ram:BICID />
|
||||
<ram:GermanBankleitzahlID />
|
||||
<ram:Name />
|
||||
</ram:PayeeSpecifiedCreditorFinancialInstitution>
|
||||
</ram:SpecifiedTradeSettlementPaymentMeans>
|
||||
<ram:ApplicableTradeTax>
|
||||
<ram:CalculatedAmount currencyID="" />
|
||||
<ram:TypeCode />
|
||||
<ram:ExemptionReason />
|
||||
<ram:BasisAmount currencyID="" />
|
||||
<ram:CategoryCode />
|
||||
<ram:ApplicablePercent />
|
||||
</ram:ApplicableTradeTax>
|
||||
<ram:BillingSpecifiedPeriod>
|
||||
<ram:StartDateTime>
|
||||
<udt:DateTimeString format="" />
|
||||
</ram:StartDateTime>
|
||||
<ram:EndDateTime>
|
||||
<udt:DateTimeString format="" />
|
||||
</ram:EndDateTime>
|
||||
</ram:BillingSpecifiedPeriod>
|
||||
<ram:SpecifiedTradeAllowanceCharge>
|
||||
<ram:ChargeIndicator>
|
||||
<udt:Indicator />
|
||||
</ram:ChargeIndicator>
|
||||
<ram:ActualAmount currencyID="" />
|
||||
<ram:Reason />
|
||||
<ram:CategoryTradeTax>
|
||||
<ram:TypeCode />
|
||||
<ram:CategoryCode />
|
||||
<ram:ApplicablePercent />
|
||||
</ram:CategoryTradeTax>
|
||||
</ram:SpecifiedTradeAllowanceCharge>
|
||||
<ram:SpecifiedLogisticsServiceCharge>
|
||||
<ram:Description />
|
||||
<ram:AppliedAmount currencyID="" />
|
||||
<ram:AppliedTradeTax>
|
||||
<ram:TypeCode />
|
||||
<ram:CategoryCode />
|
||||
<ram:ApplicablePercent />
|
||||
</ram:AppliedTradeTax>
|
||||
</ram:SpecifiedLogisticsServiceCharge>
|
||||
<ram:SpecifiedTradePaymentTerms>
|
||||
<ram:Description />
|
||||
<ram:DueDateDateTime>
|
||||
<udt:DateTimeString format="" />
|
||||
</ram:DueDateDateTime>
|
||||
</ram:SpecifiedTradePaymentTerms>
|
||||
<ram:SpecifiedTradeSettlementMonetarySummation>
|
||||
<ram:LineTotalAmount currencyID="" />
|
||||
<ram:ChargeTotalAmount currencyID="" />
|
||||
<ram:AllowanceTotalAmount currencyID="" />
|
||||
<ram:TaxBasisTotalAmount currencyID="" />
|
||||
<ram:TaxTotalAmount currencyID="" />
|
||||
<ram:GrandTotalAmount currencyID="" />
|
||||
<ram:TotalPrepaidAmount currencyID="" />
|
||||
<ram:DuePayableAmount currencyID="" />
|
||||
</ram:SpecifiedTradeSettlementMonetarySummation>
|
||||
</ram:ApplicableSupplyChainTradeSettlement>
|
||||
<ram:IncludedSupplyChainTradeLineItem>
|
||||
<ram:AssociatedDocumentLineDocument>
|
||||
<ram:LineID />
|
||||
<ram:IncludedNote>
|
||||
<ram:Content />
|
||||
</ram:IncludedNote>
|
||||
</ram:AssociatedDocumentLineDocument>
|
||||
<ram:SpecifiedSupplyChainTradeAgreement>
|
||||
<ram:GrossPriceProductTradePrice>
|
||||
<ram:ChargeAmount currencyID="" />
|
||||
<ram:BasisQuantity unitCode="" />
|
||||
<ram:AppliedTradeAllowanceCharge>
|
||||
<ram:ChargeIndicator>
|
||||
<udt:Indicator />
|
||||
</ram:ChargeIndicator>
|
||||
<ram:ActualAmount currencyID="" />
|
||||
<ram:Reason />
|
||||
</ram:AppliedTradeAllowanceCharge>
|
||||
</ram:GrossPriceProductTradePrice>
|
||||
<ram:NetPriceProductTradePrice>
|
||||
<ram:ChargeAmount currencyID="" />
|
||||
<ram:BasisQuantity unitCode="" />
|
||||
</ram:NetPriceProductTradePrice>
|
||||
</ram:SpecifiedSupplyChainTradeAgreement>
|
||||
<ram:SpecifiedSupplyChainTradeDelivery>
|
||||
<ram:BilledQuantity unitCode="" />
|
||||
</ram:SpecifiedSupplyChainTradeDelivery>
|
||||
<ram:SpecifiedSupplyChainTradeSettlement>
|
||||
<ram:ApplicableTradeTax>
|
||||
<ram:TypeCode />
|
||||
<ram:ExemptionReason />
|
||||
<ram:CategoryCode />
|
||||
<ram:ApplicablePercent />
|
||||
</ram:ApplicableTradeTax>
|
||||
<ram:SpecifiedTradeSettlementMonetarySummation>
|
||||
<ram:LineTotalAmount currencyID="" />
|
||||
</ram:SpecifiedTradeSettlementMonetarySummation>
|
||||
</ram:SpecifiedSupplyChainTradeSettlement>
|
||||
<ram:SpecifiedTradeProduct>
|
||||
<ram:GlobalID schemeID="" />
|
||||
<ram:SellerAssignedID />
|
||||
<ram:BuyerAssignedID />
|
||||
<ram:Name />
|
||||
<ram:Description />
|
||||
</ram:SpecifiedTradeProduct>
|
||||
</ram:IncludedSupplyChainTradeLineItem>
|
||||
</rsm:SpecifiedSupplyChainTradeTransaction>
|
||||
</rsm:CrossIndustryDocument>
|
||||
Loading…
Add table
Add a link
Reference in a new issue