Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

PDF Viewer - Ability to Save As

Post Reply
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: PDF Viewer - Ability to Save As

Post 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
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: PDF Viewer - Ability to Save As

Post 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.
Post Reply