okfde / froide

Freedom Of Information Portal
MIT License
357 stars 86 forks source link

Colored PDF only shown in grayscale and broken in request #401

Closed rugk closed 3 years ago

rugk commented 3 years ago

In a little embarrassing conversation I had to notice that the PDF the agency sent to me is disturbed: The following energy performance certificate is correctly shown to me in a local PDF viewer (Envince 3.38.0 on GNOME), b ut broken on the website: https://fragdenstaat.de/anfrage/energiebedarfsausweis-fur-gebaude-landesbetrieb-information-und-technik-nordrhein-westfalen-mauerstrae-5-140476-dusseldorf/550050/anhang/WE2330Ausweis_2.pdf

I know you can do nothing here, and noticed it is actually an issue in PDF.js, so I've opened this issue: https://github.com/mozilla/pdf.js/issues/12752

Just in case someone else has a similar issue or get the documents from the same agency (Bau- und Liegenschaftsbetrieb NRW), you now know what is causing this. And you can close this if upstream has fixed this issue and you've updated your platform.

arnese commented 3 years ago

Perspektivisch werden das sowieso alles Dokumente wie hier schon mal gemacht. https://fragdenstaat.de/dokumente/7996-we2330ausweis_2/

rugk commented 3 years ago

Ah danke! Das ist ja cool.

alehaa commented 3 years ago

Hier habe ich dasselbe Problem, nach einem Download kann ich die Datei aber "normal" betrachten.

@arnese es wurde Upstream inzwischen ein Patch bereitgestellt. Könnt Ihr diesen ggf. auf FdS deployen?

arnese commented 3 years ago

@alehaa nächstes Jahr :)

Ryuno-Ki commented 3 years ago

Also dieses?

stefanw commented 3 years ago

I tried to upgrade to latest pdf.js viewer, but there are problems with our CSP disallowing eval. Feel free to make latest pdf.js viewer work without eval and let me know how it goes.

rugk commented 3 years ago

How do you include it and what are the errors? Because this seems to be a well-known error, see https://github.com/mozilla/pdf.js/issues/12105, actually https://github.com/mozilla/pdf.js/issues/11036, a downstream dependency of PDF.js seems to have an issue.

So could you switch to:

A modern build (for up-to-date browsers), which is not transpiled with Babel and without any included polyfills.


That said, BTW, the last pdf.js release AFAIK does not include the patch for this issue (look at the dates). It's not released yet. That said, updating pdf.js never hurts, you need to do it anyway at some point.

stefanw commented 3 years ago

We can‘t use a version that breaks CSP or breaks older browser compat (older here means does not support things like optional chaining which is quite a few). We are using the viewer from pdf.js demo with some changes (no url validation, eval off, de locale, reduced toolbar): https://github.com/okfde/django-filingcabinet/tree/master/filingcabinet/static/filingcabinet/viewer

alehaa commented 3 years ago

Is there any update on this issue? I'm still observing it in some request answered by a specific authority.

stefanw commented 3 years ago

PDF.js has been updated to latest stable version. The mentioned PDFs are now rendering ok.

Where PDFs are just shown (via iframe) we are no longer using a bundled version of pdf.js but the native browser PDF viewer (which for Firefox is pdf.js). PDF.js is used to augment our document viewer, in the redaction process and for attachment previews in the message attachment manager.