It's interesting how many bugs you can find in ancient code that
thousands of people use every day. :-) While debugging rendering
differences between SVGs painted to PDF and PS I found some weird
numbers being written into the PDF while basically the same code for PS
wrote the expected numbers into the output file. Now, it turns out that
PDFNumber.doubleOut() has a bug when a double value comes in that is
displayed by Double.toString(double) in scientific notation, i.e. for
example: 5.7220458984375E-6

Now the horror: doubleOut operates on the String returned by
Double.toString(double) and ignores the "E" part. The above number is
written as "5.7220458" to the PDF. D'oh!

In the PSGenerator I'm using a pre-setup DecimalFormat to format the
values:

private DecimalFormat df5 = new DecimalFormat("0.#####", new 
DecimalFormatSymbols(Locale.US));

Since that code is in there for so long, I'm hesitant to simply rip it
out. Does anyone see a reason why doubleOut() should be fixed instead of
rewriting it to use a DecimalFormat like the PostScript output uses?
Speed maybe? Hard to believe.

Jeremias Maerki

Reply via email to