Skip to content
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

drawRect does not properly close rectangle #46

Closed
fransbouwmans opened this issue Sep 16, 2022 · 2 comments
Closed

drawRect does not properly close rectangle #46

fransbouwmans opened this issue Sep 16, 2022 · 2 comments

Comments

@fransbouwmans
Copy link

When using a drawRect the resulting drawn rectangle looks fine in java, but the resulting pdf export has gaps in the corner points.
When the drawRect is replace by four drawLine calls the rectangle is drawn fine.

image

image

It is not clear why this happens as the drawRect (not overridden) ultimately calls drawLine itself.

Currently the simple workaround is to use drawLine instead of drawRect

@rototor
Copy link
Owner

rototor commented Sep 16, 2022

This happens because drawRect(int,int,int,int) was defined at a time when there was only some bitmap output for graphics. But depending on your stroke and matrix you are of course getting gabs. In PDF you have "high precission" because you are not aligning on a pixel raster. I.e. that drawLine()'s might not overlap is rather likely on PDFs when you BasicStroke has not at least on 1px width (but what is pixel width in PDF ...)

=> The right fix will be to override drawRect() and do just a draw(new Rectangle2D.Float(...)).

rototor added a commit that referenced this issue Sep 16, 2022
use a Rectangle with drawShape().
@rototor
Copy link
Owner

rototor commented Dec 29, 2022

I've just released the fix in version 0.42.

@rototor rototor closed this as completed Dec 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants