TPrintPreview - Anybody to help?

Please post bug reports, feature requests, or any question regarding the DELPHI AREA projects here.

TPrintPreview - Anybody to help?

Postby Kambiz » August 4th, 2004, 7:35 am

sbussinger wrote:My second problem was also related to GetPrinterPageBounds() routine. It returns values based on the physical size of the page rather than the logical size of the page. In my case that's an issue, but it may be better the way it is for everyone else. My problem arises because inkjets tend to have much larger bottom margins than laser printers and my output was getting cropped. I'd like to propose this change to GetPrinterPageBounds():
Code: Select all
Replace

      Result.Right := GetDeviceCaps(Printer.Handle, PHYSICALWIDTH);
      Result.Bottom := GetDeviceCaps(Printer.Handle, PHYSICALHEIGHT);

with

      Result.Right := GetDeviceCaps(Printer.Handle, HORZRES);
      Result.Bottom := GetDeviceCaps(Printer.Handle, VERTRES);

This would mean that if UsePrinterOptions is true, that the page size is based on the printable area of the page rather than on the full size of the page in question. Any thoughts?


I don't have printer to try sbussinger's suggestion on the other kind of printers. Any help would be appreciated.

Greetings,
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Postby aspence » August 6th, 2004, 5:18 pm

GetPrinterPageBounds() does what it is supposed to do I believe and that is to return the physical size of the page. What you are probably looking for and what I was looking for at one point was the rectangle that defines the printable area within the page bounds rectangle. I wrote the following routine to do that:

Code: Select all
// This function should be called immediately after 'BeginDoc'
function GetPrintableRect : TRect;
begin
  with PrintPreview do
  begin
    Result.Left   :=
      ConvertUnits(GetDeviceCaps(Printer.Handle, PHYSICALOFFSETX),
      GetDeviceCaps(Printer.Handle, LOGPIXELSX),
      mmPixel, Units);
    Result.Top    :=
      ConvertUnits(GetDeviceCaps(Printer.Handle, PHYSICALOFFSETY),
      GetDeviceCaps(Printer.Handle, LOGPIXELSY),
      mmPixel, Units);
    Result.Right  :=
      Result.Left + ConvertUnits(Printer.PageWidth,
      GetDeviceCaps(Printer.Handle, LOGPIXELSX),
      mmPixel, Units);
    Result.Bottom :=
      Result.Top + ConvertUnits(Printer.PageHeight,
      GetDeviceCaps(Printer.Handle, LOGPIXELSY),
      mmPixel, Units);
  end;
end;
- Arnold B. Spence
aspence
Active Member
Active Member
 
Posts: 13
Joined: July 11th, 2004, 8:50 am
Location: Wolfville, N.S. Canada


Return to DELPHI AREA Projects

Who is online

Users browsing this forum: No registered users and 2 guests

cron