Bug 434613 - System DPI ignored for PDF files
Summary: System DPI ignored for PDF files
Status: REPORTED
Alias: None
Product: okular
Classification: Applications
Component: PDF backend (show other bugs)
Version: unspecified
Platform: Mint (Ubuntu based) Linux
: NOR normal
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-03-19 09:25 UTC by zfr77
Modified: 2021-03-19 14:18 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description zfr77 2021-03-19 09:25:07 UTC
SUMMARY

When opening PDF files, the DPI seems to be determined from the monitor EDID, if one is provided. The problem is, it's not uncommon for this to be incorrect, and for this reason I use xrandr and/or xorg.conf to enter the correct DPI. This is however ignored by Okular.

As such, if the monitor's EDID is wrong, it's not possible to have Okular use the correct DPI, other than by using a custom EDID, which is not always an easy workaround.


STEPS TO REPRODUCE
1. Type 'xrandr --dpi 96' in terminal. 
2. Open an A4 (or any other sie) PDF document in Okular. Check its width at 100%.
3. Type 'xrandr --dpi 80' in terminal.
4. Open an A4 (or any other sie) PDF document in Okular. Check its width at 100%.

Alternatively

1. Add 'Option "DPI" "96 x 96"' under 'Device' in xorg.conf. Restart. 
2. Open an A4 (or any other sie) PDF document in Okular. Check its width at 100%.
3. Add 'Option "DPI" "80 x 80"' under 'Device' in xorg.conf. Restart. 
4. Open an A4 (or any other sie) PDF document in Okular. Check its width at 100%.

OBSERVED RESULT

In both cases the width of the A4 page will be same. It will ignore the DPI you set manually. It will use DPI from your monitor's EDID's (if one is supplied).

EXPECTED RESULT

The width of the A4 page should be different, depending on DPI. An A4 paper is 210mm wide, which is equal to 8.27 inches, which should be around 794px at 96 DPI and 661px at 80 DPI.

OTHER NOTES

Some other pdf readers, like MuPDF, use the manual DPI you set correctly.

Also, this issue is particularly bad for my monitor, whose EDID provides an wrong horizontal and vertical DPIs that are not equal. This causes pages viewed on Okular not only to be of incorrect size, but also slightly stretched.

It would be ideal, if you could actually set the DPI manually in settings.


SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: Linux Mint 19.3 Cinnamon 4.4.8
(available in About System)
Okular version: 20.12.3
KDE Plasma Version: 
KDE Frameworks Version: 5.78.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION
Comment 1 Nate Graham 2021-03-19 13:53:43 UTC
We get the DPI from Qt; I don't think it realistic for us to work around Qt by getting it from somewhere else. :/
Comment 2 Oliver Sander 2021-03-19 14:03:58 UTC
What we do have, however, is

            if (qAbs(res.width() - res.height()) / qMin(res.height(), res.width()) < 0.05) {
                return res;
            } else {
                qCDebug(OkularCoreDebug) << "QScreen calculation returned a non square dpi." << res << ". Falling back";
            }


in method Utils::realDpi, file utils.cpp.  In other words, unequal dpi values for x and y are actively ignored by Okular.  I am not sure whether that is a bug or a feature.  Probably both.
Comment 3 zfr77 2021-03-19 14:18:28 UTC
And I understand Qt gets its DPI from EDID? Is there any way to work around wrong monitor EDID then? Is it possible to add a an option in Okular's .config that lets the user override the DPI used.

Incorrect EDIDs are not that uncommon.