Discussion:
Instream base64 svg jpeg produces huge pdf document.
Burlock, Craig (SAPOL)
2005-02-11 04:55:52 UTC
Permalink
I am trying to produce a pdf document which contains a jpeg image that has
been generated using svg with base64 data. The approach does work, however
the final pdf document is huge! An essentially empty document with a single
40Kb jpeg image produces a 1Mb pdf document. Is this behaviour normal?

This is the only time I'm using svg. My xsl-fo does'nt include any svg
text.

Below is an extract of my fop. Am I doing something wrong?

<fo:instream-foreign-object content-type="content-type:image/jpeg">
<svg:svg height="176mm" width="277mm">
<svg:image width="277mm" height="176mm" x="0" y="0"
xlink:href="data:image/jpeg;base64,
/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAoHBwgHBgoICAgLCgoL . . . ." />
</svg:svg>
</fo:instream-foreign-object>

This project involved accessing image data which is only available from the
session. I tried writing a servlet, but was unable to see the correct
session from within the servlet.

Can anyone help me? I'd hate to abandon fop and produce nasty html reports
after getting this far!
Jeremias Maerki
2005-02-11 07:41:20 UTC
Permalink
You're probably a victim of the 72dpi bitmap scaling. Since you have the
image as an RFC2397 URL you had to use Batik to load the image as FOP
doesn't support that URL scheme.

One thing you could do is find a Java implementation of RFC2397 which
plugs into Java's own URL handler mechanism. A quick Google search
didn't show any, though. Batik implements RFC2397 in a non-standard way
but maybe you could write a wrapper around it to still provide a normal
Java URL handler as described here:
http://java.sun.com/developer/onlineTraining/protocolhandlers/

Sascha Schmidt posted something like this last year. I haven't looked at
it, though:
http://nagoya.apache.org/eyebrowse/ReadMsg?listName=fop-***@xml.apache.org&msgId=1892793

This way you could use an fo:external-graphic instead of an SVG wrapper
which should solve your problem with PDF size.

Hope that helps.
Post by Burlock, Craig (SAPOL)
I am trying to produce a pdf document which contains a jpeg image that has
been generated using svg with base64 data. The approach does work, however
the final pdf document is huge! An essentially empty document with a single
40Kb jpeg image produces a 1Mb pdf document. Is this behaviour normal?
This is the only time I'm using svg. My xsl-fo does'nt include any svg
text.
Below is an extract of my fop. Am I doing something wrong?
<fo:instream-foreign-object content-type="content-type:image/jpeg">
<svg:svg height="176mm" width="277mm">
<svg:image width="277mm" height="176mm" x="0" y="0"
xlink:href="data:image/jpeg;base64,
/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAoHBwgHBgoICAgLCgoL . . . ." />
</svg:svg>
</fo:instream-foreign-object>
This project involved accessing image data which is only available from the
session. I tried writing a servlet, but was unable to see the correct
session from within the servlet.
Can anyone help me? I'd hate to abandon fop and produce nasty html reports
after getting this far!
Jeremias Maerki

Loading...