I use Batik+fop+axis to create pdf content on the fly from the svg source.
(batik 1.5 release, fop 0.20.5)
There are 2 document-size-issues:
1.I use absolute size in svg documents, for example 100mm.
<svg width="100mm" height="50mm">
After transcoding the size in multipled by 4/3, i.e.
100mm becomes 133mm. In the source code of both batik and fop there
are lot of
return 0.3528f; // 72 dpi
//return 0.26458333333333333333333333333333f; // 96dpi
fragments. Sometimes is 72 commented out, sometimes 96.
The ratio of 96 to 72 is exactly 4 to 3. I guess, this is the
cause of the bug? The workaround I use is to calculate the document size
in points outside the batik/fop und to pass the values through
the HEIGHT/WIDTH hints. Is it at all a good idea to hard code
a resolution? Or is 72 simply inch-to-point factor? I mean
an inch is always 72 points, but
an inch is not always 72 pixels, it is device dependent.
2.Variables for the document size in the source code of batik, fop
are sometimes declared as int, sometimes as float. The document
size values get rounded up (in points). If I have a document
with 100mm in size, it's translated to 283.447 points. Somewhere in
batik/fop it gets rounded to 283. And finally I get the pdf
document with 99.84mm in size.
I've investigated the problems in the source code and I've
tried to correct it at least in my local copy of the source code.
But there are so many places where float->int conversion
(with the lost of precision)
is made and where Dimension structure is used instead of Dimension2D...
So for me I've slightly adjusted the PDFTranscoder,
PDFDocumentGraphics2D and use the document size hints.
For all the others, who use mm as measure unit und need the
exact document size, it would be great, if somebody of the insiders
could make this quite extensive, but reasonable changes.
By the way, the batik and fop projects are very large but
so good organized and structured, that it's very easy to analyze
and navigate through the source code, even with only using
the text editor and for somebody who never has programmed java before
(last 10 years I was c++, visual basic, c# oriented ;-).
Great work guys!
vdobriakov at jjk dot de