WebWindow | NET Core library to open native OS windows containing web UI
kandi X-RAY | WebWindow Summary
kandi X-RAY | WebWindow Summary
For information, see this blog post.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of WebWindow
WebWindow Key Features
WebWindow Examples and Code Snippets
Community Discussions
Trending Discussions on WebWindow
QUESTION
In my WPF application I have a window that loads an html string to show to the user. Then there is a Button that let the user open the printing dialog and print the document (using the javascript code window.print();).
The problem is: if the html document contains an embedded pdf (
Here it is the same code in a sample application to reproduce the problem (comment the call to GetHtmlWithEmbeddedPdf to see the dialog working, and decomment it to see the error).
The Window:
...ANSWER
Answered 2021-Mar-30 at 11:18This is a security feature, not a bug. It's also not limited to WebView2 but applies to Chromium in general.
The embedded PDF object is causing the HTML document to be sandboxed. Thus preventing window.print()
from executing as usual.
This is as specified by the HTML specification:
The printing steps for a Document document are:
- ...
- If the active sandboxing flag set of document has the sandboxed modals flag set, then return.
This is also why Ctrl+P still works and brings up the print dialog, as it is a user action not affected by this security issue.
WorkaroundUntil WebView2 "natively" supports printing, the best workaround I can currently think of is to load the PDF inside an iframe
, thus freeing the parent document from being sandboxed:
QUESTION
In my WPF application I need to show an html string, and I know that I need to call EnsureCoreWebView2Async method before calling NavigateToString because otherwise the CoreWebView will be null and I would have an exception. The problem is that awaiting EnsureCoreWebView2Async never ends.
I created a little application in order to reproduce the problem (and excluding issues related to my big project) and the problem is the same.
- If I set the WebView2's Source property passing an Url, then it works!
- If I call NavigateToString without calling EnsureCoreWebView2Async, I get an exception (as expected).
- If I call EnsureCoreWebView2Async before calling NavigateToString or before setting the Source property (it should not be a problem, because calling it many times should not have any effect according to the documentation) then it hangs forever. No exceptions are raised by the call, and no messages in the console. Very frustrating.
Here are the code for the sample application (I main window with 2 buttons, one that opens the url and one that load the html string - the first one works):
...ANSWER
Answered 2021-Mar-27 at 18:21You should defer to initialize the webview until OnContentRendered is called. I changed your code and it worked as a charm. See the changes below.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install WebWindow
Windows, Mac, or Linux
Node.js (because WebWindow.Blazor.JS includes TypeScript code, so the build process involves calling Node to perform a Webpack build)
If you're on Windows: Use Visual Studio with C++ support enabled. You must build in x64 configuration (not AnyCPU, which is the default). If things don't seem to be updating, try right-clicking one of the testassets projects and choose Rebuild to force it to rebuild the native assets.
If you're on macOS: Install Xcode so that you have the whole gcc toolchain available on the command line. From the repo root, run dotnet build src/WebWindow/WebWindow.csproj Then you can cd testassets/HelloWorldApp and dotnet run
If you're on Linux (tested with Ubuntu 18.04): Install dependencies: sudo apt-get update && sudo apt-get install libgtk-3-dev libwebkit2gtk-4.0-dev From the repo root, run dotnet build src/WebWindow/WebWindow.csproj Then you can cd testassets/HelloWorldApp and dotnet run
If you're on Windows Subsystem for Linux (WSL), then as well as the above, you will need a local X server (example setup).
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page