Why TRVReportHelper wrongly resizes images on print preview?

General TRichView support forum. Please post your questions here
Post Reply
pogocki
Posts: 5
Joined: Wed Mar 28, 2007 10:39 am
Contact:

Why TRVReportHelper wrongly resizes images on print preview?

Post 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
Sergey Tkachenko
Site Admin
Posts: 17564
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
pogocki
Posts: 5
Joined: Wed Mar 28, 2007 10:39 am
Contact:

Post by pogocki »

Thanx. It works exactly how I wanted to.

JP
Post Reply