Page 1 of 1

Why TRVReportHelper wrongly resizes images on print preview?

Posted: Thu May 24, 2007 1:13 pm
by pogocki
Hi!
I use TRVReportHelper in my project and when I insert an image into a header or footer, the size of image is about 5 times smaller then original size. On the printer the size is correct, the problem is only in print preview.
The example of my problem is in the project here: http://pogocki.waw.pl/smaller_footer_images.zip

Where is the problem - in my source code, or in RV?

Thanx in advance
JP

Posted: Thu May 24, 2007 5:36 pm
by Sergey Tkachenko
The following things must be changed:

1) Add PrnCanvas: TCanvas to the form's private variables.

2) Change these procedures to use PrnCanvas:

Code: Select all

{ Menu: Print preview }
procedure TForm1.Preview1Click(Sender: TObject);
var DC: HDC;
begin
  DC := RV_GetPrinterDC; // from PtblRV unit
  PrnCanvas := TCanvas.Create;
  try
    PrnCanvas.Handle := DC;
    PrnCanvas.Font.PixelsPerInch := GetDeviceCaps(DC, LOGPIXELSY);
    FormatDoc(PrnCanvas);
    Preview(PrnCanvas);
  finally
    PrnCanvas.Handle := 0;
    DeleteDC(DC);
  end;
end;

{ Menu: Print }
procedure TForm1.Print1Click(Sender: TObject);
var  DC: HDC;
begin
  DC := RV_GetPrinterDC; // from PtblRV unit
  PrnCanvas := TCanvas.Create;
  try
    PrnCanvas.Handle := DC;
    PrnCanvas.Font.PixelsPerInch := GetDeviceCaps(DC, LOGPIXELSY);
    FormatDoc(PrnCanvas);
    Print;
  finally
    PrnCanvas.Handle := 0;
    DeleteDC(DC);
  end;
end;
3) In TForm1.RVPrint1PagePrepaint, use PrnCanvas as the first parameter of rvhHeader.Init and rvhFooter.Init.

Posted: Mon May 28, 2007 10:00 am
by pogocki
Thanx. It works exactly how I wanted to.

JP