Board index » delphi » Capturing image of quickrep

Capturing image of quickrep

Hi,

I have had a request to capture an image of a quickreport. Basically the
idea is that the application generates a page of a product catalogue
using QR. The output from this is captured as an image of some sort that
can be emailed to a customer.

This seems to be allowed for in the exporttofilter method for the
quickrep component. And that would work quite nicely, as attaching the
.HTM file to an email message is simple. But... when I insert the text
of the example in the help file, TQRHTMLDocumentFilter produces a
compiler error noting it as an undeclared identifier. I assume it is
declared somewhere else, but where?

As a matter of interest how would you capture a quickrep as a .JPG file
for instance? Via the printer canvas? I suspect this would have come up
before, but I can't see anything in the current postings.

Richard

 

Re:Capturing image of quickrep


Hi Richard,

Here's some information...

Quote
> I have had a request to capture an image of a quickreport. Basically the

...
var
 BMP: TBitmap;
 OldUnits: TQRUnit;
 I: Integer;
...
 with QuickRep do
 begin
  Prepare;
  OldUnits := Units;
  Units := Pixels;
  BMP := TBitmap.Create;
  try
   for I := 1 to QRPrinter.PageCount do
   begin
    BMP.Width := Round(Page.Width);
    BMP.Height := Round(Page.Length);
    QRPrinter.PageNumber := I;
    BMP.Canvas.Draw(0, 0, QRPrinter.Page);
    BMP.SaveToFile(ReportTitle + IntToStr(I) + '.bmp');
   end;
  finally
   BMP.Free;
   Units := OldUnits;
  end;
 end;

You will also need to free QRPrinter at the end (and correct the code as the
compiler points out <g>).

To save as JPEG you can use the same code but instead of BMP.SaveToFile...
Assign BMP to a TJPEGImage object and call SaveToStream on it, passing a
TFileStream object.

Quote
> of the example in the help file, TQRHTMLDocumentFilter produces a
> compiler error noting it as an undeclared identifier. I assume it is
> declared somewhere else, but where?

Add 'QRExport' to the uses list.

--
Girish Patil
Pragnaan Software
http://www.pragnaan.com
PsQRFilters, WYSIWYG Export Filters for QuickReport!
PsFRExportFilters, WYSIWYG Export Filters for FastReport!

Other Threads