Scalabium Software

 

SMExport/SMImport suites

Knowledge for your independence.
 

 
Home Delphi and C++Builder tips


#17:How can I read a printer settings - page sizes and margins?

From today I shall post a some useful functions for printer settings detect. Today I include a functions for printer page width/height and margins getting.

function GetPageWidth: Integer;
begin
  Result := GetDeviceCaps(Printer.Handle, PHYSICALWIDTH)
end;

function GetPageHeight: Integer;
begin
  Result := GetDeviceCaps(Printer.Handle, PHYSICALHEIGHT)
end;

function GetPageOffsetLeft: Integer;
begin
  Result := GetDeviceCaps(Printer.Handle, PHYSICALOFFSETX)
end;

function GetPageOffsetRight: Integer;
begin
  Result := GetPageWidth - GetPageOffsetLeft - GetDeviceCaps(Printer.Handle, HORZRES)
end;

function GetPageOffsetTop: Integer;
begin
  Result := GetDeviceCaps(Printer.Handle, PHYSICALOFFSETY)
end;

function GetPageOffsetBottom: Integer;
begin
  Result := GetPageHeight - GetPageOffsetTop - GetDeviceCaps(Printer.Handle, VERTRES)
end;

function GetPixelsPerInchX: Integer;
begin
  Result := GetDeviceCaps(Printer.Handle, LOGPIXELSX)
end;

function GetPixelsPerInchY: Integer;
begin
  Result := GetDeviceCaps(Printer.Handle, LOGPIXELSY)
end;

PS: of course, the GetPage* and GetPageOffset* results will be in printer units. If you want to convert in screen units you must calculate: Result := Screen.PixelsPerInch*GetPage.. div GetPixelsPerInchX (or Y)

See also
 
DBLoad
Excel Web-stream
Clarion Viewer
MAPIMail
Viewer for MS Outlook Messages
dBase Viewer
Database Information Manager
SMExport suite
Viewer for TNEF-files (winmail.dat)
SMDBGrid
 
 
Contact to webmaster

 

Borland Software CodeGear Embarcadero Technologies Scalabium Delphi tips

Copyrightc 1998-2012, Scalabium Software. All rights reserved.
webmaster@scalabium.com

August 20, 1999

SMReport Autogenerated