jelmervdl / translatelocally-web-ext

TranslateLocally for the Browser is a web-extension that enables client side in-page translations for web browsers.
https://addons.mozilla.org/en-GB/firefox/addon/translatelocally-for-firefox/
Mozilla Public License 2.0
66 stars 3 forks source link

Translate pdfs #16

Closed jelmervdl closed 2 years ago

jelmervdl commented 2 years ago

Wild idea: can I hook into pdf.js (is Firefox still using that?) and do in-pdf translation? That would be pretty unique.

jelmervdl commented 2 years ago

I think this is impossible for now. Firefox does not allow addons to run on the PDF viewer page, so we would need to ship our own copy of pdf.js. (Edit: note that Firefox' embedded version also has some special integration, like the find-in-page functionality)

pdf.js does have access to text, but not really to the flow of text. It draws the text based on position and 0 opacity to allow copy/pasting. Technically those texts could be rendered visibly to show a translated version of the document.