-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PDF renderer rounds coordinates to two decimal places #5801
Comments
I want to add that this entire behaviour is weird. For example, adding a stroke weight of |
Actually, this has become an issue now - because of the rounding behaviour, a bunch of the curves I draw fall together on the same coordinates, and that's really not nice... |
We're at the mercy of the iText library that handles converting the drawing commands to PDF format. So this can't be fixed without rewriting PDF support entirely. To deal with your specific issue, however, I'd recommend using a larger area with the |
While it's true that you are at the mercy of iText, this can be improved massively without rewriting PDF support. For future reference, if anyone should run into this, you can try this: import processing.pdf.*;
import com.lowagie.text.pdf.ByteBuffer;
void setup() {
ByteBuffer.HIGH_PRECISION = true;
size(400, 400, PDF, "test.pdf");
} This will get you up to six places after the decimal dot. It's still rounded, and in some arcane way, but it's much better than without. For this input: bezierVertex(
150.12345678, 100,
120.123227, 210, // observe rounding behaviour
223.123223, 323); we now get 100 300 m
150.123459 300 120.12323 190 223.12323 77 c
S I don't have the sources of that iText version at hand and don't know when that boolean might be reset. I also don't have enough overview over the processing sources to figure out if there would be a good place to put this. Maybe a hint for the renderer? No clue, maybe someone else can figure this out... |
Awesome, thanks for tracking that down! Now incorporated for 4.0 alpha 2. |
Wow, cool! Thanks :) |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Description
When using
PDF
as the renderer, coordinates (at least for bezier curves, didn't test anything else) are rounded to two decimal places.Expected Behavior
I didn't expect any rounding to happen. The PDF specification does not impose a limit on the precision of real numbers (see section 7.3.3 of the Adobe spec).
Current Behavior
Coordinates are rounded to two places after the decimal dot.
Steps to Reproduce
Using this program:
will produce a PDF file
test.pdf
. We can decompress the file usingmutool
, specifically themutool clean
command (https://mupdf.com/docs/manual-mutool-clean.html):The resulting PDF file, without all the preamble and trailer stuff, looks like this:
We can see that the coordinates of the bezier curve are rounded.
Of course, I see that this is not the biggest of issues, some precision is still there. For my use case, I could scale everything up by some factor, then rasterize the PDF at a lower resolution, and probably get the same result. But this behavior still came as a surprise to me.
Your Environment
Possible Causes / Solutions
Does iText enforce this? Can we configure it? Are there hints for this?
The text was updated successfully, but these errors were encountered: