Closed Bug 1810761 Opened 1 year ago Closed 1 year ago

Add API for saving a PDF

Categories

(GeckoView :: PDF Viewer, enhancement, P2)

All
Android
enhancement

Tracking

(firefox110 wontfix, firefox111 fixed)

RESOLVED FIXED
111 Branch
Tracking Status
firefox110 --- wontfix
firefox111 --- fixed

People

(Reporter: calixte, Assigned: calixte)

References

Details

Attachments

(1 file)

How it works in desktop:

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 a TypedArray
  • 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 a WebResponse 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 ?

Flags: needinfo?(ohall)
Blocks: 1810106

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 a TypedArray
  • 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 a WebResponse 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.

Flags: needinfo?(ohall)
Assignee: nobody → cdenizet
Status: NEW → ASSIGNED
Severity: -- → N/A
Priority: -- → P2
Pushed by cdenizet@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/a356e2d3cf46
Add API to save a pdf file opened in pdf.js r=pdfjs-reviewers,geckoview-reviewers,marco,ohall,calu
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 111 Branch
Component: General → PDF Viewer
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: