From: Jeremias Maerki Date: Mon, 20 Mar 2006 13:49:05 +0000 (+0000) Subject: Certain filter combinations in PDF could lead to invalid PDFs. DecodeParams were... X-Git-Tag: fop-0_92-beta~65 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8f9856b3869ca85018dacf2f79b8c3e2e9830d48;p=xmlgraphics-fop.git Certain filter combinations in PDF could lead to invalid PDFs. DecodeParams were not properly handled. Default filter for XMP metadata set to NullFilter as XMP metadata should always be embedded as clear-text so non-PDF-aware XMP processors can extract the metadata. Default filter for DCT/JPEG- and CCITT/TIFF-encoded images set to NullFilter because these two compression methods already do a good job. An additional flate filter (as was applied before due to the single default) helps a just little but also adds processing time. If anyone wants to squeeze every possible bit out of the PDF you can use the following in the user configuration: flate flate git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@387213 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/pdf/PDFFilterList.java b/src/java/org/apache/fop/pdf/PDFFilterList.java index 6ffda9da7..c26185b37 100644 --- a/src/java/org/apache/fop/pdf/PDFFilterList.java +++ b/src/java/org/apache/fop/pdf/PDFFilterList.java @@ -163,8 +163,19 @@ public class PDFFilterList { } } if (filterset == null || filterset.size() == 0) { - // built-in default to flate - addFilter(new FlateFilter()); + if (METADATA_FILTER.equals(type)) { + //XMP metadata should not be embedded in clear-text + addFilter(new NullFilter()); + } else if (JPEG_FILTER.equals(type)) { + //JPEG is already well compressed + addFilter(new NullFilter()); + } else if (TIFF_FILTER.equals(type)) { + //CCITT-encoded images are already well compressed + addFilter(new NullFilter()); + } else { + // built-in default to flate + addFilter(new FlateFilter()); + } } else { for (int i = 0; i < filterset.size(); i++) { String v = (String)filterset.get(i); @@ -187,17 +198,24 @@ public class PDFFilterList { List parms = new java.util.ArrayList(); // run the filters + int nonNullParams = 0; for (int count = 0; count < filters.size(); count++) { PDFFilter filter = (PDFFilter)filters.get(count); // place the names in our local vector in reverse order - names.add(0, filter.getName()); - if (filter.getDecodeParms() != null) { - parms.add(0, filter.getDecodeParms()); + if (filter.getName().length() > 0) { + names.add(0, filter.getName()); + if (filter.getDecodeParms() != null) { + parms.add(0, filter.getDecodeParms()); + nonNullParams++; + } else { + parms.add(0, null); + } } } // now build up the filter entries for the dictionary - return buildFilterEntries(names) + buildDecodeParms(parms); + return buildFilterEntries(names) + + (nonNullParams > 0 ? buildDecodeParms(parms) : ""); } return ""; diff --git a/status.xml b/status.xml index 4e23f12c1..f36b6968b 100644 --- a/status.xml +++ b/status.xml @@ -27,6 +27,10 @@ + + Bugfix: Certain filter combinations in PDF could lead to invalid PDFs. + DecodeParams were not properly handled. + Bugfix: CCITT Group 4 encoded TIFF images with multiple strips are now properly embedded in PDF files.