You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Yakov Shafranovich <Ya...@solidmatrix.com> on 2005/02/10 06:27:50 UTC
ASCII-85 Encoding Not Working with JPEGs
We have been using FOP in a servlet to generate PDF files out of a XSLT
template. One of the problem we had is that the plain PDF output did not
work until the ASCII-85 filter was enabled as follows:
List list = new ArrayList(2);
list.add("flate");
list.add("ascii-hex");
list.add("ascii-85");
Configuration.put("stream-filter-list", list, Configuration.PDF);
Now for the first time, we used an XSL-FO template with JPEG images via
the use of the fo:external-graphic tag. The template works fine locally
but when run in the servlet it fails. Upon closer inspection, the output
PDF file contains ASCII-85 encoding for everything EXCEPT the embedded
JPEGs. The JPEGs come out as binary streams even though the rest of the
file isn't. Is there a way to force ASCII-85 encoding on the whole file?
Sincerely,
Yakov Shafranovich
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org
Re: ASCII-85 Encoding Not Working with JPEGs
Posted by Yakov Shafranovich <Ya...@solidmatrix.com>.
Jeremias Maerki wrote:
> Not having the ASCII-85 filter in place is perfectly legal for a PDF. I
> wonder why you need that filter so your process works. Either you're
> working with a bad PDF viewer/reader or you're doing something wrong in
> stream handling, for example using Readers and Writers instead of
> InputStreams and OutputStreams. PDF is binary!
>
Jeremias,
Thank you! After going back deep into our code, we found that we were in
fact using an InputStreamReader along the way. Right now we replaced
everything with binary for FOP, and it works like a charm. I did also
notice that the deflate filter is not applied to JPEG which is a good
thing since they are already compressed.
Yakov
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org
Re: ASCII-85 Encoding Not Working with JPEGs
Posted by Jeremias Maerki <de...@greenmail.ch>.
Not having the ASCII-85 filter in place is perfectly legal for a PDF. I
wonder why you need that filter so your process works. Either you're
working with a bad PDF viewer/reader or you're doing something wrong in
stream handling, for example using Readers and Writers instead of
InputStreams and OutputStreams. PDF is binary!
In your list below you should take out the "ascii-hex" filter because it
does almost the same as the ascii-85 filter. You're encoding your in-PDF
streams twice with a binary-to-ascii filter. Not that it doesn't work,
it just kills the effect from the flate compression as the ascii-hex
filter blows up the stream to twice its original size.
The filter handling in FOP 0.20.5 is not ideal. PDF filters for JPEG
images are indeed hard-coded so you will have to modify FOP's sources to
"fix" this. Before you start hacking FOP sources, check that you're not
doing something wrong (see above). If you absolutely need the ASCII-85
filter you can try to add the following line to org.apache.fop.pdf.PDFXObject
in method output(OutputStream), approx. line 254:
if (fopimage.getPDFFilter() != null) {
imgStream.addFilter(fopimage.getPDFFilter());
//the next line is new:
imgStream.addFilter(new ASCII85Filter());
} else {
imgStream.addDefaultFilters();
}
On 10.02.2005 06:27:50 Yakov Shafranovich wrote:
> We have been using FOP in a servlet to generate PDF files out of a XSLT
> template. One of the problem we had is that the plain PDF output did not
> work until the ASCII-85 filter was enabled as follows:
>
> List list = new ArrayList(2);
> list.add("flate");
> list.add("ascii-hex");
> list.add("ascii-85");
> Configuration.put("stream-filter-list", list, Configuration.PDF);
>
> Now for the first time, we used an XSL-FO template with JPEG images via
> the use of the fo:external-graphic tag. The template works fine locally
> but when run in the servlet it fails. Upon closer inspection, the output
> PDF file contains ASCII-85 encoding for everything EXCEPT the embedded
> JPEGs. The JPEGs come out as binary streams even though the rest of the
> file isn't. Is there a way to force ASCII-85 encoding on the whole file?
Jeremias Maerki
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org