Bug 432500 - Zoom percentage not working properly
Summary: Zoom percentage not working properly
Status: REPORTED
Alias: None
Product: okular
Classification: Applications
Component: PDF backend (show other bugs)
Version: 1.9.3
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-02-04 10:20 UTC by tg
Modified: 2021-05-08 18:31 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Snapshots of pdf display at different zoom levels (356.86 KB, application/pdf)
2021-02-04 10:20 UTC, tg
Details

Note You need to log in before you can comment on or make changes to this bug.
Description tg 2021-02-04 10:20:32 UTC
Created attachment 135417 [details]
Snapshots of pdf display at different zoom levels

SUMMARY
Issues with the display of pdf while choosing the zoom values. If I choose any % value the display becomes very large. At 100% I would expect the document to show the original pdf, but when I select 100%, the display of the pdf blows up. Same is the case for any other percentage chosen. However, it displays fine for "Fit Width".

STEPS TO REPRODUCE
1. Right click a pdf document
2. Choose "Open With"
3. Choose "Other Application"
4. Select "Okular"
5. Select the option "Remember application association for all files of type "PDF" document"
6. Click "Ok"
7. Select the zoom level to any percent (25,50,100). 


OBSERVED RESULT
The pdf display will blow up

EXPECTED RESULT
The pdf display should work properly for the zoom values.

SOFTWARE/OS VERSIONS
Linux: Ubuntu 20.04.2 LTS
KDE Plasma Version: 5.18.5
KDE Frameworks Version: 5.68.0
Qt Version: 5.12.8

ADDITIONAL INFORMATION
Kernel Version: 5.4.0-65-lowlatency

Link of issue raised on another forum:
https://forum.kde.org/viewtopic.php?f=67&t=126986
Comment 1 Yuri Chornoivan 2021-02-04 10:31:04 UTC
Cannot reproduce it with the same file (open access).

https://royalsocietypublishing.org/doi/10.1098/rspb.2012.2863

Can you check (and untick if it is) if the "View -> Trim View -> Trim To Selection" menu item is selected?

Thanks in advance for your answer.
Comment 2 tg 2021-02-04 10:41:05 UTC
Thank for looking into this.
The "View -> Trim View -> Trim To Selection" item is not selected. 

I would like to add one more thing: 

1. I had the same problem in Ubuntu 18.04.
2. Yesterday I updated to 20.04
3. After the update it worked fine when I opened a pdf document.
4. However, the moment I selected "okular" as the default application. The issue came back.
Comment 3 Yuri Chornoivan 2021-02-04 10:50:31 UTC
Can you check one more thing?

1. Open the "File association" module of the System Settings (Alt+F2, type "association", select the module).

2. Enter "pdf", select "pdf".

3. Press "Edit...", then select the "Application" tab.

What is in the "Command" field (should be "okular %U")?
Comment 4 tg 2021-02-04 11:44:47 UTC
It is "Okular %U".
Comment 5 tg 2021-02-04 11:48:14 UTC
There has been  discussion on similar lines:
https://askubuntu.com/questions/773648/okular-doesnt-show-correct-zoom-factors-too-small

This link is 4 years old. So I am not sure whether it is an old issue or even related to okular.
Comment 6 Albert Astals Cid 2021-02-04 22:44:54 UTC
I'm going to guess your dpi settings are not correctly detected.

Please run kdebugsettings, write Okular on top to filter the options, then set Okular (Core) to Full Debug and run okular from the command line.

Then open a file and there will be a line like:
   org.kde.okular.core: Output DPI: QSizeF(143.435, 144.379)

Can you paste your QSizeF value?
Comment 7 tg 2021-02-05 02:31:08 UTC
I think you might be right. I'll run kdebugsettings and upload the results.
However I did more research to find out exactly when does this problem occur. It occurs consistently when I connect an external monitor using HDMI. 
On the laptop the zoom feature consistently works fine. The moment I connect my external monitor the feature stops working.
Comment 8 tg 2021-02-05 03:31:37 UTC
I ran kdebugsettings. I got the following output:

org.kde.okular.core: Output DPI: QSizeF(2159, 2167.47)
Comment 9 Albert Astals Cid 2021-02-05 17:57:45 UTC
Yeah that's not good :D

I very much doubt that your monitor has such a high DPI, unfortunately without access to your monitor i don't think there's much we can do here.

I mean we could theoretically say "nah that's too high, but on the other hand someone at some point will have such a dpi"
Comment 10 jdvm 2021-05-07 23:29:40 UTC
Hi guys, I am experiencing this issue, too.

- Trim To selection is not checked.
- First application association for pdf is Okular and command is okular %U
- My output from kdebugsettings is:

Output DPI: QSizeF(3048, 3048)

I wrote a post in the forums months ago with sample images (I guess I can't upload that file due to copyright although it's a free preview...)

https://forum.kde.org/viewtopic.php?f=251&t=166706&p=441381#p441381

I was surprised when I downloaded evince and the zoom looked 'right', specially when I saw both Okular and evince use poppler.
Comment 11 jdvm 2021-05-08 18:31:38 UTC
Hi again, guys.

Sorry for the double comment, but I think I know where is the issue, at least in my case.

The EDID for my screen is wrong, the DisplaySize in parse-edid says 160 and 90 and I think QScreen 'physical methods' use those values, because printing physicalSize().width() and height() outputs 16 and 9. Thus, the physicalDotsPerInchY and X used by Okular are 'wrong'.

Maybe I should try to create a new EDID file and tell Xorg to use it, but Okular could use logicalDotsPerInch instead of physical or QX11Info's properties? Or maybe let the user choose which type to use for this cases?

In my case, logicalDotsPerInch and QX11Info::appDpiY/X outputs 96, which is more accurate (I'm not sure if it's because I created a .Xresources file with the property Xft.dpi equal to 96).
Could be that those properties were used by Okular years ago?
I saw these commit:
https://invent.kde.org/graphics/okular/-/commit/f42a3bad65200267cfe04cf584c203e70a3a6ec0

I saw the source code for QX11Info and it uses logical values, not physical:
https://code.qt.io/cgit/qt/qtx11extras.git/tree/src/x11extras/qx11info_x11.cpp