Blurry pdf preview on Linux ( Fedora )

Steps to reproduce

You may try to import a pdf then zoom in and zoom out.
It’ll look very blurry.
While I can reproduce this issue on Linux.
Its not found on windows.

Did you follow the troubleshooting guide? [Y]

Yes I have.

Expected result

Sharp Pdf Preview

Actual result

Blurry mess

Environment


Additional information

1 Like

+1

The same happens to me. I’m using Obsidian on Ubuntu 22.04.2 LTS.

Can you post a screenshot? Also how does the same a pdf look like with chrome using this https://mozilla.github.io/pdf.js/web/viewer.html?

Are you using X, Xwayland, or Wayland?

I’m using Wayland ( Fedora 38 )

Same pdf would look sharp on chrome.

I also have blurry PDFs, but I’m on windows 11.
I’ve noticed that depending on the scale of the pdf getting rendered inside the obsidian window bounds, it sometimes renders more clearly. I can nudge it to go from badly blurry to better blurry.
I suspect it is because whatever scaling algorithm is being used works better at certain aspects than others when it tries to approximate pixels. I don’t have this problem with the built-in pdf viewers of the browsers I use.

You need to test chrome using the pdf viewer I shared in that link not the chrome build in pdf viewer

Ah, sorry, obsidian is more blurry than the same pdf opened in that viewer you linked.

I’ve screenshotted both apps in one go, and the blurriness is visible if I open the attached image itself so it’s full screen.
And while the image compression is altering the results, since the left one is clear to me ‘in-person’, you can see that the right one, which is from obsidian, is more blurry when compared side by side, especially if you look at the formulas.

So it’s clear that something is messing with the rendering, since it’s screenshoot directly from windows. I’ve had this problem from day 1 of the new pdf viewer, and had hoped it would be fixed with time, because it’s quite annoying to read blurry text when I’m reading longer texts and doing notes back and forth. Side note, this bug survived multiple reinstalls of obsidian for me, since I’ve changed computer since I first experienced it.

Hey, this might also be fixable on linux by changing the parameters for calculating scale for pdf.js. i.e. pdfPage.getViewport({ scale: 5.0 });
I can fix this problem by replacing pdf.js with my own bundled version where I can adjust the parameters, and I’ve tried to change the parameters of the built-in pdfjs, but I cannot access them, even though I’ve tried monkey patching and proxying, since they are protected. And the place where obsidian loads pdfjs lib itself is nested inside a place I cannot access either.

Can you do that also on Windows somehow? Would you explain, how to change pdf scaling factor in obsidian on windows?

I would also like to decide by myself, what scaling factor i want to use. Im sure developer will not make it as sharp as i want.

Hey, seeing the lack of response from on this issue from obsidian both here and on discord, (it might be they just have bigger issues they would rather fix), I think the solution is to make a plugin.

Finding pdf.js can only be done by monkey patching/proxying your own javascript into obsidian after it has loaded. But after trying that route for a bit, and finding out they have made everything hard to adjust outside their API (probably due to security), I’ve found that it would take too much time to patch their software and it’s easier to bundle another version of pdf.js myself.

I have already got the bundling to work, but it’s in no way user friendly at this point, but it works as a proof of concept. When I have time (hopefully in the coming weeks), I will make a plugin which allows you to tweak the settings given to pdf.js yourself which then ships with its own version of pdf.js.

I don’t think they are going to fix this issue, even if the fix itself would be very simple for them to make, but hard for others because they minify and bundle everything into their executable. At this point I’ve read a lot of their emitted code, and it looks like it’s just a question of changing some min/max parameters and a resolution estimation function they made which I think lowballs the needed quality.