Add API for saving a PDF
Categories
(GeckoView :: PDF Viewer, enhancement, P2)
Tracking
(firefox110 wontfix, firefox111 fixed)
People
(Reporter: calixte, Assigned: calixte)
References
Details
Attachments
(1 file)
How it works in desktop:
- the user clicks on the save button;
- it triggers a
download
:
https://searchfox.org/mozilla-central/rev/5bcbe6ae54ee5b152f6cef29dc5627ec7c0e1f1e/toolkit/components/pdfjs/content/PdfStreamConverter.jsm#334 - which itself triggers a
saveURL
in the parent:
https://searchfox.org/mozilla-central/rev/5bcbe6ae54ee5b152f6cef29dc5627ec7c0e1f1e/toolkit/components/pdfjs/content/PdfjsParent.jsm#91
The data to save are passed in using a Blob
:
https://github.com/mozilla/pdf.js/blob/d8d5545e03d2c7a17b414a65684a745389f2a614/web/app.js#L1001-L1050
For GV, I think we need to:
- trigger an event from the UI in order to download/save a pdf (a pdf with a form can be modified by the user)
- use the actors added in this patch: https://phabricator.services.mozilla.com/D166566 to ask to the content to send a
Blob
or aTypedArray
- and finally when the data are ready in the parent, we could either use the callback associated to the original event to pass the data (in using a
ByteArray
) or call directly a function which will create aWebResponse
containing the pdf to download.
Anyway it's just ideas so if we can do something better please tell me.
:olivia, what do you think ?
Comment 1•2 years ago
|
||
This outline sounds good to me too.
For GV, I think we need to:
- trigger an event from the UI in order to download/save a pdf (a pdf with a form can be modified by the user)
In patch,- use the actors added in this patch: https://phabricator.services.mozilla.com/D166566 to ask to the content to send a
Blob
or aTypedArray
- and finally when the data are ready in the parent, we could either use the callback associated to the original event to pass the data (in using a
ByteArray
) or call directly a function which will create aWebResponse
containing the pdf to download.
Adding in the Android Components onExternalResponse
implementation link for reference in case we do use a WebResponse
directly.
Probably not needed, but one of the proposed new signatures on the GV Print API is onPrint(InputStream pdfInputStream);
that will send a PDF document to the Android PrintManager, which also has some system save to PDF functionality. Just mentioning this more as an option or workaround. The above outlined download workflow sounds ideal.
Assignee | ||
Updated•2 years ago
|
Updated•2 years ago
|
Assignee | ||
Comment 2•2 years ago
|
||
Comment 4•2 years ago
|
||
bugherder |
Updated•2 years ago
|
Updated•2 years ago
|
Description
•