Well, I did it.
In case this helps, here are the most important changes I had to make:
1) Any function that executes javascript code through the
EvaluateScriptAsync extension function needs to be awaited, otherwise the function call will simply freeze and never return anything back.
2) Calling
async functions that use
EvaluateScriptAsync to execute javascript code from the
FrameLoadEnd is a no no. In order to maintain my original code structure I had to store the function that I wanted to call (using a delegate) and then call the appropriate function from the
LoadingStateChanged event handler instead, which is called shortly after
FrameLoadEnd.
3) Finally, my original code based on Awesomium 1.7.5.1 instantiated
WebSessions through the
CreateWebSession static method and set the
WebPreferences PdfJS property to
False. This caused the internal chromium instance to trigger a download request for any PDF file that was loaded. This allowed me to have full control over the download process through the
WebCore.DownloadBegin and
WebCore.Download event handlers. Very handy and very easy to implement and maintain.
Unfortunately, there appears to be no way to do this in CefSharp. I tried creating a
DownloadHandler and that didn't work. I even tried deleting the pdf_js.pak to no avail. Every time you load a PDF file, the file is simply displayed and it never triggers a download request.
Fortunately, I was able to find a piece code that uses an
IRequestHandler and
IResponseFilter to manually capture the PDF stream and saves it to a file:
https://stackoverflow.com/questions/372 ... p/37418798I really hope this saves some time to anyone going through the process of moving from Awesomium.