Bug 226509 - [iOS] Need API to save currently-displayed PDF blob
Summary: [iOS] Need API to save currently-displayed PDF blob
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit API (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-06-01 12:59 PDT by Ali Juma
Modified: 2022-05-09 07:42 PDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ali Juma 2021-06-01 12:59:56 PDT
Steps to reproduce:
1. Visit https://alijuma.github.io/test-pdf.html
2. Tap on “Generate”

This produces a PDF blob and then loads this PDF.

In Safari, it’s possible to save this PDF (tap on the sharing icon, and then “Save to Files”).

However, a WKWebView embedder like Chrome cannot implement the same functionality since there’s no API to save the currently-displayed PDF. Since the blob object no longer exists (since we navigated away from it), the WKWebView download API doesn’t work (the load fails with a WebKitBlobResource error).

Also, since the blob link produced in step (2) doesn’t have a ‘download’ attribute, WKNavigationAction’s |shouldPerformDownload| attribute was false on navigation to the PDF, so the embedder would not have preemptively downloaded the file.

Safari seems to be using SPI to save the PDF after it’s displayed.

WKWebView’s |_getMainResourceDataWithCompletionHandler:| SPI does work in this case, so making this public would be one way to address this issue.

I've also filed FB9124664 for this.
Comment 1 Radar WebKit Bug Importer 2021-06-08 13:00:21 PDT
<rdar://problem/79029343>
Comment 2 Sam Sneddon [:gsnedders] 2022-05-09 07:42:28 PDT
rdar://78728238