-
We have a use case for which we always need to render PDFs inside the browser, even if the response has e.g. the content disposition set to "attachement" (and not "inline") or if the link to the PDF specifies the download attribute. I already managed to detect a PDF document download, cancel it and spawn a new browser control with the URL of the PDF, but now it is unclear to me how I can force the rendering of a PDF document with the internal PDF viewer (PDFium)? Is there a special URL format or scheme I need to use (e.g. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
It's not clear what you've actually tried or the current behaviour you are seeing.
What do you mean exactly? Just load the
There is a scheme from memory, I've never tried to interact with it directly. |
Beta Was this translation helpful? Give feedback.
-
@dbuechel You can achieve it by using PDFJS, there is an example here: https://github.com/cefsharp/CefSharp/wiki/Embedding-PDF.JS-in-CEFSharp |
Beta Was this translation helpful? Give feedback.
If your going to keep the stream in memory then Request Interception is one option.
There's a simplified option available using
RegisterResourceHandler
. Basically you tell the browser that for the given url it should load the stream. Then you load the url.CefSharp/CefSharp/WebBrowserExtensions.cs
Line 1003 in 2cb81aa