WPF CEFSharp ChromiumWebBrowser - Render MemoryStream

為{幸葍}努か 提交于 2021-01-27 23:39:43

问题


I need to be able to retrieve a Pdf from our web server via a call to Web API and then render the document in the ChromiumWebBrowser for CEFSharp, all within memory and not saving the file locally.

Right now I'm at the point where I get back the file in a MemoryStream, but can't seem to get any further.

Is this possible? Any examples would be greatly appreciated.

Thanks.


回答1:


You have two options, implement a Scheme Handler for your own custom scheme, e.g. client:// or implement a Resource Handler

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

You can use the default ResourceHandlerFactory if your using just statically generated resources.

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

or implement your own IResourceHandlerFactory

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

Scheme Handler is more complicated, supports async callbacks though. Next version of CefSharp will include support for async resource handlers. (-pre release should be out sometime this week)



来源:https://stackoverflow.com/questions/32052129/wpf-cefsharp-chromiumwebbrowser-render-memorystream

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!