go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
43.04k stars 5.32k forks source link

Replace vendored pdf.js with webpack-loaded version #18912

Open silverwind opened 2 years ago

silverwind commented 2 years ago

https://github.com/go-gitea/gitea/tree/main/public/vendor/plugins/pdfjs contains a outdated vendored copy of pdf.js. We should instead find a way to load pdf.js via webpack.

The main challenge will be that the "viewer" component (which is basically all the UI for pdf.js) is not part of the official pdf.js distribution, so we need some way to sideload it or some other similar UI, maybe https://github.com/hediet/pdf.js-viewer.

silverwind commented 2 years ago

Or maybe just replace it entirely with https://pdfobject.com/, which is a browser-native pdf viewer. Only issue is that it won't work on mobile at all, so we would display a download link instead then.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.

aceArt-GmbH commented 1 year ago

I created a PoC https://github.com/aceArt-GmbH/gitea/commit/b8cee55f91291076440ca0d986288af7f56bb865 using pdfobject. PDFs should work in latest firefox for android.

Opinions on the issue and the solution? (also technical)

image before -> after

silverwind commented 1 year ago

I did not consider PDFObject so far because of lacking mobile support.

Also see https://github.com/go-gitea/gitea/issues/23994. I think what we should do is to have a viewer-less pdf.js rendering, similar to GitLab or GitHub.