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.

How to print Silently in Cef4Delphi

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

Re: How to print Silently in Cef4Delphi

Post by salvadordf »

Hi,

CEF3 doesn't support silent printing but there are some workarounds :
marcoscdoni
Posts: 25
Joined: Thu Sep 21, 2017 4:33 pm

Re: How to print Silently in Cef4Delphi

Post by marcoscdoni »

Hello Salvador, me again!

Now I was able to print to PDF. I'd like to achieve automatically save. I've tried save pdf OnLoadEnd but the generated file is blank. It looks like is some delay for the pdf to be displayed after load end.

How could I know for sure when the pdf file was completely displayed? Through the LoadingProgressChange method, testing the progress = 1 parameter also did not work.
User avatar
salvadordf
Posts: 4084
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How to print Silently in Cef4Delphi

Post by salvadordf »

Hi,

You need to use the TChromium.OnPdfPrintFinished event to know when it's ready to be used.
The MiniBrowser demo uses that event in the "Chromium1PdfPrintFinished" procedure.
marcoscdoni
Posts: 25
Joined: Thu Sep 21, 2017 4:33 pm

Re: How to print Silently in Cef4Delphi

Post by marcoscdoni »

Salvador, sorry, but I do not think that's be right. The OnPdfPrintFinished method is executed after the PrintToPDF function has been executed and returns whether it was successfully printed or not, that is, after printing was requested by the PrintToPDF method. My goal is to actually know when the PDF document has already been fully loaded in the browse and then call the PrintToPDF method. When calling the PrintToPDF method in the LoadEnd event for example, even checking the status is 200 the generated file is blank.
User avatar
salvadordf
Posts: 4084
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How to print Silently in Cef4Delphi

Post by salvadordf »

Sorry, I misunderstood.

I'm not aware of any event that is triggered when the PDF plugin or any other element finishes rendering.

The events available are these :
  • TChromium.OnLoadingStateChange
  • TChromium.OnLoadEnd
  • TChromium.OnLoadingProgressChange
All of them are triggered at different loading states but the document rendering may never end in a web page.
Post Reply