Skip to content

Internal and external PDF viewer, and embedded versus linked PDF's #38

Open
@verelpode

Description

@verelpode

Will WebView2 include a built-in PDF viewer? In comparison, WebView 1 does not display PDF's -- it triggers the event UnviewableContentIdentified whenever PDF is encountered.

Option to hide and show individual buttons in PDF toolbar, etc.

If WebView2 will include a built-in PDF viewer, could you please provide these options that are essential for kiosk modes:

  • Option to enable or disable the built-in PDF viewer. Allow an external PDF viewer to be used. WebView 1 supports external PDF viewers therefore WebView2 should also support it.
  • Option to hide or show the "Save" / "Save As" buttons in the PDF viewer toolbar. The "Save As" button needs to be hidden in kiosk computers in order to prevent access to the local file system or documents folder.
  • Option to override what happens when the "Save As" button is clicked. In this case, the "Save As" button is visible but the app has the option to make the "Save As" button do something other than the default built-in behavior.
  • Option to hide or show the "Print" button in the PDF toolbar.
  • Option to hide or show the "Full screen" button in the PDF toolbar.
  • Option to hide or show the "Add Notes" button that Microsoft Edge currently shows in its PDF toolbar, because this button is unsuitable in shared computer and kiosk mode environments. For example, one user of a kiosk computer should not be able to read the notes created by a previous user.

PDF's via "embed" element versus simple link to PDF

When supporting external PDF viewers, please provide info about whether the PDF is simply a URI to a PDF file versus a HTML <embed> element. In WebView 1, the UnviewableContentIdentified event doesn't say whether it was triggered via an <embed> element or not. Could you please provide this info in WebView2? Here is an example of a HTML snippet that displays a PDF in an <embed> element:

<embed width="100%" height="100%" src="https://www.example.com/xxxxxxxx/TestPdfFile.pdf" type="application/pdf" style="margin:0px;padding:0px;overflow:hidden;display:block;">

Are you able to make WebView2 support an external PDF viewer that also supports the <embed> element meaning an external PDF viewer that is displayed inline/WITHIN a HTML webpage? In WebView 1, this issue is handled in a non-ideal manner. WebView 1 triggers its UnviewableContentIdentified event regardless of whether the PDF content was encountered via <embed> or a simple URI/link to a PDF file, and this works just fine for a simple link to a PDF file, but is somewhat problematic in the case of <embed> because it doesn't report whether the origin is <embed> or not, and it doesn't support an external PDF viewer displayed inline within a page. How can you improve this situation in WebView2? This issue depends on whether or not WebView2 will include a built-in PDF viewer.

Inability to download PDF files because of cookie access failure

Especially when WebView2 is run in a separate-process mode, it is very important to support cookie retrieval, otherwise it becomes impossible for an external PDF viewer to download + display PDFs in all cases.

We are required to download + display PDF files from websites that only authorize the PDF downloads if the correct temporary/session cookie is available, but when WebView 1 runs in a separate process, the temporary cookies in the separate web process are unavailable to the app using WebView. When our app does a HTTP download of a PDF, it uses Windows.Web.Http.HttpClient but HttpClient doesn't see the temporary cookies in the WebView process, thus the website refuses to provide the PDF file.

Our app subscribes to WebView.UnviewableContentIdentified and then uses Windows.Web.Http.HttpClient (or System.Net.Http.HttpClient) to download the PDF file, but the website denies it because of the missing cookie. We need a way of giving HttpClient access to the same cookies as WebView despite the fact they're running in different processes. Thus if WebView allowed us to retrieve the cookies, then we could copy them for use with HttpClient.

Thus for WebView 2, it's important to support cookie retrieval or transfer/sharing between processes.

Even if WebView 2 includes a built-in PDF viewer, cookie retrieval still needs to be supported in order to allow the app to download other file types (other than PDF) when the user clicks a file download link in a webpage.

See also HttpBaseProtocolFilter.CookieManager. Can you make WebView2 more compatible with CookieManager? WebView 1 fails to be compatible with CookieManager when the WebViewExecutionMode.SeparateProcess option is used. Cookies stored to disk can be retrieved, but cookies fail to be retrieved when they are only stored in RAM when:

  • Windows.Web.Http.HttpCookie.HttpOnly == true; or
  • Windows.Web.Http.HttpCookie.Expires == null

Double request for PDF doesn't necessarily work with all websites

Can WebView2 eliminate the double request for the same URL that occurs when the event UnviewableContentIdentified is triggered in WebView 1?

In WebView 1, the procedure is:

  1. WebView requests URL http://ABC.
  2. WebView receives HTTP Response message and notices that the content type is PDF.
  3. WebView notices that it doesn't support PDF, so it triggers event UnviewableContentIdentified and sets WebViewUnviewableContentIdentifiedEventArgs.Uri to http://ABC.
  4. An external PDF viewer receives the event UnviewableContentIdentified and proceeds to use Windows.Web.Http.HttpClient to send a request for the URI specified in WebViewUnviewableContentIdentifiedEventArgs.Uri meaning http://ABC in this example.
  5. Hopefully the website provides exactly the same response when http://ABC is requested for the second time, but this is questionable when the URL is a dynamic web-app and not a simple static file.

To be fully reliable with dynamic web-apps, I think ideally WebView2 would support the external PDF viewer without causing the same URL to be requested/downloaded twice. I think this means WebView2 would have to download the PDF and then transfer the downloaded PDF data to the external PDF viewer, instead of just passing the URL to the external PDF viewer. However, that's extra complexity and I'm unsure how important this is. Admittedly, so far, the particular websites we use function correctly when the same URL (with dynamic content) is requested/downloaded twice. Thus our top priority is actually the cookie problem, not the double request.

AB#28495879

Metadata

Metadata

Assignees

Labels

feature requestfeature requestpriority-lowWe have considered this issue and decided that we will not be able to address it in the near future.trackedWe are tracking this work internally.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions