aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/java/org/apache/fop/pdf/PDFFilterList.java30
-rw-r--r--status.xml4
2 files changed, 28 insertions, 6 deletions
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
@@ -28,6 +28,10 @@
<changes>
<release version="FOP Trunk">
<action context="Code" dev="JM" type="fix">
+ Bugfix: Certain filter combinations in PDF could lead to invalid PDFs.
+ DecodeParams were not properly handled.
+ </action>
+ <action context="Code" dev="JM" type="fix">
Bugfix: CCITT Group 4 encoded TIFF images with multiple strips are now properly
embedded in PDF files.
</action>