Configurable PDF Attachment Compression
This commit is contained in:
@@ -136,6 +136,7 @@ public class DXExporterFromA1 extends DXExporterFromA3 {
|
||||
public DXExporterFromA1 setConformanceLevel(PDFAConformanceLevel newLevel) {
|
||||
return (DXExporterFromA1) super.setConformanceLevel(newLevel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DXExporterFromA1 setProducer(String producer){
|
||||
return (DXExporterFromA1) super.setProducer(producer);
|
||||
|
||||
@@ -71,6 +71,7 @@ import jakarta.activation.FileDataSource;
|
||||
public class DXExporterFromA3 extends ZUGFeRDExporterFromA3 {
|
||||
|
||||
protected PDFAConformanceLevel conformanceLevel = PDFAConformanceLevel.UNICODE;
|
||||
protected boolean compressionEnabled = false;
|
||||
protected ArrayList<FileAttachment> fileAttachments = new ArrayList<>();
|
||||
|
||||
/**
|
||||
@@ -296,8 +297,8 @@ public class DXExporterFromA3 extends ZUGFeRDExporterFromA3 {
|
||||
dict.setString("Desc", description);
|
||||
|
||||
ByteArrayInputStream fakeFile = new ByteArrayInputStream(data);
|
||||
PDEmbeddedFile ef = new PDEmbeddedFile(doc, fakeFile);
|
||||
// ef.addCompression();
|
||||
COSName filter = compressionEnabled ? COSName.FLATE_DECODE : null;
|
||||
PDEmbeddedFile ef = new PDEmbeddedFile(doc, fakeFile, filter);
|
||||
ef.setSubtype(subType);
|
||||
ef.setSize(data.length);
|
||||
ef.setCreationDate(new GregorianCalendar());
|
||||
@@ -417,7 +418,6 @@ public class DXExporterFromA3 extends ZUGFeRDExporterFromA3 {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DXExporterFromA3 setCreator(String creator) {
|
||||
this.creator = creator;
|
||||
|
||||
@@ -56,6 +56,7 @@ public interface IZUGFeRDExporter extends Closeable, IExporter {
|
||||
public IZUGFeRDExporter load(InputStream pdfSource) throws IOException;
|
||||
public IZUGFeRDExporter setCreator(String creator);
|
||||
public IZUGFeRDExporter setConformanceLevel(PDFAConformanceLevel newLevel);
|
||||
public IZUGFeRDExporter setEnablePDFAttachmentCompression(boolean enablePDFAttachmentCompression);
|
||||
public IZUGFeRDExporter setProducer(String producer);
|
||||
public IZUGFeRDExporter setZUGFeRDVersion(int version);
|
||||
public boolean ensurePDFIsValid(final DataSource dataSource) throws IOException;
|
||||
|
||||
@@ -129,6 +129,9 @@ public class OXExporterFromA3 extends ZUGFeRDExporterFromA3 {
|
||||
|
||||
private boolean attachZUGFeRDHeaders = true;
|
||||
|
||||
/** Defines whether attachments to the PDF should be using FLATE compression */
|
||||
private boolean compressionEnabled = false;
|
||||
|
||||
/**
|
||||
* Makes A PDF/A3a-compliant document from a PDF-A1 compliant document (on the
|
||||
* metadata level, this will not e.g. convert graphics to JPG-2000)
|
||||
@@ -296,8 +299,8 @@ public class OXExporterFromA3 extends ZUGFeRDExporterFromA3 {
|
||||
dict.setString("Desc", description);
|
||||
|
||||
ByteArrayInputStream fakeFile = new ByteArrayInputStream(data);
|
||||
PDEmbeddedFile ef = new PDEmbeddedFile(doc, fakeFile);
|
||||
// ef.addCompression();
|
||||
COSName filter = compressionEnabled ? COSName.FLATE_DECODE : null;
|
||||
PDEmbeddedFile ef = new PDEmbeddedFile(doc, fakeFile, filter);
|
||||
ef.setSubtype(subType);
|
||||
ef.setSize(data.length);
|
||||
ef.setCreationDate(new GregorianCalendar());
|
||||
|
||||
@@ -101,6 +101,9 @@ public class ZUGFeRDExporterFromA3 extends XRExporter implements IZUGFeRDExporte
|
||||
private Profile profile = null;
|
||||
protected boolean documentPrepared = false;
|
||||
|
||||
/** Defines whether attachments to the PDF should be using FLATE compression */
|
||||
private boolean compressionEnabled = false;
|
||||
|
||||
/**
|
||||
* Data (XML invoice) to be added to the ZUGFeRD PDF. It may be externally set,
|
||||
* in which case passing a IZUGFeRDExportableTransaction is not necessary. By
|
||||
@@ -392,7 +395,8 @@ public class ZUGFeRDExporterFromA3 extends XRExporter implements IZUGFeRDExporte
|
||||
dict.setString("Desc", description);
|
||||
|
||||
ByteArrayInputStream fakeFile = new ByteArrayInputStream(data);
|
||||
PDEmbeddedFile ef = new PDEmbeddedFile(doc, fakeFile, COSName.FLATE_DECODE);
|
||||
COSName filter = compressionEnabled ? COSName.FLATE_DECODE : null;
|
||||
PDEmbeddedFile ef = new PDEmbeddedFile(doc, fakeFile, filter);
|
||||
// ef.addCompression();
|
||||
ef.setSubtype(subType);
|
||||
ef.setSize(data.length);
|
||||
@@ -503,6 +507,12 @@ public class ZUGFeRDExporterFromA3 extends XRExporter implements IZUGFeRDExporte
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IZUGFeRDExporter setEnablePDFAttachmentCompression(boolean compressionEnabled) {
|
||||
this.compressionEnabled = compressionEnabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public ZUGFeRDExporterFromA3 setCreator(String creator) {
|
||||
this.creator = creator;
|
||||
|
||||
@@ -188,6 +188,10 @@ public class ZUGFeRDExporterFromPDFA implements IZUGFeRDExporter {
|
||||
return getExporter().setConformanceLevel(newLevel);
|
||||
}
|
||||
|
||||
public IZUGFeRDExporter setEnablePDFAttachmentCompression(boolean compressionEnabled) {
|
||||
return getExporter().setEnablePDFAttachmentCompression(compressionEnabled);
|
||||
}
|
||||
|
||||
public IZUGFeRDExporter setProducer(String producer) {
|
||||
|
||||
return getExporter().setProducer(producer);
|
||||
|
||||
Reference in New Issue
Block a user