WPF CEFSharp ChromiumWebBrowser - 渲染内存流

WPF CEFSharp ChromiumWebBrowser - Render MemoryStream

我需要能够通过调用 Web API 从我们的 Web 服务器检索 Pdf,然后在 ChromiumWebBrowser 中为 CEFSharp 呈现文档,所有这些都在内存中,而不是在本地保存文件。

现在我正处于从 MemoryStream 中取回文件的阶段,但似乎无法取得任何进展。

这可能吗?任何例子将不胜感激。

谢谢。

您有两个选择,为您自己的自定义 scheme 实施 Scheme Handler,例如client:// 或实施 Resource Handler

https://github.com/cefsharp/CefSharp/blob/cefsharp/41/CefSharp.Example/CefSharpSchemeHandler.cs#L46

如果您只使用静态生成的资源,则可以使用默认值 ResourceHandlerFactory

https://github.com/cefsharp/CefSharp/blob/cefsharp/41/CefSharp.Example/CefExample.cs#L98

或实施您自己的 IResourceHandlerFactory

https://github.com/cefsharp/CefSharp/blob/cefsharp/41/CefSharp/DefaultResourceHandlerFactory.cs

Scheme Handler 更复杂,但支持 async 回调。 CefSharp 的下一版本将包括对 async 资源处理程序的支持。 (-pre 应该会在本周某个时候发布)