Closed rgolomidov closed 5 months ago
@victorhuangwq if you are attempting to load the PDF from an arbitrary local on the device's file system, you just run into an error. As this could be a security issue. If you wish to load a PDF from the device, you should be able to leverage the SetVirtualHostMapping()
method, mention here.
You'll just need to ensure that the PDF is deployed as an asset/resource with your APPX, with the correct relative path.
Thank you, the error no longer appears, but now the application crashes every time. I will try to get this under control. The PDF file is on a server and is downloaded at runtime and stored in the ApplicationDataPath, from where it is then accessed via WebView.
it work now! The SetVirtualHostMapping() is the way to go
Some example of how that worked for me
((IWithVirtualHost)webView).SetVirtualHostMapping("webview2.sample", Application.dataPath + "/StreamingAssets/"); webViewComponent.Load(new Uri($"http://webview2.sample/{this.fileName}"));
Actually, if some trouble in path string, Unity crashes and shutdown (nothing about raising errors, exceptions, or Bug console for Unity).
Hello, I am developing an application for HoloLens 2, integrating Unity 2021.3.32f1 with a UWP application. My application, which involves loading a PDF file in WebView2, works as expected when using Holographic Remoting but encounters an “ERR_Blocked_by_client” error when run directly on HoloLens 2 as a UWP application. This problem persists even with the standard "WebView2Samples" project, indicating a broader issue.