izuzak / atom-pdf-view

Support for viewing PDF files in Atom.
https://atom.io/packages/pdf-view
MIT License
106 stars 30 forks source link

Black blocks obscuring text in PDF files #62

Closed frxstrem closed 9 years ago

frxstrem commented 9 years ago

I use pdf-view to render LaTeX files I compile in real time. I have recently come across what seems to be a bug in the rendering of the pages, which leads some of the text and formulas to be obscured by black boxes, similar to those that appear when selecting text in a normal PDF viewer.

This happens almost every time, but not always, and the part (and amount) of the text obscured varies for each time the file is opened. The obscured part is almost always at the bottom of the page.

I have had this problem on (at least) the following versions:

Below is the same part of the same file, along with the black boxes that appear. (The black edge at the bottom of the pictures is the separator between the pages.)

screenshot 1 screenshot 2

izuzak commented 9 years ago

Thanks for the report. Can you share a link to one PDF where you're seeing this?

frxstrem commented 9 years ago

Sure, here:

https://www.dropbox.com/s/txxvgxzu3dk8sg2/pdf-view%20bug%2062.pdf?dl=0

izuzak commented 9 years ago

Thanks! I'm having trouble reproducing this, though -- I just reloaded that PDF ~20 times and it never showed the black regions as in the screenshot. Not sure what this might be related to. I just upgraded the pdf.js dependency (the library which is used to render PDFs) and published a new version (see https://github.com/izuzak/atom-pdf-view/pull/63). Can you try updating to atom-pdf-view v0.20.0 and see if you can still reproduce?

If you can reproduce after updating, can you try loading the PDF in the pdf.js viewer https://mozilla.github.io/pdf.js/web/viewer.html and see if you can reproduce it there?

frxstrem commented 9 years ago

I suspect it's due to some factor local to my machine. I still get the same result after updating pdf-view and restarting Atom, but I don't get the black regions in the online viewer (using Chrome).

I tried switching themes in Atom, and it seems that the color of the "black" regions depend on the background color of the pane (as shown on the left side below). Switching to a lighter theme also made the black regions lighter:

screenshot light

It seems that for some reason, these regions are rendered as transparent on the canvas, and switching the background color of the canvas in the developer tools confirms that this is what happens.

frxstrem commented 9 years ago

I tried changing the background of the document to green (link) and then opening it in the online pdf.js viewer. It seemed to produce the same regions (just white) as in pdf-view when viewed in Chrome 41 (the version used by Atom), but not after updating to Chrome 42. I assume that there therefore is a bug in pdf.js and not in pdf-view, and that may be fixed as Atom updates to Chrome 42. Until then, the workaround I found involved changing the canvas background color to white (which works most of the time since most documents have a white background):

/* styles/pdf-view.less */
.pdf-view .page-container {
  background-color: white;
}
izuzak commented 9 years ago

Thanks for letting me know -- great work on investigating this! :mag_right:

An update to Chrome 42 should happen soon, see https://github.com/atom/electron/issues/1424.