Page 1 of 1

TPrintPreview event to cancel printing...

PostPosted: October 19th, 2018, 4:41 pm
by mrtossas
Hi,

In TPrintPreview 5.30, this is my code:

Begindoc;
for i := 1 to 1000 do begin
Print YYY ZZZ...
if XXX then NewPage;

if finish_now then begin
EndDoc;
PrintPreview.Abort;
ShowMessage('Canceled Print');
end;

end; // for
EndDoc;

BUT in TPrintPreview 5.30 not exit the Abort method...

How would I have to rewrite my code in order to cancel the printing when I needed it?

Thanks!

Re: TPrintPreview event to cancel printing...

PostPosted: November 17th, 2018, 12:49 pm
by Kambiz
Hi,

If you are creating pages, your code should handle cancellation.
If you are printing or exporting pages, you can use OnPageProcessing event to cancel the operation.
To cancel a print job, call the Abort method of the global Printer object.