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.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

Page Save as

Post Reply
umpani
Posts: 11
Joined: Thu Nov 01, 2018 2:17 pm

Page Save as

Post by umpani »

Hello,

common browser have the possibility to save the loaded page as HTML with all the images and resource files. The HTML is then also changed to load the resourcefiles from disk.

Is there a build in function in CEF4Delphi, to do this without reloading the resources?

Thanks, also for your great work.

Benno
User avatar
salvadordf
Posts: 4575
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Page Save as

Post by salvadordf »

Hi,

I'm afraid that feature is not included in CEF.

You can save the raw HTML file and each image (with some extra code in your app) but as far as I know CEF doesn't modify the internal resource links tbefore you save them in a local drive.

You also have the possibility to save the print the web page as a PDF file or take a screenshot of the web contents.
umpani
Posts: 11
Joined: Thu Nov 01, 2018 2:17 pm

Re: Page Save as

Post by umpani »

Hi,

I‘ve already created such a function. But sometimes, it downloads an image or another resource again, although it has already been displayed.
Is it possible to extract resources from the browser cache and to avoid a further download?

Regards
Benno
User avatar
salvadordf
Posts: 4575
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Page Save as

Post by salvadordf »

I'm not aware of any function to read cache contents directly but you can use a simple TStringList protected by a critical section in the TChromium.OnBeforeResourceLoad event to keep a list of resources. Set the TStringList.Duplicates property to false in order to avoid repeated resources and call TChromium.DownloadImage for each item when the web page is fully loaded.

There are some interesting DevTools methods that you can use too :
https://chromedevtools.github.io/devtoo ... /tot/Page/

I have used only a fraction of those methods but it seems possible to do all kinds of DOM modifications, get resource contents, etc...
Post Reply