-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Poor rendering if OS (Windows) scales to 125% due to monitor resolution #311
Comments
Thanks, always nice to get some feed back, even more so if its positive. This is an interesting problem. It's not specific the the library but from my readings is more of a JDK issue. Could you try the following systems properties (https://news.kynosarges.org/2019/03/24/swing-high-dpi-properties/)? -Dsun.java2d.uiScale.enabled=false |
Hi Patrick, thanks for your quick response. Also I found an interesting statement here: https://github.com/JFormDesigner/FlatLaf/blob/main/flatlaf-core/src/main/java/com/formdev/flatlaf/util/UIScale.java Maybe the PDF could be prepared with higher resolution if necessary and drawn with scale 1.0? |
…ainting the page buffer at higher scale factors.
The UIScale class you posted does indeed have some very interesting information in it. The Viewer RI AbstractPageViewComponent uses a BufferedImage to cache the latest render of the PDF content. There is a bunch of logic that copies cached content and tries to limit the size of clip when updating for scrolling and scaling. The buffer is then painted using java.awt.Graphics2D and will pick up on the JRE applied scaling. This probably explains the blurring you are seeing. I don't have the hardware to test this properly any chance you could pull https://github.com/pcorless/icepdf/tree/GH-311.fraction.scaling.compensation and give the theory a try? |
Yes, sure I'll give this a try :-) |
It seems, your idea does not change anything. :-( If you add I also tried to replace the AffineTransform with identity transform (I know, you should NEVER do that...). Then the PDF content is not scaled any more and thus look fine, but the 'paper' is too big. It seems, it was painted before already. Maybe we could do something like
and something similar where the paper boundaries are painted? |
I experimented a bit and now I'm able to prevent the scaling. The page layouts (e.g. OnePageViewLayout) do not consider the smaller scale of the pages yet (sure this can be fixed, too). But I'm not sure if this is what we really want. Before I continue please let me know what you think: What is the real meaning of a scale 100% shown by the UI? Should the page appear on the screen in the same size as printed on paper? BTW: on my normal 100% screen a A4 page shows up with a width of 161mm (should be 210mm) It might be by coincidence, but the factor is almost 96 / 72. Could it be, that there should be an additional scaling from 72 pt/inch to 96 px/inch? But maybe nobody cares about the real size of the picture on the screen? |
That's interesting about the page layouts but I guess that makes sense in a way. I'll give it another try and see about passing in the scale factor into the code that creates the buffer, see if I can make some headway with that angle. I haven't been able to reproduce this on my Linux system yet but will keep trying. Any chance you could post a screen shot of the blurred output? Papers size has come up over the years but I could probably count then on one hand. It's pretty much just like you pointed out 72 pt/inch to 96 px/inch. The PDF spec states one thing and Java2D does another. I don't think this would be too difficult to fix but I think there are some consideration with Apple and Windows but I can't remember if Java2d automatically corrects for that. More reading. |
Yes, maybe it is worth a try to directly create the image with a modified scaling factor. The bad thing is, that we cannot get the scaling factor before we get the Graphics2D in paint function... Would you like me to create a pull request with my changes? |
Another note: |
I was poking around tonight and there really isn't much info on this issue. There is a thread on Intellij support that discusses the issue with regards to the the IDE. They seem to make the distinction of app scaling vs the jre scaling. Have you tried a simple configuration of: From you screen shots this definitely looks like the buffer being scaled by 1.25. In your cloned repo, you should be able to create new branch with your work committed to it. Then create a pull request against pcorless:master. |
Thanks for the info, I'll continue to work on the buffer angle. Found a pretty good lead here, https://stackoverflow.com/questions/61558678/how-do-i-double-buffer-in-java-swing-on-a-retina-display-without-losing-the-high . Fairly sure I can incorporate the approach. |
This is still on the top of my todo list. I'm currently trying to wrap up a bunch of work on redacting text. |
The same problem occurs when an image of a page is to be created via getPageImage and the physical screen resolution is not 100% and it happens especially when truetype fonts are embedded in the PDF. |
Thanks for extra information. |
Could someone on this thread pull the GH-311 branch and let me know what they see. I don't expect an improvement in rendering quality just yet but I'm curious about the following log lines to standard out. It would also helpful as to what OS you are running and JRE version device scale: xx On my Linux system I can only get values of 1.0. I've tried applying a 200% scale in Gnome but the JRE only reports 100% on my none high dpi monitors. |
OS: Windows 22H2 scale factor 125% |
Thanks |
Thanks for this really great piece of software!
I am using ICEpdf on a Windows 10 machine. My PDFs are rendered perfectly, as long as the monitor scaling is set to 100%.
When I move the viewer window to my other monitor, which has scaling set to 125% (recommended), then the PDF seems to be scaled up and fonts get blurred. This happens regardless of the current scaling factor in the viewer.
Is there any way to avoid this?
The text was updated successfully, but these errors were encountered: