You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems there is an issue when translating java2D graphics to PDF. Some lines are getting off their real precise coordinates. Same graphics exported to SVG from jfreeSVG are coordinate accurate. There might be some kind of optimization (or java variable type setting, float to double maybe) that actually reduces the number of coordinate digits and as a result some points are off their actual position in the used grid. I have noted such behavior in inkscape 's SAVE optimization algorithms that optionally can reduce the SVG size by reducing the number of digits used in coordinates. For some designs this might be and look OK, but for coordinate accurate or complex graphics this might lead to this artifact. You can consider this as a high priority bug as it can distort the produced graphics data with irreversible loss in specific cases.
There should be a way to improve the accuracy of the exported vectors, and this could be selectable scenarios by entering a new parameter hint value upon the fundamental call of graphics, something like
graphicsPDF.setRenderingHint(PDFHints.KEY_VECTOR_ACCURACY,
PDFHints.VALUE_DRAW_VECTOR_ACCURACY_LOW/MED/HIGH);
The text was updated successfully, but these errors were encountered:
I've searched a bit the source and with a bit of luck I have found the coordinate digit accuracy setting.
I have tested translations to PDF with the new setting and they seem perfect.
It resides here: package org.jfree.pdf.stream; GraphicsStream.java
changed digit pattern from 2 to a higher value to increase coordinate precision this.geometryFormat = new DecimalFormat("0.##", dfs);
to
this.geometryFormat = new DecimalFormat("0.############", dfs); // NEW 12 digit
There might be more changes to take place, but this one just eliminates the described artifact
istinnstudio
changed the title
Coordinate accuracy issues in vector elements inside produced PDF
Coordinate precision issues in vector elements inside produced PDF
Jan 19, 2022
Good spot! A while back there was also a pull request for JFreeSVG to increase performance in the formatting of coordinates, this might also be interesting to look at here: jfree/jfreesvg#30
It seems there is an issue when translating java2D graphics to PDF. Some lines are getting off their real precise coordinates. Same graphics exported to SVG from jfreeSVG are coordinate accurate. There might be some kind of optimization (or java variable type setting, float to double maybe) that actually reduces the number of coordinate digits and as a result some points are off their actual position in the used grid. I have noted such behavior in inkscape 's SAVE optimization algorithms that optionally can reduce the SVG size by reducing the number of digits used in coordinates. For some designs this might be and look OK, but for coordinate accurate or complex graphics this might lead to this artifact. You can consider this as a high priority bug as it can distort the produced graphics data with irreversible loss in specific cases.
There should be a way to improve the accuracy of the exported vectors, and this could be selectable scenarios by entering a new parameter hint value upon the fundamental call of graphics, something like
graphicsPDF.setRenderingHint(PDFHints.KEY_VECTOR_ACCURACY,
PDFHints.VALUE_DRAW_VECTOR_ACCURACY_LOW/MED/HIGH);
The text was updated successfully, but these errors were encountered: