Open Bug 810815 Opened 7 years ago Updated 4 years ago

Integrate pdf.js to Thunderbird

Categories

(Thunderbird :: General, defect)

x86
Linux
defect
Not set

Tracking

(Not tracked)

People

(Reporter: smaug, Unassigned)

References

(Blocks 1 open bug, )

Details

(Whiteboard: dupme)

It would be very nice to be able read pdf files inline.
Whiteboard: dupme
I spent one our two nights trying to make that work out. I somehow managed to make double-clicking on an attachment open up a pdf.js content tab, but then pdf.js was unable to download the attachment because it's an imap:// URL and there's some hackery involved. Conversations bundle a pdf.js-based viewer, which does have the hackery, but conversely, does not have the full-fledged PDF.js UI, unfortunately.

All in all, I don't think it's that much work required, but it probably requires some pdf.js knowledge which I don't have. And also, it was quite some time ago :)
Is pdf.js even ready? It seems it was postponed from some FF versions. But I see it is enabled now in Aurora 18.
(In reply to :aceman from comment #2)
> Is pdf.js even ready? It seems it was postponed from some FF versions. But I
> see it is enabled now in Aurora 18.

It's stable enough to handle most of the PDFs I have to read (admittedly, mostly just academic papers, so not a strong indicator of general reliability).
IIRC pdf.js wasn't enabled in < FF18 because Gecko lacked some printing related features which
pdf.js needs.
From what I recall, pdf.js runs as a content script, but in the context of Thunderbird, you need to run with chrome privileges to download the contents of an attachment (which does indeed make a lot of sense!). So what is needed is to add an extra wrapper that fetches the contents of the attachment, and then passes it to pdf.js, for instance through a string in the URL, bypassing the default method for downloading a PDF (which is based on an XMLHttpRequest I think).
Do you have a patch for that WIP experiment?
Blocks: 977822
CC some pdf.js developers

(In reply to Magnus Melin from comment #6)
> Do you have a patch for that WIP experiment?
Ping Protz
Flags: needinfo?(jonathan.protzenko)
The code is in Conversations: https://github.com/protz/GMail-Conversation-View/tree/master/content/pdfviewer

There's an outer, chrome XUL window here: https://github.com/protz/GMail-Conversation-View/blob/master/content/pdfviewer/wrapper.js

It wraps the PDF contents as strings, which it then passes into the inner, HTML content window by calling its init function: https://github.com/protz/GMail-Conversation-View/blob/master/content/pdfviewer/viewer.js#L131

The inner HTML window then does the pdf.js incantations that allow the PDF to be rendered.

I completely gave up on adapting the addon "as-is"; I don't think I got very far anyway, and the code changed so much back then that it was pretty difficult to keep up with it. What I have now is a suboptimal viewer bundled with Conversations, but well, that does the job for now!
Flags: needinfo?(jonathan.protzenko)
You need to log in before you can comment on or make changes to this bug.