Solved

Printing problem - the job disapears from the spooler

Posted on 2003-11-01
3
531 Views
Last Modified: 2012-08-14
Environment:
  OS: Windows XP
  Programming language: Delphi 4 + service packs
  VCL component version: 7.4.0.41, VCL for Delphi 4
  Crystal Reports: Development Edition 8.5.0.217

Specification:
The program has to print a crystal report without user intervention to a nominated printer in the program's options. This is part of a automated process and it should just print the report and move on.
I have currently installed 3local printers: Genreric Text ,Panasonic KX-P6100 , dummy printer that prints to a file

Depending on wich is my default printer and which printer is set up in the program's option I get the strage situation when the report is sent to the spooler, it sits there for a half of second saying "Spooling" and that it disapears. There are no errros and no messages. This happens when I tell the report on which printer to print.
If I bring up the printer selection dialog and select the printer than it work juts fine.

Here is the calling code for the crystal report that I am using:

Oderreport: TCrpe; - this is the static Crystal Report component on the form
*****************
      OrdersReport.Clear;
      OrdersReport.ReportName :=  'name of the report file.rpt' ;
      //Set database location
      OrdersReport.Tables.Retrieve;
      OrdersReport.Tables[0].Path := SysControl.DataDirectory;
      OrdersReport.Tables.Propagate := True;
      OrdersReport.output := toPrinter;

      OrdersReport.Printer.Name := SysControl.PrinterName;
      OrdersReport.Printer.ShowDialog := False;
      OrdersReport.Execute;
*************************

SysControl.PrinterName is pick-up up from the options of the program and it's the name of a windows printer as in Printer.Printers[2] wich returns the third printer in the windows printer list.


If I change in the code above only
   OrdersReport.Printer.ShowDialog := True;
and I hit the OK button on the Printer Dialog that appears it will print the report without problems.

Does anyone ever had or encoutered this problem ?

Thank you for your help.
0
Comment
Question by:Tavirgil
  • 2
3 Comments
 
LVL 100

Accepted Solution

by:
mlmcc earned 100 total points
ID: 9665771
This link shows how it can be done in VB.  A similar approach should work from Delphi

http://www.experts-exchange.com/Databases/Crystal_Reports/Q_20762547.html

mlmcc
0
 

Author Comment

by:Tavirgil
ID: 9792193
I followed up on your advice to read from your post in VB and I've made sure that the report gets all the values needed for the printer (name, driver, port, handle).

This should be the case since in Crystal 8.5 it's adversited that you only need to put the name of the printer and crystal takes care of the rest.

Anyway I used some Windows API functions together with some Delphi functions to get these values rigth.

If anyone interested please tell me.

Thank's for the advice mlmcc and I'll accept your advice since I need it for a VB project that does the same thing as this one: sends the report to the spooler and the job just disapears. I believe I'll take the same aproach but just your code from the answer you pointed me too.

Cheers and thanks a lot.

Virgil
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 9792656
Glad I could help.

mlmcc
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question