Blurry PDFs

Steps to reproduce

  • Add a high-resolution PDF to vault
  • Open in Obsidian
  • Open in Chrome

Did you follow the troubleshooting guide? [Y/N]

Y

Expected result

PDF looks the same in both Obsidian and Chrome

Actual result

PDF is blurrier in Obsidian

Environment

SYSTEM INFO:
Obsidian version: v1.4.5
Installer version: v1.4.5
Operating system: Darwin Kernel Version 22.6.0: Wed Jul 5 22:22:52 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T8103 22.6.0
Login status: not logged in
Insider build toggle: off
Live preview: on
Legacy editor: off
Base theme: dark
Community theme: none
Snippets enabled: 0
Restricted mode: on

RECOMMENDATIONS:
none


Additional information

4 Likes

I would like to add that the problem is even worse on mobile (iPadOS 16.6)

1 Like

Possibly related: Blurry pdf preview on Linux ( Fedora )

I get blurry PDFs on windows 11, and had this problem since the launch of the new pdf viewer, and it has survived multiple reinstalls of obsidian and different computers.

I’ve reproduced the problem with a completely fresh obsidian vault, and added debug info as well. This is related to the following bug: Blurry pdf preview on Linux ( Fedora )

Below is a screenshot of the issue, comparing two pdfs side by side, left side using pdfjs directly and right side the viewer inside the obsidian vault. The left hand side looks crisp ‘in-person’, but it’s just that the compression from the screenshotting itself is creating small artifacts, so ignore that.

The left hand side is using pdf.js directly from Mozilla to view the PDF, link to viewer used here: PDF.js viewer

Notice the blurriness is especially visible on small details and equations, and it becomes quite annoying to read text in obsidian due to this.

I’ve noticed that if you nudge the size / aspect of the window in obsidian, sometimes the preview renders the pdf more clearly. I suspect there’s some aspect ratios which get resized better than others. Using pdf.js directly from the link does not exhibit this behavior, it just rescales correctly.

Debug info

*(Notice, it says windows 10, I don’t know why it does that…)
SYSTEM INFO:
Obsidian version: v1.4.12
Installer version: v1.4.5
Operating system: Windows 10 Pro 10.0.22621
Login status: not logged in
Insider build toggle: off
Live preview: on
Legacy editor: off
Base theme: dark
Community theme: none
Snippets enabled: 0
Restricted mode: on

RECOMMENDATIONS:
none

Hey, as I was curious if I could replace the bundled pdf.js viewer with my own, and I needed to familiarize myself with pdf.js and obsidian plugin dev anyway for other things, I managed to get a proof of concept up and running using the standard latest npm version of pdf.js inside obsidian.

The blurriness can be completely removed by changing a parameter given to the pdf object from PDFJS.getDocument. When calling getViewport in pdf.js, this can be adjusted.
I.e. const viewport = pdfPage.getViewport({ scale: 4.0 }); and rendering the pdf via an attached div on the current page.

Everything is completely clear to me now. Given I know obsidian has some more stuff on top of it, so it might not be so simple, but I will further explore this option later and see if I can bundle it as a quickfix via a plugin at some point, unless of course they fix it first :stuck_out_tongue:

Otherwise it might be that this scaling factor is not being set high enough, when the layout logic and similar is getting called natively in obsidian. But it might be other issues, that I am not simply aware of, since I am new to obsidian plugin dev etc.

Hey, i have same Problems on Win 11. Were you able to make a Plugin?

Or could you explain, how you did it? Because in obsidian i dont find any pdf.js file which i could edit. Could you explain which file we hafve to edit and what we have to edit ?

Or please if you already did it, could you make a plugin, if this is not to much work ?

I would like to decide by myself, what scaling i want. Hate pdf viewer, who think no one see’s it, when you scale down.

Hello, i’m new on obsidian but i encounter the same problem and i think it was due to zooming my obsidian window (not my pdf file). By reseting the zoom, my pdf is less blurry. Hope it helps.

1 Like

Could you explain why the text in a PDF becomes blurry when I preview it until I zoom in significantly?

Machine: Windows 11

Obsidian Version: 1.5.12

repro:

  1. Import a PDF file into the vault.
  2. Open the PDF.
  3. Observe that all text appears blurry until I zoom in significantly.

Notes:

  • All plugins are disabled, and I’m using the default theme.
  • This issue persists across different versions of Obsidian, including 1.3.7.

The discussion here might be of your interest:

1 Like

Thank you very much. Setting window.devicePixelRatio to 2 instead of 1 fixed my issue.

1 Like

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

3 Likes

+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.