Andreas,
Hello, I have had the same problem in the past and actually, I am still
having a couple problems with it. Here are some fixes I have come up
with to view the report in a custom preview:
1.frmPreview.qrPrevRpt.QRPrinter := QRPrinter;
frmPreview.qrPrevRpt.QRPrinter.Load(RptName);
frmPreview.qrPrevRpt.QRPrinter := QRPrinter;
frmPreview.qrPrevRpt.QRPrinter.Load(RptName);
if Rptpage = 'Landscape' then
frmPreview.qrPrevRpt.QRPrinter.Orientation := poLandscape
else
frmPreview.qrPrevRpt.QRPrinter.Orientation := poPortrait;
frmPreview.qrPrevRpt.Zoom := 45;
Hide;
frmPreview.ShowModal;
FrmPreview.qrPrevRpt.QRPrinter.Cleanup;
frmPreview.qrPrevRpt.QRPrinter := nil;
Show;
Where frmPreview is a form, qrPrevRpt is a TQRPreview object. This
method will allow me to view the report properly in the custom preview.
It will not print the report though. When I try to call print, only
blank pages are printed.
2. procedure TfrmBatch.PreviewRpt(s: String);
var
PF : TfrmPreview; //Preview object
RP : TQuickRep; //Report object
begin
Screen.Cursor := crHourglass;
RP := TQuickRep.Create(nil);
try
Application.CreateForm(TfrmPreview,PF);
RP.Prepare;
PF.QRPrevRpt.QRPrinter := RP.QRPrinter;
PF.QRPrevRpt.QRPrinter.Load(RptName);
PF.QRPrevRpt.QRPrinter := PF.QRPrevRpt.QRPrinter;
if Rptpage = 'Landscape' then
PF.QRPrevRpt.QRPrinter.Orientation := poLandscape
else
PF.QRPrevRpt.QRPrinter.Orientation := poPortrait;
PF.qrPrevRpt.Zoom := 45;
Hide;
PF.ShowModal;
PF.qrPrevRpt.QRPrinter.Cleanup;
PF.qrPrevRpt.QRPrinter := nil;
Show;
RP.QRPrinter := nil;
finally
RP.Free;
Screen.Cursor := crDefault;
end;
end;
This method views the report properly in the custom preview. However,
even though I set the page orientation, it will only view it Portrait.
This method also allows the user to print the report by calling the
qrPrevRpt.QRPrinter.Print method. However, there is still a problem
with the printing. It appears that with HP Laserjet printers, the
report will print really small in the upper left hand corner of the
paper and only portrait.
Well, there are my findings so far. The fist method works fine for
viewing only. The second method will allow you to print, but with
problems. I hope they help. If you try any of these fixes out and
figure out any of the other problems I have been having, let me know. I
have been driving myself crazy trying to figure it out.
Goodluck,
Melissa Thobe