Page 1 of 1

TRVPrint.Print not printing (not arriving in printer queue)

Posted: Wed Nov 27, 2013 10:52 am
by DSE
Sometimes when we print from TRVPrint, nothing arrives in the Windows printer queue (from then on consistently - although this might only happen after a few hundred copies who'd just print fine). If we select another printer everything works fine again (for some time). Restarting the application and/or the Windows session does sometimes 'solve' the problem, but not always.

We've updates all printer software (including firmware), and went from network printers to local printers. There's nothing 'special' with the printout before the first faulty one (no errors).

Code looks like this (pdRapToon = printer dialog; rvpRapToon = TRVPrint; rvRapToon: TRichView):

Code: Select all

     
  if pdRapToon.Execute then try
    rvpRapToon.AssignSource(rvRapToon);
    rvpRapToon.FormatPages(rvdoAll);
    rvpRapToon.Print(Caption, pdRapToon.Copies, true);
    rvpRapToon.Clear;
  except
    //some logging
  end;
Any idea anyone?

Posted: Thu Nov 28, 2013 10:02 am
by Sergey Tkachenko
I am afraid I do not know why it happens :(

TRichView relies on TPrinter for printing, its printing code contains nothing special - it used Printer.BeginDoc, NewPage, Canvas, EndDoc.

Are there any exceptions?

Posted: Thu Nov 28, 2013 11:12 am
by DSE
Nope, no exceptions. From a Delphi point of view everything works fine.

I'm now adding extra logging to the RichView code, to see where the flow exits.

Posted: Thu Jan 23, 2014 9:37 am
by DSE
I tracked it down to RV_GetPrinterDC. In the cases nothing happens no device context is created (0). This leads to IsDestinationReady = false, which means no formatting, which means lastPgNo = 0 and firstPgNo = 1, which leads to a silent exit in TPrintableRV.PrintPages.

Any ideas why CreateDC sometimes returns 0 (and continuously from then on)?

Posted: Sat Jan 25, 2014 9:05 am
by Sergey Tkachenko
Sorry, I do not know :(

What version of Windows do you use?

Possible problems:
http://support.microsoft.com/kb/967663
http://support.microsoft.com/kb/972616

Posted: Mon Jan 27, 2014 12:50 pm
by DSE
Hello Sergey,

I found these also. We will be trying them this week.

Maybe it's an idea to throw an exception if no canvas is allocated, instead of this 'silent exit'. That will be at least my 'solution'.

Thanks for the support!

Posted: Mon Jan 27, 2014 1:06 pm
by Sergey Tkachenko
There is no exception, but you can check RVPrint.IsDestinationReady property (after calling FormatPages)