Page 1 of 1
Re: PDF Viewer - Ability to Save As
Posted: Tue Aug 13, 2019 5:57 pm
by salvadordf
Use the TChromium.OnBeforeDownload event and use the callback to set the final file path.
Read this for more information about that event :
https://magpcss.org/ceforum/apidocs3/pr ... llback%3E)
https://magpcss.org/ceforum/apidocs3/pr ... lback.html
Re: PDF Viewer - Ability to Save As
Posted: Wed Aug 14, 2019 7:48 am
by salvadordf
That can be difficult...
Chromium uses a built-in PDF viewer with limited functionality and there's no easy way, as far as I know, to detect what the user clicked.
If you want total control when you view PDFs I would consider using a different Delphi component for that task.
The CEF project maintainer also suggests to build the CEF binaries with the desired configuration for the PDF viewer :
https://magpcss.org/ceforum/viewtopic.p ... 806#p29261
As you can see in the DevTools, Chromium creates a simple web page with an EMBED element for the PDF :
Code: Select all
<html><body style="height: 100%; width: 100%; overflow: hidden; margin: 0px; background-color: rgb(38, 38, 38);"><embed width="100%" height="100%" name="plugin" id="plugin" src="http://www.africau.edu/images/default/sample.pdf" type="application/pdf" internalinstanceid="9"></body></html>
Perhaps you can use GlobalCEFApp.OnLoadEnd to visit the DOM and check if the BODY has a simple EMBED child. This information could be used to cancel all downloads.