I’m trying to print multiple copies of an HTML document using the ICoreWebView2_16
‘s Print()
function. The documentation states that “Only one Printing operation can be in progress at a time.”. I’ve tried using a for loop to print multiple times:
for I := 1 to NumberOfCopies do
begin
(EdgeBrowser.DefaultInterface as ICoreWebView2_16).Print(PrintSettings, CoreWebView2PrintCompletedHandler);
end;
This doesn’t work because, as stated, only one print operation can happen at a time.
I’ve also tried using the PrintSettings
parameter to indicate the number of copies, but there are no members for setting the number of copies in the ICoreWebView2PrintSettings
interface. There is a member for settings the number of copies in the ICoreWebView2PrintSettings2
interface… But that can’t be used as a parameter for the ICoreWebView2_16.Print
function.
TEdgeBrowser uses an old WebView2 version. Consider using WebView4Delphi and you’ll be able to set the TWVBrowser.CoreWebView2PrintSettings.Copies property value and then simply call TWVBrowser.Print.
Just to note, if I use the
ShowPrintUI
function, the user can select the number of copies to print… but this doesn’t work because it doesn’t allow me to use my customPrintSettings
What’s
CoreWebView2PrintCompletedHandler
? Wouldn’t that be a perfect place to start the next of N print operation?@AmigoJack After calling the Print function,
CoreWebView2PrintCompletedHandler
stays nil forever.CoreWebView2PrintCompletedHandler
is a function expected to called, not to be set. Since your example code doesn’t include if it’s a variable or a function I can only guess. Handing over a variable that you expect to be set (to what exactly?) is wrong.