aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2006-03-20 13:49:05 +0000
committerJeremias Maerki <jeremias@apache.org>2006-03-20 13:49:05 +0000
commit8f9856b3869ca85018dacf2f79b8c3e2e9830d48 (patch)
treebcec6c5fe21a59a2028cc92853cedf5a92b4be74
parentdf5d57e4bfe413f53673cb8465ef9a88e90c6b0a (diff)
downloadxmlgraphics-fop-8f9856b3869ca85018dacf2f79b8c3e2e9830d48.tar.gz
xmlgraphics-fop-8f9856b3869ca85018dacf2f79b8c3e2e9830d48.zip
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: <filterList type="tiff"> <value>flate</value> </filterList> <filterList type="jpeg"> <value>flate</value> </filterList> git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@387213 13f79535-47bb-0310-9956-ffa450edef68
-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>