Create PDF with quick reports behind Delphi web server

I have a Delphi web server providing some web services *. One of them is to generate and return a PDF report.

PDF creation is done using QReport, which is then exported to a PDF file using the ExportToFilter procedure.

The program works fine when called from within the application, but when called behind TIdTCPServer it hangs and never ends. While debugging it I got the suspension point:

(note: I'm at home now and don't have the source code. I'll try to reproduce the quickrpt.pas source as duplicate as I remember).

procedure TCustomReport.ExportToFilter(TQRDocumentFilter filter);
  ...
  AProgress := TQRFormProgress.Create(Application); // Hangs on this line
  AProgress.Owner := QReport;
  if ShowProgress then AProgress.Show;
  QReport.Client := AProgress;
  ...

      

Searching the web, I found in this page (1) a suggestion to set ShowProgress to False and edit the code so that it does not create a progress form when ShowProgress is set to false (apparently this is because QReport is not thread safe).

So, I edited the code and now I have this:

procedure TCustomReport.ExportToFilter(TQRDocumentFilter filter);
  ...
  if ShowProgress then
  begin
    AProgress := TQRFormProgress.Create(Application);
    AProgress.Owner := QReport;
    AProgress.Show;
    QReport.Client := AProgress
  end;
  ...

      

Now the report is out. But then the service gets an Invalid Pointer Exception (which I cannot track). Subsequent calls to the service succeed, but when I close the service **, it starts whining again with Invalid Pointer Exceptions, after which "MyServer has performed an invalid action and must be closed", Windows message, then again a couple of times more, then only an exception pointer and then comes up with error 216 (which, as far as I can tell, has to do with Windows access permissions).

Thank!

Update (jan 5) . Thanks to Scott W. for the answer. Indeed, after some research, I found another assumption that only the main thread can access some of the components. So I brought the QR code back to normal and called the main method from the call to Synchronize inside TThread (so the main thread will process it). But I still get the same error.

You mentioned that you could generate PDF as a service with QR 4. Maybe that's why it doesn't work for me since I'm using QR 3. On the other hand, you don't say if you are doing what the TIdTCPServer (this is my case by providing web services), or if you start it by itself (for example, during a batch process).

Does anyone know if there might be a problem with my QR code? Thank!

* Run Delphi 7 and QuickReport 3 on Windows XP SP2. The server is based on Indy.

** I have two versions of the server: Windows Application and Windows Service. Both calls are the same inner logic and the problem occurs from both versions.

Update (mar 8) . In the end, my problem was that my print program was in a different DLL, and the default memory management module was somewhat cheesy. Setting my first use of .dpr for ShareMem overrides the memory management module with Borland implementation and solved my problem.

uses
    ShareMem, ...

      

(1): http://coding.derkeiler.com/Archive/Delphi/borland.public.delphi.thirdpartytools.general/2006-09/msg00013.html

+1


source to share


1 answer


I assume it is QReport.Client

used somewhere later in the code, and if your modified code no longer assigns it AProgress, you will get an error.



Are you sure you need to change the QuickReport source? I used QuickReport in Windows Service to generate a PDF and then attached to an email message and everything worked fine without having to change the QR source. I don't remember exactly what settings were to be made, but it was done with Delphi 6 and QR 4.06.

+1


source







All Articles